Skip to content

src/test/ — the test suite

The test suite: seventeen suites in three execution contexts behind npm test, the fixtures and generated goldens, and the fast plain-Mocha loop.

Seventeen suites, three execution contexts, one command: npm test. The runner is @vscode/test-cli driving Mocha's tdd interface (suite / test) over the plain tsc output in out/test/, configured by .vscode-test.mjs at the repository root. npm run pretest compiles that output, builds the six esbuild bundles and runs eslint first, so a green npm test means the tests, the types, the lint gate and the shipped artifacts all agree.

File Runs in Covers
core.test.ts plain Node The three configuration layers, pyJsonDump parity, the YAML/TOML/JSON front-matter parsers, line surgery, the shared primitives, the page-index cache and the SEO metrics.
fields.test.ts plain Node All 18 field types, the ten when operators, field-group inlining, required-field validation, SEO limit derivation, processFields, placeholders and slugs.
governance.test.ts plain Node The brand guard, the draft queue, the ledger, every publish gate in isolation and in order, the .cms/ contract, and the read-only preview.
golden.test.ts plain Node Cross-lane byte contracts against fixtures written by Python.
loop.test.ts plain Node The feedback loop: the analytics join and its read-surface boundary, the portfolio, and media coverage.
fleet.test.ts plain Node The Fleet console's pure half: the verbatim irony-works manifest (wrapped summary whole), a malformed manifest coercing without throwing, the blocker order in both modes, the repo-scoped-only surface guard, and every request the client makes landing in the declared plan — with a fetch that records and answers.
engines.test.ts plain Node The engines seam: exactly one importer, no re-export through the barrel, dist/mcp-server.js holding only the core libraries and never the package (skipped without a build), the adapters, and parity against real sister-repository workflows and manifests.
routes.test.ts plain Node The route registry: the tabs' ids are a subset of the routes, in the same relative order.
webview.test.ts plain Node, over a mini-DOM Every route renders an empty state, the operator primitives keep their promises, field widgets mount and dispose without leaking, and an unread run list renders as unknown — and the studio webviews' host-side transport (PLAN G10): the token reaches the configured platform only, a path that could leave the API is refused before a socket, a live-site change asks every time, and the page's CSP has no connection and no inline code.
styling.test.ts plain Node The styling gate: only media/tokens.css may name a VS Code theme variable — in src/, media/ and the web/packages/ the studio bundle is built from.
platform.test.ts plain Node The seven profiles and the zer0-mistakes overlay, detection over the fixture sites, a site's own configuration, and the Jekyll golden.
audit.test.ts plain Node The thirteen front-matter rule ids, the parser's warnings channel, schema ingestion from sister sites' own files, and the fix-it that never writes.
harness.test.ts plain Node One harness vocabulary over verbatim copies of four sibling repositories' agents, skills, workflows and AI configuration: the inventory, the joins and the profile.
lanes.test.ts plain Node Lane generation: drift against the hub's reusable ai-lane.yml, and the rendered files against the golden/lanes/ fixtures.
mcp.test.ts child process Spawns the bundled dist/mcp-server.js over stdio with a scrubbed environment.
extension.test.ts extension host Activation, the contributed commands, the context keys, and the fixture workspace's live settings — plus, by launching a second editor with no folder (the bundle's Contents/MacOS/Electron on macOS, process.execPath elsewhere), that activation survives a folderless window; and the studio in the webviews once a platform is configured: the panels the commands open, the open file the page view is told, and the token reaching the platform from SecretStorage and nowhere else.
multiroot.test.ts extension host, its own multiroot entry The two-folder window: per-site stores, the active-site rule, per-site MCP servers. See below.

The two rules every test here obeys

Zero network. Nothing in the suite resolves a hostname. The buildPreview test proves it positively rather than by convention: it installs a fetch that throws, runs the preview, and asserts the counter it increments is still zero.

Zero writes outside os.tmpdir() and the fixture workspace. Tests that write create a fresh fs.mkdtempSync directory and remove it in a finally. The fixture workspace itself is read-only from the suite's side — governance.test.ts snapshots every file under src/test/fixtures/workspace/ before and after buildPreview and asserts the two trees are byte-identical, so a regression that started writing during a preview would fail here rather than in somebody's repository.

fixtures/workspace/ — a small, realistic site

.vscode-test.mjs opens this directory as the workspace folder, so it is both the input to the pure-Node tests and the live workspace the extension-host tests activate against.

zer0.json declares two content folders (pages/_posts/corp, pages/_posts/tech) and two content types. The post type exercises every one of the 18 field types — fields.test.ts asserts that, so adding a type without adding a fixture field fails the suite rather than going untested. .vscode/settings.json sets zer0Cms.governance.publishAllow to false while zer0.json sets it to true: the layers disagree on purpose, and the merge that collapsed them would fail loudly.

