The page's script is TypeScript in web/src, built and minified with swc
- web/src/*.ts: the script that was inline in index.html and login.html, split along its existing sections. Still one scope, concatenated in order, not modules. - web/build.mjs strips the types, puts the script in the page and minifies it with swc; build.rs runs it into OUT_DIR and web.rs include_str!s the result. 137 KB -> 106 KB. - npx tsc -p . type-checks web/src, loosely; the handful of annotations it needed change no behaviour. - The Docker build installs node and swc (npm ci --omit=dev). - Two list requests racing no longer let the older one win, and switching tabs clears the selection it closes, which made a browser test flaky. Closes #23, #24. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
25
CLAUDE.md
25
CLAUDE.md
@@ -61,18 +61,28 @@ the shell running the command and kills the session (exit 144). This has happene
|
||||
|
||||
## Before you touch the page
|
||||
|
||||
`web/index.html` is `include_str!`d into the binary, so **every page change needs a rebuild** before
|
||||
it is visible. It is one file: markup, CSS and script.
|
||||
The page is markup and CSS in `web/index.html` and TypeScript in `web/src/`. `build.rs` runs
|
||||
`web/build.mjs`, which uses swc to strip the types, put the script into the page and minify the
|
||||
whole thing, and the result is `include_str!`d into the binary. So **every page change needs a
|
||||
rebuild** before it is visible, and building needs node and `npm ci` run once.
|
||||
|
||||
The files in `web/src` are not modules. They are one script split up, concatenated in the order
|
||||
`web/build.mjs` lists them, sharing one top-level scope as the single inline script did; a new
|
||||
file goes into that list. Top-level names are kept as they are, because markup calls some by
|
||||
name (`onclick="closeModal()"`) and the browser tests reach others through `page.evaluate`.
|
||||
|
||||
After any edit to it:
|
||||
|
||||
```sh
|
||||
npx tsc -p .
|
||||
node tests/page-smoke.js
|
||||
```
|
||||
|
||||
That loads the script against a stub DOM and checks every selector it wires at load actually
|
||||
exists. It 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.
|
||||
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.
|
||||
|
||||
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.
|
||||
@@ -80,9 +90,10 @@ Patching that file by guessing an anchor string has failed repeatedly. Read the
|
||||
## Tests
|
||||
|
||||
```sh
|
||||
cargo test # ~51 tests: parsing, filters, retention, schedules, SQL, per-user state
|
||||
cargo test # ~80 tests: parsing, filters, retention, schedules, SQL, per-user state
|
||||
npx tsc -p . # type-checks web/src
|
||||
node tests/page-smoke.js
|
||||
npx playwright test # 16 browser tests against a real daemon on fixture feeds
|
||||
npx playwright test # 40 browser tests against a real daemon on fixture feeds
|
||||
```
|
||||
|
||||
Things about the browser suite that have cost time:
|
||||
|
||||
Reference in New Issue
Block a user