diff --git a/CLAUDE.md b/CLAUDE.md index 3cab993..6ed861e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -151,13 +151,15 @@ After any edit to it: ```sh npx tsc -p . node tests/page-smoke.js +node --test tests/page-unit.js ``` The first type-checks `web/src` (loosely: `strict` is off, and `$` returns `any`). The second builds the page as shipped and runs its script against a stub DOM, checking every selector it wires at load actually exists. That check exists because a patch once anchored on a deleted function, `String.replace` silently matched nothing, and the whole UI died with a -`ReferenceError` while every server-side test passed. +`ReferenceError` while every server-side test passed. The third loads the same built script and +calls its helpers directly (#234): a pure function added to the page gets its check there. Patching that file by guessing an anchor string has failed repeatedly. Read the exact block first (`sed -n 'START,ENDp'`), match it verbatim, and assert the replacement happened rather than hoping. @@ -168,6 +170,7 @@ Patching that file by guessing an anchor string has failed repeatedly. Read the cargo test # ~80 tests: parsing, filters, retention, schedules, SQL, per-user state npx tsc -p . # type-checks web/src node tests/page-smoke.js +node --test tests/page-unit.js # the page's own functions, called directly, in a second node tests/native-bridge.js # the page hands playback to a native shell node tests/contrast.js # every theme's palette against WCAG AA npx playwright test # 66 browser tests against a real daemon on fixture feeds diff --git a/tests/page-unit.js b/tests/page-unit.js new file mode 100644 index 0000000..4d9b393 --- /dev/null +++ b/tests/page-unit.js @@ -0,0 +1,132 @@ +// Unit tests for the page's own functions (#234): the script as shipped, loaded into the stub DOM +// page-smoke.js uses, and its helpers called directly. The browser suite tests what people do; +// this tests the small pieces it is made of, in a second, with nothing running. +// +// node --test tests/page-unit.js +// +// The files in web/src are one script, not modules. Its top-level `function`s are properties of +// the context; its top-level `const`s are not, but a script run in the same context sees them, as +// a second