fleet.manifest.yml is bamr87/irony-works's manifest, copied verbatim: a fleet/v1 document with a wrapped summary:, an ungated event lane and a gated scheduled-plus-dispatch lane. It is the input to fleet.test.ts and, with zer0Cms.fleet.enabled off by default, inert for the extension-host tests.

Seven markdown files cover the shapes the parser has to survive: YAML front matter, TOML (+++), Hugo-style JSON (a bare object), a file dense with comments and blank lines that pins the byte-preservation property of line surgery, a draft, and a README.md with no front matter at all that must be skipped and remembered rather than re-read.

.zer0/drafts/ is the queue: a README.md with no front matter that listQueue must skip, a pending draft whose source is already in the ledger (so a publish is skipped rather than duplicated), and an approved one that is not. .zer0/ledger.json carries a _meta block, one real share, and one half-written entry with no urn — the two rows shareEntries has to filter. .cms/index/ holds a six-record content index and its summary, spanning fresh/aging/stale, health 40/82/88/90/93/95, one draft and one structural page.

The other fixture trees

fixtures/audit/ is a site for the audit suite — 23 posts shaped for the rules, plus the real front-matter schemas of it-journey and zer0-mistakes under schemas/. fixtures/fleet/ holds verbatim copies of sister repositories' workflows and manifests for the engines and fleet suites. fixtures/harness/ holds verbatim agents, skills, workflows and AI configuration from four sibling repositories, with provenance in FIXTURE-SOURCES.md. fixtures/sites/ is six small sites, one per platform idiom: Astro, Docusaurus, Hugo, a Jekyll site on the zer0-mistakes theme, MkDocs and Wiki.js. fixtures/multi/ and fixtures/multi.code-workspace are the two-folder window multiroot.test.ts opens.

fixtures/golden/ — generated, never hand-edited

ledger.json and the worklist pair were written by Python, and the TypeScript core has to reproduce those bytes exactly — that is what makes them prove lane compatibility rather than self-consistency. The three subdirectories are generated by Node instead, each by its own generate.mjs: engines/ pins the engines' output (with an ENGINES_VERSION sidecar), lanes/ the rendered lane files (with LANES_VERSION), and platform/ the pre-profile Jekyll projection.

ledger.json is json.dumps(indent=2, sort_keys=True, ensure_ascii=True) plus a trailing newline; its café-métier URL pins the escaping and the code-point key ordering in one object. worklist.md and worklist-inputs.json come from the real catering.build / catering.render and are inherited verbatim from BASH-CMS — eleven records and seven performance rows chosen to hit every lane boundary: health exactly 70, health -1, a draft, a structural page and a stale page with engagements.

Regenerate with generate.py, from that directory:

python3 generate.py                          # ledger.json (stdlib only)
python3 generate.py /path/to/bashconsultants  # + the worklist pair, from the real lane

When a golden test fails, the fix is either a real bug in our serializer or a re-run of generate.py against a changed Python lane. Decide which. Never edit a golden to match a change made here — the moment you do, the file stops proving anything.

Running a subset

npm test runs everything. During development the fourteen pure-Node suites also run under plain Mocha, which is much faster and needs no VS Code download (Node >= 22.12, for the engines seam):

npx tsc -p . --outDir out
npx mocha --ui tdd out/test/{core,fields,governance,golden,loop,fleet,engines,routes,webview,styling,platform,audit,harness,lanes}.test.js

extension.test.ts and multiroot.test.ts need the extension host and mcp.test.ts needs dist/mcp-server.js, so none of the three is in that list. On a headless Linux box npm test shells out to xvfb-run for you (see test-runner.js); set ZER0_CMS_NO_XVFB=1 to force the plain path.

The multi-root suite

src/test/multiroot.test.ts runs under its own defineConfig entry in .vscode-test.mjs, against src/test/fixtures/multi.code-workspace — two folders, one Jekyll and one MkDocs, one configured through a folder-scoped setting and the other through its own zer0.json. Run it with npx vscode-test --label multiroot.

It declares its own precondition and skips itself in a window with fewer than two folders, which is why the single-root run reports it as pending rather than failing: @vscode/test-cli hands files straight to glob, and glob does not honour a ! negation, so the first entry's pattern matches this file too.

What it pins: two stores with distinct cache keys, each reading its own zer0.json; that the registry watches but scans nothing at activation; that the active site follows the active editor until a person picks one, and then stops; that a file-targeted command resolves its own site from a Uri, an absolute path, or falls back to the active site for a relative one; that the MCP provider offers one server per configured site with distinct working directories; that a folder-scoped publishAllow arms only its own server; and that a store whose resolver reports no folder installs zero watchers.