Repository navigation
test(worker): the test harness on the Worker (WP11) - #71
Conversation
…ker harness (WP11)
…le scripts (WP11)
…arness counts (WP11)
…d when the sources change (WP11 review)
wojciechszyjka
left a comment
There was a problem hiding this comment.
🤖 om-auto-review-pr: review of d4aea77
Verdict: approve on the code, with the browser run still to do. No blockers or majors are left. The owner's own PR, so this is a comment review.
Validation
| Command | Result |
|---|---|
yarn check |
pass (with dist-worker/ removed: check-text does not skip it, as WP08 noted) |
yarn test |
3104 passed, 22 failed in 5 files, each mktemp refused by this session's sandbox (the same 22 WP03 and WP07 recorded) |
node scripts/worker-harness.ts --no-browser |
10 of 14 checks passed, 0 failed, 4 browser checks skipped |
vitest run test/worker/harness.test.ts |
19 of 19 |
Fixed in this review (d4aea77)
- major: a run stopped hard (SIGKILL) left the owner's
.wrangler/stateaside and the harness's copy in its place, and the next run moved the copy over the saved state. Now every copy carries a marker, a stopped run is recovered, and a state that is not the harness's copy is never overwritten (setAside,putBack, 4 tests). - major: the seed was reused after
www/content,www/publicorlib/emdashchanged, so parity would fail on stale D1 rows. The seed marker is now a fingerprint of those sources (sourceFingerprint, 1 test).
Open, not blocking
- minor: the harness leaves
dist-worker/of its last phase (the templates fixture when all phases run). Runyarn build:workerbeforeyarn dev:workerafter a harness run. - minor: when
dist-www/is missing, the static www build runs twice (once for the seed's derivatives, once after the emit). - The browser checks (calculator, e2e, stale, templates) have not run yet: this sandbox refuses to start Chrome, and Playwright 1.64 needs Chromium build 1248. To run on the owner's Mac:
yarn playwright install chromium, thennode scripts/worker-harness.ts --data .data.
CI was pending when this was posted.
…ication rule of WP08 in the harness (WP11)
…s left to WP10 (WP11)
… a local key pair, the outage and the guard config (WP11)
… API before use (WP11 review)
wojciechszyjka
left a comment
There was a problem hiding this comment.
🤖 om-auto-review-pr: re-review of ba39dae
Verdict: approve on the code (the owner's own PR, so a comment review). No blockers or majors. Since the last review: main merged in (WP08, WP10, PR 72, PR 73), WP08's and WP10's checks folded in, a cold concurrent walk added, and a publish phase with a build-time key-source swap.
Validation
| Command | Result |
|---|---|
yarn check |
pass |
yarn test |
3219 passed, 22 failed in 5 files, each mktemp refused by this session's sandbox (unchanged) |
node scripts/worker-harness.ts --no-browser |
15 of 20 passed, 1 failed, 4 not run (browser) |
node scripts/worker-harness.ts --only publish --no-browser at ba39dae |
3 of 3 |
The failed harness line is smoke, and its cause is outside this PR. The HTML cache of WP10 answers a request with emdash-edit-mode from a cached page, without clearing the cookie and with public caching, because src/worker/editorial-cache.ts runs before src/outer-middleware.ts. The check is kept as it is and named in the description for WP10.
Checked in the new code
- The key-source swap touches no source file and only
access-entry.ts's import of./access.ts. Signature, issuer, audience and D1 users stay real. A renamed file would make the hook miss, and admin-d1 would then fail on 403, so it cannot pass silently. test/worker/harness-access.tsandharness-astro.config.tsare reachable only from the harness's own build command.- The outage is always reverted (
outage-endinfinally), and the state it renames is the harness's copy. - The seed recipe is now part of the seed fingerprint, so a seed made the old way is made again.
Fixed in this review (ba39dae)
- minor: the ports of the static www server and the fake purge API are now checked before use, as the Worker's port was.
Open, not blocking
- nit:
harness-astro.config.tshas no unit test of its own. The 35 admin checks through the Access gate exercise it. - The browser part is the one remaining check, run on the owner's Mac after the merge (command and pass line in the description).
WP11 of
docs/specs/2026-11-29-unified-astro-emdash.md(PR 56): the test harness on the Worker.Status: complete, except one check: the browser run on the owner's Mac after the merge (below). Tracking plan: kept outside the repository (AGENTS.md rule 1), in the session notes (runs/wp11/PLAN.md).
One command
It builds the Worker, seeds a local D1 and R2 once with
yarn om emdash-import run(with the derivatives of the static www build), and runs every check againstwrangler dev, one Worker at a time (the Mac's limit). Each phase rebuildsdist-worker/(about 8 s) and starts the Worker on a fresh copy of the seeded state in.wrangler/state. A state already there is moved aside and put back at the end. Options:--only <phase,...>,--port(default 8831),--out(defaultout/worker-harness),--no-browser.matrixindexed(test/worker/matrix-build.ts)noindexPAGES_NOINDEX=1real<data>in the main site's environment, beside a static Run build and a static www build of the same emitAccept: text/html(test/worker/editorial/walk.ts), then Run parity, editorial parity, compare-live, the SEO surface (test/worker/og/seo.ts), the 34 OG cards pixel by pixel (test/worker/harness-og.ts), the www build tests on a mirror of the Worker, the calculator, the e2e suite with its screenshots, then the OG publication rule (test/worker/og/publish.ts: an unpublished entry's card answers 404, it writes and restores)publishsrc/worker/access-entry.tsa key source reading a local key pair (test/worker/harness-astro.config.ts,test/worker/harness-access.ts)test/worker/publish/admin-d1.ts: the guard, the fake purge, the Cron Trigger), the outage of the editorial reads on a new isolate, the tests that the committed config registers the guard (config.test.ts,plugin.test.ts)staletest/e2e/build.tsstale.spec.tstemplatestemplates.spec.tsEvery check prints
okorFAILwith its counts. A difference already owned elsewhere is listed inKNOWN(test/worker/harness.ts) and reported with its owner, so it never hides. The report goes toout/worker-harness/report.txtandreport.json. A check that cannot run printsNOT RUNwith the reason. Exit 0 when every check ran and passed, 1 when one failed, 2 when a build or a Worker did not start, 3 when every check that ran passed but some did not run.What changed
scripts/worker-harness.ts: the command.test/worker/harness.ts: the counts read from each check's output (ok/FAIL lines, the Access summary, run-parity and editorial-parity JSON, vitest and Playwright JSON reports, the compare-live report), the named differences, the report. A script that crashed with no line of its own, and a test file that failed before its tests ran, count as failures.test/worker/harness-og.ts: every card ofdist-www/ogasked of the Worker and compared pixel by pixel (at most 0.1 % of pixels over 16 of 255, the threshold ofog.test.ts).test/worker/harness-mirror.ts: the Worker's answers laid out asdist-www/: every sitemap address, every entry file ofwww/content(drafts too), the files the tests read by name and what each page loads. Only a 200 is written.test/www/*-build.test.ts:WWW_DISTnames the folder they read (defaultdist-www, the Pages path). Six assertions no longer depend on attribute order (the Worker's Preact writes attributes in another order) andpageScriptsalso reads inline module scripts (the Worker inlines the cookie banner's script). Both builds pass: 186 of 186 ondist-www.test/worker/smoke.ts, outside the owned paths (WP01 and WP04 are merged, so it has no other owner; agreed with the coordinator): the harness calls this one smoke check. Its expectations follow main: the home page and the marketing routes from D1 (WP07, PR 66), the OG card route (WP08, PR 70) and 403, never stored, under/_emdashwithout a signed Access assertion (WP09, PR 68). No check was loosened: each changed answer is the behaviour those PRs ship.test/e2e/build.ts,test/e2e/serve.ts,test/design/shots/preview-clock.mjs.gallery-shots.mjsstays on the static build:/_dev/galleryis no route of the Worker build.Evidence (owner's Mac, 30 Nov 2026, head fa450c2, data f57612e)
node scripts/worker-harness.ts --no-browser --data .data(1.0 min with the seed of an earlier run; a first run with the seed is about 4 min):worker harness: 16 of 20 checks passed, 0 failed, 4 not run (exit 3), at fa450c2 with main a023276 (WP08, WP10, PR 72, PR 73, PR 74) merged in. 1.4 min with a seed of an earlier run; a first run with the seed is about 5 min.
/run/_astro/<stylesheet>.csson 4 hosts (WP04 decision 5: one build serves its bundles at/_astro/). Body hashes are reported, not counted (the Worker renders pages anew, as WP07 noted).test/worker/editorial/publish.tsandseed-d1.tswrite through EmDash's REST API without an Access assertion, which WP09 refuses, so the harness no longer runs them: it seeds with EmDash's first load on an empty state and thenyarn om emdash-import(the order WP10 found EmDash needs), and checks publication with WP10'sadmin-d1.ts.The one remaining check: the browser part, for the owner after the merge
This session's sandbox refuses to start Chrome, so the browser checks ran nowhere yet. On the owner's Mac, in a normal terminal:
The first command installs Chromium build 1248, the one Playwright 1.64 asks for (only 1217 is cached on the Mac). The run passes when it exits 0 and its last line reads
worker harness: 20 of 20 checks passed, 0 failed, 0 not run, with these four linesokamong the others:real / calculator:test/www/calculator-browser.test.tson the Worker's/blog-posts/profit-margin-calculator(40%, Add 20 hours 30%, Reset example, the error of a fee of zero, keyboard).real / e2e: every spec oftest/e2eagainst<worker>/run(a11y, demo, install-card, layout, links, mobile, navbar, perf, shots with its screenshots inout/worker-harness/shots).stale / e2e:stale.spec.tson the stale fixture variant.templates / e2e:templates.spec.tson the template fixture variant.Findings for other owners
Cannot perform I/O on behalf of a different requestatpublishedShell. The harness now walks every page at 64 at once on a cold isolate first; 0 errors at this head.feed.xml,/.well-known/*,apple-touch-icon.png, a badge, a module's.mdand.json), where WP03 had every machine file equal. The harness lists them on each run (info:). Worth a look whether the fixtures or the files moved.test/worker/media/live.tsreads.wrangler/stateonly, so the harness has to seed that folder. An env override (or an argument) would let it use its own folder.astro.worker.config.tswould need theOM_DEV_GALLERYroute ofastro.config.ts.Asked of WP01 (package.json is its file)
"dev:worker": "wrangler dev --config dist-worker/server/wrangler.json --persist-to .wrangler/state", + "test:worker": "node scripts/worker-harness.ts", "check": ...and in
test/schema/repo.test.ts, under thedev:workerexpectation:Checks
yarn checkgreen,yarn test3233 passed, 22 failed in 5 files (test/proxy/check-sh,test/receipts/harness,test/receipts/presets-r2,test/rentgen/golden,test/validate/workflow-run):mktempin/var/foldersrefused by this session's sandbox, the same 22 WP03 and WP07 recorded.