a200832cfb
docs/LETTER.md holds slots as comments only, so the player sees no change
until the author writes. The app bundles the letter at build time, a small
Markdown subset renders without {@html}, only https: and tel: become links,
and lint:copy now reads the letter. Review found turbo replaying a stale
build after the letter changed; docs/LETTER.md is now in its cache key.
61 lines
3.2 KiB
Markdown
61 lines
3.2 KiB
Markdown
# 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.
|
|
|
|
## Fill an empty slot for one run, to test the state it will have later
|
|
|
|
**What happened.** The Letter's e2e test branches: no link while `docs/LETTER.md` is
|
|
empty, and the page opens once it is written. Only the empty branch could run, because
|
|
the author has not written the letter. One run with a temporary sample letter took the
|
|
other branch. It found the stale-cache bug (`technical.md`), and then passed the
|
|
written-letter page, axe included, in a real browser. The scaffold was restored
|
|
afterwards.
|
|
|
|
**Why it bit.** A test written for a future state passes trivially until that state
|
|
arrives. Then it fails for the first time on the author's machine, with the author's words.
|
|
|
|
**How to apply it.** When a test branches on content that does not exist yet, fill the
|
|
content temporarily, run the suite, restore it, and record the run in the review.
|