Tests / @ogygia/rewrite
@ogygia/rewrite
Version 0.14.0 latest
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
| Test | Kind | Node | Chromium | Firefox | WebKit |
|---|---|---|---|---|---|
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 in | End to end | not run | pass | pass | pass |
| a hole’s answer arrives restored, and its island hydrates after | End to end | not run | pass | pass | pass |
| a router navigation away and back: every restored host has its sheet, and nothing throws | End to end | not run | pass | pass | pass |
| a router navigation morphs a server-owned host its own runtime unpacked, without the transform’s tree in its light DOM | End to end | not run | pass | pass | pass |
| a router-fetched page is rendered as an answer: every host planned, and the response varies on it | End to end | not run | pass | pass | pass |
| the island inside a reshaped host hydrates as is, and stays interactive | End to end | not run | pass | pass | pass |
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 log | Browser | not run | pass | pass | pass |
packages/rewrite/test/browser/host-classes.test.ts | |||||
| a token the component dropped on the client before the hydrate stays dropped | Browser | not run | pass | pass | pass |
| an element hydration replaced gets nothing put back: the element left the page | Browser | not run | pass | pass | pass |
| Svelte’s own tokens are never put back; unrestored and replaced elements are left alone | Browser | not run | pass | pass | pass |
| the component’s tokens as they are just before the hydrate come back after Svelte’s write | Browser | not run | pass | pass | pass |
| through a real Svelte hydrate: the class write happens, and the component’s token survives it | Browser | not run | pass | pass | pass |
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 code | Browser | not run | pass | pass | pass |
| a parsed answer builds none of its custom elements, in this engine (#382)#382 | Browser | not run | pass | pass | pass |
| a shadow sheet a host names but the page lacks is said once per key, with its code | Browser | not run | pass | pass | pass |
| every parse is checked: an answer with a built custom element breaks rule_parse_upgraded | Browser | not run | pass | pass | pass |
| production: a late restore is said once per page and host tag, with its code | Browser | not run | pass | pass | pass |
| under the Firefox 159 model, an answer stays inert, and its host is restored, never late (#382)#382 | Browser | not run | pass | pass | pass |
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’s | Browser | not run | pass | pass | pass |
| a csr=false page arms no class watch (the island hydrate puts the tokens back) | Browser | not run | pass | pass | pass |
| a custom element keeps the class tokens its render added beside Svelte’s (recorded for the hydrate); a plain element gets Svelte’s alone | Browser | not run | pass | pass | pass |
| a declarative shadow root parsed in an inert fragment gets the page’s registry after insertion (no transform needed) | Browser | not run | pass | pass | pass |
| a dev check that does not parse checks nothing: the restore goes on, and the script is consumed | Browser | not run | pass | pass | pass |
| a DOM without adoptable sheets or CSS.escape (jsdom): a <style> per root | Browser | not run | pass | pass | pass |
| a host its component already upgraded (no root of its own yet) keeps its identity and gets the restored root | Browser | not run | pass | pass | pass |
| a host that cannot have a shadow root is skipped and said; the hosts after it are restored | Browser | not run | pass | pass | pass |
| a host that names a shadow sheet the page does not carry is recorded, and its other sheets still adopted | Browser | not run | pass | pass | pass |
| 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 so | Browser | not run | pass | pass | pass |
| a host whose tag name holds markup characters is restored with nothing parsed out of its name | Browser | not run | pass | pass | pass |
| a host with an attribute name only the HTML parser accepts (`=eq`) is restored, and so is every host after it | Browser | not run | pass | pass | pass |
| a host’s attribute reset (`og-r`) never sets a data: URL, which html.ts refuses too | Browser | not run | pass | pass | pass |
| a host’s attribute reset (`og-r`) never sets an on* handler or a javascript: URL | Browser | not run | pass | pass | pass |
| 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 one | Browser | not run | pass | pass | pass |
| a Kit-hydrated page: the first whole write to Svelte’s tokens gets back what it dropped; the component’s own later removals stand | Browser | not run | pass | pass | pass |
| a mangled attribute reset (`og-r`) leaves the host’s attributes as served, and its mark gone | Browser | not run | pass | pass | pass |
| a missing shadow sheet named by many hosts is logged once per key, and the log keeps room for what comes after | Browser | not run | pass | pass | pass |
| a planned host inside a declarative shadow root the page shipped is restored too | Browser | not run | pass | pass | pass |
| a root restored in an answer’s inert fragment gets the page’s registry after insertion: what is inside upgrades | Browser | not run | pass | pass | pass |
| a root that cannot adopt its sheet leaves the others in the answer theirs | Browser | not run | pass | pass | pass |
| a router swap: a root the swap left in the parsed page is skipped, and every root in this one gets its sheets | Browser | not run | pass | pass | pass |
| a stand-in becomes only a tag the server pass writes as one, without on* attributes | Browser | not run | pass | pass | pass |
| a stand-in keeps the parser from splitting the page’s link, and becomes a real <a> in the tree | Browser | not run | pass | pass | pass |
| 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)#1775 | Browser | not run | pass | pass | pass |
| a text mark whose original does not parse carries none: the text stays as served, the mark gone | Browser | not run | pass | pass | pass |
| an answer restored in its inert fragment: a component that attaches its own root upgrades at insertion over the emptied root | Browser | not run | pass | pass | pass |
| an answer still waiting for its stylesheet keeps its roots while another answer goes in | Browser | not run | pass | pass | pass |
| an answer’s fragment: restored before insertion, its sheets adopted once the host is in the page | Browser | not run | pass | pass | pass |
| dev: the check compares each restored host with Svelte’s children, and names the first difference | Browser | not run | pass | pass | pass |
| 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) | Browser | not run | pass | pass | pass |
| putting attributes back never adds an event handler, a srcdoc or a javascript: URL | Browser | not run | pass | pass | pass |
| self-contained: the function source runs on its own (the handle inlines it) | Browser | not run | pass | pass | pass |
| Svelte’s children put back into a host are known render output (a later morph may remove one) | Browser | not run | pass | pass | pass |
| text a render trimmed inside a custom element it did not render comes back through the planned host above | Browser | not run | pass | pass | pass |
| the dev check reads class as tokens and style as declarations, an empty one as absent | Browser | not run | pass | pass | pass |
| the document: a shadow root with the tree, Svelte’s children back exactly, the host’s attributes back | Browser | not run | pass | pass | pass |
| the restorer swaps back every tag the server pass may write as a stand-in | Browser | not run | pass | pass | pass |
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 once | Browser | not run | pass | pass | pass |
| region answers: every host restored in the fragment, nothing left, idempotent | Browser | not run | pass | pass | pass |
packages/rewrite/test/browser/rewrite.test.ts | |||||
| check(): a document, its restored hosts compared with Svelte’s | Browser | not run | pass | pass | pass |
| check(): a region answer restored in a DOM, every host exactly Svelte’s | Browser | not run | pass | pass | pass |
| check(): a render that changes Svelte’s children is named in mismatches | Browser | not run | pass | pass | pass |
| chunk by chunk: the first chunk’s restorer and each later chunk’s call restore exactly their hosts, sheets found inline | Browser | not run | pass | pass | pass |
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 URLs | Browser | not run | pass | pass | pass |
| the script-URL table in the restorer > inline, as the page runs it: an attribute reset sets every value but the script URLs | Browser | not run | pass | pass | pass |
| the script-URL table in the restorer > this browser’s URL parser says what the table says | Browser | not run | pass | pass | pass |
packages/rewrite/test/plugin.test.ts | |||||
| a rewrite() handle > gives a pass to the requests it wrapped, and to no other | Unit | pass | not run | not run | not run |
| a rewrite() handle > listed after ogygia.handle() is refused with rewrite_after_ogygia | Unit | pass | not run | not run | not run |
| a rewrite() handle > refuses every request while rewrite() is not in vite.config, naming the fix | Unit | pass | not run | not run | not run |
| a rewrite() handle > several in sequence share one pass, in the order they ran | Unit | pass | not run | not run | not run |
| core's handle > refuses `transform`, pointing at @ogygia/rewrite | Unit | pass | not run | not run | not run |
| rewrite() in vite.config > takes no options, is named by its package and names its realms, the modules beside it | Unit | pass | not run | not run | not run |
packages/rewrite/test/restorer-inline-safe.test.ts | |||||
| the inlined restorer > is one script element whose text holds no </script and no <!-- | Unit | pass | not run | not run | not run |
packages/rewrite/test/restorer-size.test.ts | |||||
| the inlined restorer > a later chunk’s restore is one short call | Unit | pass | not run | not run | not run |
| the inlined restorer > minified as the build does, stays inside its budget: 9.7 kB, 3.45 kB brotli | Unit | pass | not run | not run | not run |
packages/rewrite/test/reversible-browser-read.test.ts | |||||
| mark reads tags as the browser does > a comment ends at `--!>` and `<!-->` too | Unit | pass | not run | not run | not run |
| mark reads tags as the browser does > a host inside a noscript is text, not an element | Unit | pass | not run | not run | not run |
| mark reads tags as the browser does > a quote inside an unquoted value does not hide the host after it | Unit | pass | not run | not run | not run |
| mark reads tags as the browser does > a region’s attributes in any quoting place its hosts | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not run |
| closes_all > refuses HTML that would take in the page after it, or close an element around it | Unit | pass | not run | not run | not run |
| closes_all > takes HTML that closes what it opens, implied closes and voids included | Unit | pass | not run | not run | not run |
| localize_marks > gives back the same string when the marks already count from 0 | Unit | pass | not run | not run | not run |
| localize_marks > reads back ids a serializer requoted | Unit | pass | not run | not run | not run |
| localize_marks > renumbers a block’s marks from 0 for a cache key, and puts the document’s ids back after | Unit | pass | not run | not run | not run |
| mark > a baked live region is opaque like a lake: on a Kit-hydrated document its hosts get no plan, its islands keep theirs | Unit | pass | not run | not run | not run |
| mark > a document the router fetched is an answer: every host planned, as in a region answer | Unit | pass | not run | not run | not run |
| mark > a Kit-hydrated document is Svelte-owned throughout its body; a region answer plans every host | Unit | pass | not run | not run | not run |
| mark > a server-owned host around a hole is planned: ogygia swaps the hole, its runtime must not adopt it | Unit | pass | not run | not run | not run |
| mark > marks text a trimmer could change, deeper inside a planned host’s children — never the first text of a <pre> | Unit | pass | not run | not run | not run |
| mark > plans the hosts in Svelte-owned markup and around it; tags every custom element’s children | Unit | pass | not run | not run | not run |
| restored_ids > reads og-h however a serializer quotes it | Unit | pass | not run | not run | not run |
| settle > a block the tree opens inside a Svelte <p> becomes a stand-in too | Unit | pass | not run | not run | not run |
| settle > a host ogygia will not restore gets no comment marks (its element children still carry their tag) | Unit | pass | not run | not run | not run |
| settle > a host without a plan loses every mark: left exactly as the transform wrote it | Unit | pass | not run | not run | not run |
| settle > a planned host keeps what the restorer needs: the attributes to reset, the text the render changed | Unit | pass | not run | not run | not run |
| settle > a planned host that is also a tagged child carries one attribute reset: its own | Unit | pass | not run | not run | not run |
| settle > a tagged child that is a host ogygia won’t restore keeps the attributes its runtime adopts it by | Unit | pass | not run | not run | not run |
| settle > dev: each planned host’s original children, for the browser’s check | Unit | pass | not run | not run | not run |
| settle > head assets in a document’s body go to its head, once per key | Unit | pass | not run | not run | not run |
| settle > settle alone drops marks of hosts the transform never planned | Unit | pass | not run | not run | not run |
| settle > stand-ins: a start tag the parser would restructure, where the render made either side of it | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not run |
| an identity render > gives any markup, cut anywhere, back byte for byte (csr false, answer false) | Unit | pass | not run | not run | not run |
| an identity render > gives any markup, cut anywhere, back byte for byte (csr false, answer true) | Unit | pass | not run | not run | not run |
| an identity render > gives any markup, cut anywhere, back byte for byte (csr true, answer false) | Unit | pass | not run | not run | not run |
packages/rewrite/test/rewrite.test.ts | |||||
| .check() > lists failures, counts restored hosts, and has no DOM in node | Unit | pass | not run | not run | not 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 so | Unit | pass | not run | not run | not 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 it | Unit | pass | not run | not run | not 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 it | Unit | pass | not run | not run | not 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 it | Unit | pass | not run | not run | not run |
| element rewrites: failures cost only the element > a batch with the wrong count is retried one at a time | Unit | pass | not run | not run | not run |
| element rewrites: failures cost only the element > a cancelled request: the batch is shipped as is, never retried, nothing said | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not run |
| element rewrites: failures cost only the element > a later chunk of a cancelled request goes out as it came, never rendered | Unit | pass | not run | not run | not run |
| element rewrites: failures cost only the element > a request cancelled during the first rewrite: the second never renders, and nothing is written | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not run |
| element rewrites: failures cost only the element > production says each failure with its code, once per response and element name | Unit | pass | not run | not run | not 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 code | Unit | pass | not run | not run | not 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 go | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not run |
| element rewrites: the restore > a later chunk: its sheet inline at first use, once per key, and one restore call at its end | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not run |
| element rewrites: the restore > an element split across chunks goes out unrendered, said once, and the rest is read after it | Unit | pass | not run | not run | not run |
| element rewrites: the restore > the chunk that restored something carries the restorer before </body>; its sheets go to the head | Unit | pass | not run | not run | not run |
| element rewrites: the restore > the last chunk carries a restore still waiting, wherever it ends | Unit | pass | not run | not run | not run |
| element rewrites: what goes to render > a custom element outside Svelte-owned markup is rendered, not restored | Unit | pass | not run | not run | not run |
| element rewrites: what goes to render > a page with no match goes out byte for byte, render is never called, and no restorer ships | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not run |
| element rewrites: what goes to render > only the outermost match goes, with marks numbered from 0, and equal elements render once | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not run |
| element rewrites: what goes to render > the context carries kind, csr, url, event and a signal that fires when the request is cancelled | Unit | pass | not run | not run | not run |
| element rewrites: what goes to render > the ids of a response keep counting past each element, so marks never collide | Unit | pass | not run | not run | not run |
| region answers > every host is restored; sheets go inline for the runtime to hoist | Unit | pass | not run | not run | not run |
| several rewrites > run in order on one marking: the second sees the first one’s output, marks intact | Unit | pass | not run | not run | not run |
| the page form > .html(str) runs the page function on a plain string, outside any request | Unit | pass | not run | not run | not run |
| the page form > a page function that throws: production sends the document as ogygia rendered it, said as rewrite_page_failed | Unit | pass | not run | not run | not run |
| the page form > a request cancelled while the page function ran: the document goes out as ogygia rendered it | Unit | pass | not run | not run | not run |
| the page form > dev throws it | Unit | pass | not run | not run | not run |
| the page form > holds the document until its last chunk and rewrites it whole | Unit | pass | not run | not run | not run |
packages/rewrite/test/types.test.ts | |||||
| rewrite() > an element rewrite is a Kit handle with .check(); a page rewrite also has .html() | Unit | pass | not run | not run | not run |
| rewrite() > render gets the elements and the context, and gives one result per element, sync or async | Unit | pass | not run | not run | not run |