Checked-in browser smoke test for the UI #14

Open
opened 2026-11-09 23:42:40 +00:00 by eric · 0 comments
Owner

npm test covers only the pure logic (crypto, model, ops, print helpers, build). src/app.js (the whole UI, ~690 lines) has no automated tests. Browser behavior for #10-#13 was verified with throwaway headless-Chromium scripts that were never committed, so a later change can break drop/paste/Cancel/print while npm test still passes.

Goal

A committed smoke test that drives a real browser through the main flows, with no new npm dependencies, that skips itself when no browser is available (like the existing test that skips without data/seed.json).

Approach

  • test/browser.test.js under node --test. Launch Chromium/Chrome headless with --remote-debugging-port, talk to it over the DevTools protocol using Node's global WebSocket (Node >= 22; skip on older) and fetch.
  • Browser path: FW_CHROME env var, else a short list of usual locations (Playwright cache, google-chrome, chromium, Edge). If none is found, skip with a clear message.
  • Build a sealed test file in a temp dir from a small fixture document with a throwaway passphrase (via assemble/encrypt, not data/seed.json). Use a fresh --user-data-dir and a free port; always kill the browser and delete temp files, even on failure.
  • Small shared helper module (test/helpers/cdp.js): launch, evaluate, click-by-text, set-value, wait-for, dialog auto-handling (confirm accept/decline), in-page helpers to make PNG/JPEG Files and fire drop/paste/picker events, and a stub for showSaveFilePicker that captures the saved HTML.
  • Never use real data or the owner's passphrase.

Flows to cover

  1. Unlock: wrong passphrase shows an error; right one opens the document.
  2. Edit a record, add a text field, add an image field via picker, drop and paste (replace and add); a disguised GIF is rejected.
  3. Visual sequence: add in a records, a checklist and a text section; add steps by picker/drop/paste; text position right/under/none; secret step hidden until Show; reorder and delete steps.
  4. Cancel (#11): decline keeps edits; accept reverts, leaves edit mode and clears the badge; added section removed; after Save, Cancel returns to the saved state.
  5. Section delete prompt (#13): text names the section and counts; decline keeps, accept deletes.
  6. Save and reopen: the saved file unlocks, content round-trips, and no image bytes appear outside the encrypted payload.
  7. Upgrade path: open an older file's payload through 'Open your existing Final Wishes file'.
  8. Print: Page.printToPDF after Print (masked and full); assert the PDF text has the running header, numbered steps, [withheld] vs real text (parse text with a tiny built-in check on the PDF or simply assert on the built print DOM before printing; no PDF library dependency).

Acceptance

  • npm test runs it when a browser exists and skips cleanly (reported as skipped) when not.
  • Runs in under about 60 s, leaves no processes or temp files behind, and does not touch data/, dist/ or F:.
  • A deliberately broken UI behavior (e.g. Cancel no longer leaving edit mode) makes it fail.
  • Short note in README / docs/MAINTENANCE.md on how to run it and FW_CHROME.
  • Update OVERVIEW.md, which currently says browser checks are not in the repo.

Out of scope

Firefox/Safari, visual (pixel) comparisons, CI wiring.

Open question

  • The CDP approach needs Node's global WebSocket (Node 22+); package.json says Node >= 20. Either raise the engine for tests only (skip below 22) or add a tiny hand-rolled WebSocket client. Recommend skip below 22.
`npm test` covers only the pure logic (crypto, model, ops, print helpers, build). `src/app.js` (the whole UI, ~690 lines) has no automated tests. Browser behavior for #10-#13 was verified with throwaway headless-Chromium scripts that were never committed, so a later change can break drop/paste/Cancel/print while `npm test` still passes. ## Goal A committed smoke test that drives a real browser through the main flows, with **no new npm dependencies**, that skips itself when no browser is available (like the existing test that skips without `data/seed.json`). ## Approach - `test/browser.test.js` under `node --test`. Launch Chromium/Chrome headless with `--remote-debugging-port`, talk to it over the DevTools protocol using Node's global `WebSocket` (Node >= 22; skip on older) and `fetch`. - Browser path: `FW_CHROME` env var, else a short list of usual locations (Playwright cache, google-chrome, chromium, Edge). If none is found, skip with a clear message. - Build a sealed test file in a temp dir from a small fixture document with a throwaway passphrase (via `assemble`/`encrypt`, not `data/seed.json`). Use a fresh `--user-data-dir` and a free port; always kill the browser and delete temp files, even on failure. - Small shared helper module (`test/helpers/cdp.js`): launch, evaluate, click-by-text, set-value, wait-for, dialog auto-handling (confirm accept/decline), in-page helpers to make PNG/JPEG Files and fire drop/paste/picker events, and a stub for `showSaveFilePicker` that captures the saved HTML. - Never use real data or the owner's passphrase. ## Flows to cover 1. Unlock: wrong passphrase shows an error; right one opens the document. 2. Edit a record, add a text field, add an image field via picker, drop and paste (replace and add); a disguised GIF is rejected. 3. Visual sequence: add in a records, a checklist and a text section; add steps by picker/drop/paste; text position right/under/none; secret step hidden until Show; reorder and delete steps. 4. Cancel (#11): decline keeps edits; accept reverts, leaves edit mode and clears the badge; added section removed; after Save, Cancel returns to the saved state. 5. Section delete prompt (#13): text names the section and counts; decline keeps, accept deletes. 6. Save and reopen: the saved file unlocks, content round-trips, and no image bytes appear outside the encrypted payload. 7. Upgrade path: open an older file's payload through 'Open your existing Final Wishes file'. 8. Print: `Page.printToPDF` after Print (masked and full); assert the PDF text has the running header, numbered steps, `[withheld]` vs real text (parse text with a tiny built-in check on the PDF or simply assert on the built print DOM before printing; no PDF library dependency). ## Acceptance - `npm test` runs it when a browser exists and skips cleanly (reported as skipped) when not. - Runs in under about 60 s, leaves no processes or temp files behind, and does not touch `data/`, `dist/` or `F:`. - A deliberately broken UI behavior (e.g. Cancel no longer leaving edit mode) makes it fail. - Short note in README / docs/MAINTENANCE.md on how to run it and `FW_CHROME`. - Update OVERVIEW.md, which currently says browser checks are not in the repo. ## Out of scope Firefox/Safari, visual (pixel) comparisons, CI wiring. ## Open question - The CDP approach needs Node's global WebSocket (Node 22+); package.json says Node >= 20. Either raise the engine for tests only (skip below 22) or add a tiny hand-rolled WebSocket client. Recommend skip below 22.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: eric/final-wishes#14
No description provided.