Script loading
Complementary test nets pin the script-loading subsystem (design,
implementation). The fixture-site nets run in npm run test:repo; the
build-time vendoring and browser nets run in npm run test:visual.
Golden net
scripts-golden.test.mjs pins, across fixture configurations:
- the rendered script region of selected pages, and
- every locally built script, byte-exact.
Fixture builds, region extraction, and the comparison form live in
lib/scripts-goldens.mjs. The net was committed and verified
green against untouched main before the scripts.html decomposition, so the
refactor’s no-output-change claim is machine-checked, not asserted.
The goldens are committed. After a reviewed, intended output change, refresh them with:
npm run update:scripts-goldens
Dispatch net
scripts-dispatch.test.mjs pins the dispatcher’s page-flag
wiring: the .Page.Store-gated partials (Mermaid, KaTeX) are dispatched on
flagged pages only. The real partials fetch remote assets at build time, so
fixture marker overrides stand in for them; what’s pinned is exactly the
gate-to-partial wiring, offline.
Loop-contract tests
plugins.test.mjs pins the plugin loop’s registry contract:
- Emission:
enable/deferhandling, deterministic order, env-override booleans, companions and shims (a shim-gated plugin, and a head-end flag widening its gate), SRI in development builds. - Validation: shape-guard warnings (the pre-release list shape and a site’s
own
params.docsyincluded), name and field allowlisting (the_docsy-shimsuffix refused, unknown fields warned), theversionguard’s warning and error policy. - Layering: theme plugins through Hugo’s config merge (inheritance, override, turn-off).
Three companion nets pin the conversions:
tabpane-persist-plugin.test.mjs: the ungated default, persistence opt-out, and theme-plugin shadowing.markmap-plugin.test.mjsandclick-to-copy-plugin.test.mjs: the per-conversion contracts. The markmap cases stub the vendoring companion with a marker to stay offline; the real vendor fetch is covered by the build-time vendoring net.
Acceptance test
plugins-acceptance.test.mjs proves adoption end to end: a
project site drops assets/js/plugins/hello.js plus one registry entry and gets
its script loaded, with zero layout overrides asserted structurally (the fixture
contains no layouts/ directory).
Build-time vendoring
The MarkMap vendoring net in the tests/visual/ directory uses
real build-time CDN fetches, without a browser. It compares bilingual MarkMap
builds with single-version controls to verify each language’s published
autoloader bytes; distinct URLs alone cannot prove correct resource-cache
behavior.
Runtime nets
Two browser nets under tests/visual/:
js-runtime.test.mjsloads representative fixture pages in a real browser and asserts that no uncaught exception or in-scope console error fires, alongside behavior probes (search, diagrams, navbar, copy button, tab persistence). Markup and visual goldens can’t see JS runtime breakage (a missing global, a botched conversion); this net can (#1436).- Two fixture variants cover both search bundles: the main bundle
(
scripts/main-bundle.html) concatenatesoffline-search.jsorsearch.jsintomain.js, never both. - Pages load their real CDN script dependencies, so the net needs network access. The console tally filters off-origin and non-code resource noise but keeps same-origin script and stylesheet load failures (a broken first-party bundle is a defect). Filtered breakage that throws (a dependent script’s missing global) still surfaces as a page error; silent feature degradation is what the behavior probes catch.
- Two fixture variants cover both search bundles: the main bundle
(
plugins-runtime.test.mjsproves an emitted plugin actually executes: its DOM effects land. A static-markup check can bless output whose runtime is broken (a botched build); this net can’t.
Red-proof rationale
A net that passes for the wrong reason (building nothing, matching an empty region) is worse than a red one: it hides breakage behind green. The nets were built red-first, and where a no-op could masquerade as success, a persistent safeguard proves the signal:
- Zero-output cases are asserted against: a golden’s script region must be non-empty.
- The plugin runtime net’s red-proof doubles as an assertion: a deliberately broken plugin must be the error tally’s only entry, so an empty tally from the healthy plugin is meaningful.
- The site runtime net carries a collector self-test: a page that deliberately throws and drops a same-origin script must have both reported, so a silent collector (wrong event names, races, a broken filter) can’t masquerade as all-green.