Files
Rosea/.agents/lessons/testing.md
T
mnovak 6885a217cd [repo] Workspace: Review Phase 0 and record gaps, lessons and handover
Adversarial review with per-package counts and 13 reintroduced bugs, all
caught. Fixes from the review: the trace geocell is capped at 6 characters
(~1 km; 16 allowed centimetres), one forbidden-word hit per place, and an
e2e guard that meta charset stays within the first 1024 bytes.

CLAUDE.md §6.2 no longer contradicts itself about care acts; §2 and §3
say what Phase 0 actually built.
2026-11-01 00:36:06 +01:00

2.3 KiB

Testing

A pipe hides the exit code of the command you are checking

What happened. On 2026-11-01 Phase 0 ran pnpm -s lint 2>&1 | tail -30; echo "exit=$?". It printed one ESLint error and then exit=0. The 0 belonged to tail, not to ESLint.

Why it bit. Anything piped through tail, grep or head reports the last command's status. A gate read that way can be red and look green. This is the same lie as pnpm test exiting 0 having run nothing, one layer further out.

How to apply it. When the exit code matters, redirect to a file and read $? before filtering: cmd > log 2>&1; ec=$?; grep … log; echo "exit=$ec". You can also use ${PIPESTATUS[0]} in bash. Never quote exit=0 from the far end of a pipe.

setOffline tests the harness, not the service worker (imported from Ludus)

What happened. In Ludus, context.setOffline(true) and route().abort() both failed the navigation before the service worker was consulted. So an "offline" test passed or failed for reasons that had nothing to do with the cache.

Why it bit. Both mechanisms act at the browser's network layer, which sits in front of service-worker dispatch.

How to apply it. Prove offline by closing the server: start it, wait for navigator.serviceWorker.controller and for the precache, call server.close(), then navigate. e2e/offline.spec.ts does this, and also fetches from Node to prove the server really is gone. Not re-measured in Rosea. Strike the "imported" mark once someone has.

Put the bug back before you trust the test

What happened. Phase 0 put 13 bugs back one at a time: clientsClaim: false, no navigateFallback, manifest scope /, an inline script, a Google Fonts link, a localStorage write, a hard-coded heading, a UTC localDay, a disabled length cap (checked twice), a lost word boundary, a removed Domi rule, and both git hooks. Every one was caught. The results are recorded in .agents/reviews/feature-phase0-workspace.md.

Why it bit. It didn't, this time. But a guard that has only ever been seen not firing has not been tested. Without the run, a review can only say "I believe".

How to apply it. For every guard a branch adds, apply the inverse change, run the one suite that should catch it, record CAUGHT or MISSED, and restore the file with git checkout. Commit first, so the restore is exact.