Tests / @ogygia/rewrite

@ogygia/rewrite

Version 0.14.0 latest
commit 620ddcca
155 test runs (155 tests, each run in Node, the browsers or both)
0.90× lines of test for each line of source (2,939 to 3,254) Only real test code counts: test files and their helpers, not fixtures, sample apps or benches. Blank lines are left out on both sides.
Exactly what is counted non-blank lines of test code across the repo (*.test.ts, *.test-d.ts, *.spec.ts, and the .ts helpers in test/ and e2e/ folders; no fixtures, fixture apps, stubs or benches), over non-blank lines of packages/*/src (no .d.ts or generated files)
94.8% of source lines run by the tests
  • 90Unit
  • 59Browser
  • 6End to end
  • 0Type tests
  • 0Lint rules
  • 0Failing

Coverage

  • 94.8%Lines
  • 88.7%Branches
  • 89.7%Functions
  • 93.3%Statements

Every test

155 tests

TestKindNodeChromiumFirefoxWebKit
packages/rewrite/e2e/restore.spec.ts
a first-load copy reaching the router (a store, a prerender, a cache that ignores Vary) is loaded, never swapped inEnd to endnot runpasspasspass
a hole’s answer arrives restored, and its island hydrates afterEnd to endnot runpasspasspass
a router navigation away and back: every restored host has its sheet, and nothing throwsEnd to endnot runpasspasspass
a router navigation morphs a server-owned host its own runtime unpacked, without the transform’s tree in its light DOMEnd to endnot runpasspasspass
a router-fetched page is rendered as an answer: every host planned, and the response varies on itEnd to endnot runpasspasspass
the island inside a reshaped host hydrates as is, and stays interactiveEnd to endnot runpasspasspass
packages/rewrite/test/browser-chunk-lost/restore-report.test.ts
a restore report whose wording chunk does not load says nothing, throws nothing, and keeps the logBrowsernot runpasspasspass
packages/rewrite/test/browser/host-classes.test.ts
a token the component dropped on the client before the hydrate stays droppedBrowsernot runpasspasspass
an element hydration replaced gets nothing put back: the element left the pageBrowsernot runpasspasspass
Svelte’s own tokens are never put back; unrestored and replaced elements are left aloneBrowsernot runpasspasspass
the component’s tokens as they are just before the hydrate come back after Svelte’s writeBrowsernot runpasspasspass
through a real Svelte hydrate: the class write happens, and the component’s token survives itBrowsernot runpasspasspass
packages/rewrite/test/browser/inert-parse.test.ts
a host that cannot have a shadow root is said once per page and host tag, with its codeBrowsernot runpasspasspass
a parsed answer builds none of its custom elements, in this engine (#382)#382Browsernot runpasspasspass
a shadow sheet a host names but the page lacks is said once per key, with its codeBrowsernot runpasspasspass
every parse is checked: an answer with a built custom element breaks rule_parse_upgradedBrowsernot runpasspasspass
production: a late restore is said once per page and host tag, with its codeBrowsernot runpasspasspass
under the Firefox 159 model, an answer stays inert, and its host is restored, never late (#382)#382Browsernot runpasspasspass
packages/rewrite/test/browser/restore.test.ts
a component that attaches its own root in its constructor upgrades over a restored host: the root comes back emptied, the light DOM stays Svelte’sBrowsernot runpasspasspass
a csr=false page arms no class watch (the island hydrate puts the tokens back)Browsernot runpasspasspass
a custom element keeps the class tokens its render added beside Svelte’s (recorded for the hydrate); a plain element gets Svelte’s aloneBrowsernot runpasspasspass
a declarative shadow root parsed in an inert fragment gets the page’s registry after insertion (no transform needed)Browsernot runpasspasspass
a dev check that does not parse checks nothing: the restore goes on, and the script is consumedBrowsernot runpasspasspass
a DOM without adoptable sheets or CSS.escape (jsdom): a <style> per rootBrowsernot runpasspasspass
a host its component already upgraded (no root of its own yet) keeps its identity and gets the restored rootBrowsernot runpasspasspass
a host that cannot have a shadow root is skipped and said; the hosts after it are restoredBrowsernot runpasspasspass
a host that names a shadow sheet the page does not carry is recorded, and its other sheets still adoptedBrowsernot runpasspasspass
a host upgraded before the restore reached it keeps its own root; the light DOM is put back, the server’s tree dropped, and it says soBrowsernot runpasspasspass
a host whose tag name holds markup characters is restored with nothing parsed out of its nameBrowsernot runpasspasspass
a host with an attribute name only the HTML parser accepts (`=eq`) is restored, and so is every host after itBrowsernot runpasspasspass
a host’s attribute reset (`og-r`) never sets a data: URL, which html.ts refuses tooBrowsernot runpasspasspass
a host’s attribute reset (`og-r`) never sets an on* handler or a javascript: URLBrowsernot runpasspasspass
a Kit-hydrated page: a watched host that leaves the document leaves the watch, a moved one stays, and the observer goes with the last oneBrowsernot runpasspasspass
a Kit-hydrated page: the first whole write to Svelte’s tokens gets back what it dropped; the component’s own later removals standBrowsernot runpasspasspass
a mangled attribute reset (`og-r`) leaves the host’s attributes as served, and its mark goneBrowsernot runpasspasspass
a missing shadow sheet named by many hosts is logged once per key, and the log keeps room for what comes afterBrowsernot runpasspasspass
a planned host inside a declarative shadow root the page shipped is restored tooBrowsernot runpasspasspass
a root restored in an answer’s inert fragment gets the page’s registry after insertion: what is inside upgradesBrowsernot runpasspasspass
a root that cannot adopt its sheet leaves the others in the answer theirsBrowsernot runpasspasspass
a router swap: a root the swap left in the parsed page is skipped, and every root in this one gets its sheetsBrowsernot runpasspasspass
a stand-in becomes only a tag the server pass writes as one, without on* attributesBrowsernot runpasspasspass
a stand-in keeps the parser from splitting the page’s link, and becomes a real <a> in the treeBrowsernot runpasspasspass
a stand-in with an attribute name only the HTML parser accepts (`=eq`) becomes its tag, and so does every stand-in after it (#1775)#1775Browsernot runpasspasspass
a text mark whose original does not parse carries none: the text stays as served, the mark goneBrowsernot runpasspasspass
an answer restored in its inert fragment: a component that attaches its own root upgrades at insertion over the emptied rootBrowsernot runpasspasspass
an answer still waiting for its stylesheet keeps its roots while another answer goes inBrowsernot runpasspasspass
an answer’s fragment: restored before insertion, its sheets adopted once the host is in the pageBrowsernot runpasspasspass
dev: the check compares each restored host with Svelte’s children, and names the first differenceBrowsernot runpasspasspass
every dev check under the root is read and consumed: a restore of a streamed page checks the hosts of every chunk, and a second restore finds nothing (found by the rewrite sim)Browsernot runpasspasspass
putting attributes back never adds an event handler, a srcdoc or a javascript: URLBrowsernot runpasspasspass
self-contained: the function source runs on its own (the handle inlines it)Browsernot runpasspasspass
Svelte’s children put back into a host are known render output (a later morph may remove one)Browsernot runpasspasspass
text a render trimmed inside a custom element it did not render comes back through the planned host aboveBrowsernot runpasspasspass
the dev check reads class as tokens and style as declarations, an empty one as absentBrowsernot runpasspasspass
the document: a shadow root with the tree, Svelte’s children back exactly, the host’s attributes backBrowsernot runpasspasspass
the restorer swaps back every tag the server pass may write as a stand-inBrowsernot runpasspasspass
packages/rewrite/test/browser/rewrite-sim.test.ts
a seeded swarm of streamed pages through two failing rewrites restores what Svelte rendered, says every failure, and restores onceBrowsernot runpasspasspass
region answers: every host restored in the fragment, nothing left, idempotentBrowsernot runpasspasspass
packages/rewrite/test/browser/rewrite.test.ts
check(): a document, its restored hosts compared with Svelte’sBrowsernot runpasspasspass
check(): a region answer restored in a DOM, every host exactly Svelte’sBrowsernot runpasspasspass
check(): a render that changes Svelte’s children is named in mismatchesBrowsernot runpasspasspass
chunk by chunk: the first chunk’s restorer and each later chunk’s call restore exactly their hosts, sheets found inlineBrowsernot runpasspasspass
packages/rewrite/test/browser/script-url.test.ts
the script-URL table in the restorer > as a module: an attribute reset sets every value but the script URLsBrowsernot runpasspasspass
the script-URL table in the restorer > inline, as the page runs it: an attribute reset sets every value but the script URLsBrowsernot runpasspasspass
the script-URL table in the restorer > this browser’s URL parser says what the table saysBrowsernot runpasspasspass
packages/rewrite/test/plugin.test.ts
a rewrite() handle > gives a pass to the requests it wrapped, and to no otherUnitpassnot runnot runnot run
a rewrite() handle > listed after ogygia.handle() is refused with rewrite_after_ogygiaUnitpassnot runnot runnot run
a rewrite() handle > refuses every request while rewrite() is not in vite.config, naming the fixUnitpassnot runnot runnot run
a rewrite() handle > several in sequence share one pass, in the order they ranUnitpassnot runnot runnot run
core's handle > refuses `transform`, pointing at @ogygia/rewriteUnitpassnot runnot runnot run
rewrite() in vite.config > takes no options, is named by its package and names its realms, the modules beside itUnitpassnot runnot runnot run
packages/rewrite/test/restorer-inline-safe.test.ts
the inlined restorer > is one script element whose text holds no </script and no <!--Unitpassnot runnot runnot run
packages/rewrite/test/restorer-size.test.ts
the inlined restorer > a later chunk’s restore is one short callUnitpassnot runnot runnot run
the inlined restorer > minified as the build does, stays inside its budget: 9.7 kB, 3.45 kB brotliUnitpassnot runnot runnot run
packages/rewrite/test/reversible-browser-read.test.ts
mark reads tags as the browser does > a comment ends at `--!>` and `<!-->` tooUnitpassnot runnot runnot run
mark reads tags as the browser does > a host inside a noscript is text, not an elementUnitpassnot runnot runnot run
mark reads tags as the browser does > a quote inside an unquoted value does not hide the host after itUnitpassnot runnot runnot run
mark reads tags as the browser does > a region’s attributes in any quoting place its hostsUnitpassnot runnot runnot run
packages/rewrite/test/reversible.test.ts
a page tag that closes a custom element around it > is the page’s, not the render’s: settle never makes it a stand-in (found by the round-trip fuzz)Unitpassnot runnot runnot run
closes_all > refuses HTML that would take in the page after it, or close an element around itUnitpassnot runnot runnot run
closes_all > takes HTML that closes what it opens, implied closes and voids includedUnitpassnot runnot runnot run
localize_marks > gives back the same string when the marks already count from 0Unitpassnot runnot runnot run
localize_marks > reads back ids a serializer requotedUnitpassnot runnot runnot run
localize_marks > renumbers a block’s marks from 0 for a cache key, and puts the document’s ids back afterUnitpassnot runnot runnot run
mark > a baked live region is opaque like a lake: on a Kit-hydrated document its hosts get no plan, its islands keep theirsUnitpassnot runnot runnot run
mark > a document the router fetched is an answer: every host planned, as in a region answerUnitpassnot runnot runnot run
mark > a Kit-hydrated document is Svelte-owned throughout its body; a region answer plans every hostUnitpassnot runnot runnot run
mark > a server-owned host around a hole is planned: ogygia swaps the hole, its runtime must not adopt itUnitpassnot runnot runnot run
mark > marks text a trimmer could change, deeper inside a planned host’s children — never the first text of a <pre>Unitpassnot runnot runnot run
mark > plans the hosts in Svelte-owned markup and around it; tags every custom element’s childrenUnitpassnot runnot runnot run
restored_ids > reads og-h however a serializer quotes itUnitpassnot runnot runnot run
settle > a block the tree opens inside a Svelte <p> becomes a stand-in tooUnitpassnot runnot runnot run
settle > a host ogygia will not restore gets no comment marks (its element children still carry their tag)Unitpassnot runnot runnot run
settle > a host without a plan loses every mark: left exactly as the transform wrote itUnitpassnot runnot runnot run
settle > a planned host keeps what the restorer needs: the attributes to reset, the text the render changedUnitpassnot runnot runnot run
settle > a planned host that is also a tagged child carries one attribute reset: its ownUnitpassnot runnot runnot run
settle > a tagged child that is a host ogygia won’t restore keeps the attributes its runtime adopts it byUnitpassnot runnot runnot run
settle > dev: each planned host’s original children, for the browser’s checkUnitpassnot runnot runnot run
settle > head assets in a document’s body go to its head, once per keyUnitpassnot runnot runnot run
settle > settle alone drops marks of hosts the transform never plannedUnitpassnot runnot runnot run
settle > stand-ins: a start tag the parser would restructure, where the render made either side of itUnitpassnot runnot runnot run
packages/rewrite/test/rewrite-fuzz.test.ts
a render that only adds beside each element > leaves every other byte as it was: marks, settle and splice undo each other (csr false, answer false)Unitpassnot runnot runnot run
a render that only adds beside each element > leaves every other byte as it was: marks, settle and splice undo each other (csr false, answer true)Unitpassnot runnot runnot run
a render that only adds beside each element > leaves every other byte as it was: marks, settle and splice undo each other (csr true, answer false)Unitpassnot runnot runnot run
an identity render > gives any markup, cut anywhere, back byte for byte (csr false, answer false)Unitpassnot runnot runnot run
an identity render > gives any markup, cut anywhere, back byte for byte (csr false, answer true)Unitpassnot runnot runnot run
an identity render > gives any markup, cut anywhere, back byte for byte (csr true, answer false)Unitpassnot runnot runnot run
packages/rewrite/test/rewrite.test.ts
.check() > lists failures, counts restored hosts, and has no DOM in nodeUnitpassnot runnot runnot run
buggify points: each way a render fails, drawn by the simulator > rewrite.chunk-split: a chunk read as two, cut inside an element, ships that element unrendered and says soUnitpassnot runnot runnot run
buggify points: each way a render fails, drawn by the simulator > rewrite.render-count: a batch one result short is retried one at a time, and an element whose own answer is short goes out as ogygia rendered itUnitpassnot runnot runnot run
buggify points: each way a render fails, drawn by the simulator > rewrite.render-malformed: a result that does not close what it opens goes out as ogygia rendered itUnitpassnot runnot runnot run
buggify points: each way a render fails, drawn by the simulator > rewrite.render-strips-marks: a result without the og-h of a host ogygia restores goes out as ogygia rendered itUnitpassnot runnot runnot run
element rewrites: failures cost only the element > a batch with the wrong count is retried one at a timeUnitpassnot runnot runnot run
element rewrites: failures cost only the element > a cancelled request: the batch is shipped as is, never retried, nothing saidUnitpassnot runnot runnot run
element rewrites: failures cost only the element > a failed batch is retried one element at a time; one that drops the marks goes out as ogygia rendered it (rewrite_marks_lost)Unitpassnot runnot runnot run
element rewrites: failures cost only the element > a failed batch is retried one element at a time; one that returns a bad sheet goes out as ogygia rendered it (rewrite_element_failed)Unitpassnot runnot runnot run
element rewrites: failures cost only the element > a failed batch is retried one element at a time; one that returns html that does not close goes out as ogygia rendered it (rewrite_element_failed)Unitpassnot runnot runnot run
element rewrites: failures cost only the element > a failed batch is retried one element at a time; one that returns no html goes out as ogygia rendered it (rewrite_element_failed)Unitpassnot runnot runnot run
element rewrites: failures cost only the element > a failed batch is retried one element at a time; one that throws goes out as ogygia rendered it (rewrite_element_failed)Unitpassnot runnot runnot run
element rewrites: failures cost only the element > a later chunk of a cancelled request goes out as it came, never renderedUnitpassnot runnot runnot run
element rewrites: failures cost only the element > a request cancelled during the first rewrite: the second never renders, and nothing is writtenUnitpassnot runnot runnot run
element rewrites: failures cost only the element > a request cancelled while the elements are retried one at a time: shipped as is, nothing said, and no element’s render starts after the cancel (found by the long rewrite sim)Unitpassnot runnot runnot run
element rewrites: failures cost only the element > production says each failure with its code, once per response and element nameUnitpassnot runnot runnot run
element rewrites: failures cost only the element > rule_rewrite_after_cancel: a render called after the request was cancelled is said with the rule’s codeUnitpassnot runnot runnot run
element rewrites: the restore > a chunk that ends inside a region or a tag carries no script: the restore waits for a chunk that ends where one may goUnitpassnot runnot runnot run
element rewrites: the restore > a chunk-1 meta or sheet never lands inside an island: the first-load mark goes before the element it is for (found by the rewrite sim)Unitpassnot runnot runnot run
element rewrites: the restore > a later chunk: its sheet inline at first use, once per key, and one restore call at its endUnitpassnot runnot runnot run
element rewrites: the restore > a later chunk's host inside a declarative shadow root the page opened, in that chunk or an earlier one, gets the restore call that enters every root (found by the rewrite sim)Unitpassnot runnot runnot run
element rewrites: the restore > a matched element whose start tag a chunk boundary cuts (after "<", in a chunk with no match before it) is said as split, as one its chunk ends inside (found by the rewrite sim)Unitpassnot runnot runnot run
element rewrites: the restore > a matched element whose start tag a chunk boundary cuts (after "<dem", in a chunk with no match before it) is said as split, as one its chunk ends inside (found by the rewrite sim)Unitpassnot runnot runnot run
element rewrites: the restore > a matched element whose start tag a chunk boundary cuts (after "<demo-", in a chunk with no match before it) is said as split, as one its chunk ends inside (found by the rewrite sim)Unitpassnot runnot runnot run
element rewrites: the restore > a matched element whose start tag a chunk boundary cuts (after "<demo-ca", in a chunk with no match before it) is said as split, as one its chunk ends inside (found by the rewrite sim)Unitpassnot runnot runnot run
element rewrites: the restore > a matched element whose start tag a chunk boundary cuts (after "<demo", in a chunk with no match before it) is said as split, as one its chunk ends inside (found by the rewrite sim)Unitpassnot runnot runnot run
element rewrites: the restore > a region whose start tag is cut by a chunk boundary (after "<") still owns its elements (found by the rewrite sim)Unitpassnot runnot runnot run
element rewrites: the restore > a region whose start tag is cut by a chunk boundary (after "<ogygia-region entry") still owns its elements (found by the rewrite sim)Unitpassnot runnot runnot run
element rewrites: the restore > a region whose start tag is cut by a chunk boundary (after "<ogygia-region") still owns its elements (found by the rewrite sim)Unitpassnot runnot runnot run
element rewrites: the restore > an element split across chunks goes out unrendered, said once, and the rest is read after itUnitpassnot runnot runnot run
element rewrites: the restore > the chunk that restored something carries the restorer before </body>; its sheets go to the headUnitpassnot runnot runnot run
element rewrites: the restore > the last chunk carries a restore still waiting, wherever it endsUnitpassnot runnot runnot run
element rewrites: what goes to render > a custom element outside Svelte-owned markup is rendered, not restoredUnitpassnot runnot runnot run
element rewrites: what goes to render > a page with no match goes out byte for byte, render is never called, and no restorer shipsUnitpassnot runnot runnot run
element rewrites: what goes to render > a render the page around its element would restructure goes out as a stand-in: a <div> in the page’s <p>, an <a> in the page’s <a> (the restore lab e2e)Unitpassnot runnot runnot run
element rewrites: what goes to render > only the outermost match goes, with marks numbered from 0, and equal elements render onceUnitpassnot runnot runnot run
element rewrites: what goes to render > text that spells a mark is text: moving ids never touches it, and render sees it as written (found by the fuzz)Unitpassnot runnot runnot run
element rewrites: what goes to render > the context carries kind, csr, url, event and a signal that fires when the request is cancelledUnitpassnot runnot runnot run
element rewrites: what goes to render > the ids of a response keep counting past each element, so marks never collideUnitpassnot runnot runnot run
region answers > every host is restored; sheets go inline for the runtime to hoistUnitpassnot runnot runnot run
several rewrites > run in order on one marking: the second sees the first one’s output, marks intactUnitpassnot runnot runnot run
the page form > .html(str) runs the page function on a plain string, outside any requestUnitpassnot runnot runnot run
the page form > a page function that throws: production sends the document as ogygia rendered it, said as rewrite_page_failedUnitpassnot runnot runnot run
the page form > a request cancelled while the page function ran: the document goes out as ogygia rendered itUnitpassnot runnot runnot run
the page form > dev throws itUnitpassnot runnot runnot run
the page form > holds the document until its last chunk and rewrites it wholeUnitpassnot runnot runnot run
packages/rewrite/test/types.test.ts
rewrite() > an element rewrite is a Kit handle with .check(); a page rewrite also has .html()Unitpassnot runnot runnot run
rewrite() > render gets the elements and the context, and gives one result per element, sync or asyncUnitpassnot runnot runnot run