diff --git a/log/s016.dj b/log/s016.dj new file mode 100644 index 0000000..defe807 --- /dev/null +++ b/log/s016.dj @@ -0,0 +1,38 @@ +# S016 - Web UI behavior tests + +One isolated place: `app0/web/tests/`. Vitest + happy-dom — no real +browser. + +## Layout + +- `tests/server.ts` - **FakeBff**: the production `linji serve` API + contract in memory (invite gate, bare-name normalization, sessions, + member-only space ACL, push endpoints). EventSource listeners are fed + `update` events when writes land in their space, mirroring the + server's zds watch. +- `tests/setup.ts` - environment wiring: `fetch` -> FakeBff, + EventSource mock fed by the fake, Notification / PushManager / + serviceWorker mocks, `resetEnv()` between tests. +- `tests/app.test.tsx` - 19 tests over the rendered App: login (hint, + invite field visibility, wrong invite, wrong password, bare name), + spaces (empty state, invalid URI, join, non-member denial, thread + expansion), posting (disabled button, post + composer clear, new + thread), SSE live update, open-app notifications (hidden tab fires, + own posts and visible tab don't), the bell (permission + push + subscription registration), logout. + +## Run + +`cd app0/web && bun test` (alias for `bunx vitest run`). ~1.5s. + +## Gotchas found (test-side) + +- Vitest resolves solid-js's `node` export condition (server build, + renders nothing). `vitest.config.ts` aliases `solid-js` and + `solid-js/web` to their browser `dev.js` builds. +- `` keys by reference: a refresh replaces the whole thread + section (new JSON objects), so assertions must re-query elements + after a refresh. +- Seed/mutation state in the fake must be reset between tests + (`resetEnv` restores `inviteCode` too — one leaked mutation hid the + invite field for every later test). diff --git a/roadmap.dj b/roadmap.dj index 9fc6152..8b2d8d0 100644 --- a/roadmap.dj +++ b/roadmap.dj @@ -102,6 +102,8 @@ would be what fails. - **S015** v - SSE updates (`/api/events`, server watches zds as the session user; catches CLI-bot writes) + open-app notifications; closed-app delivery = best-effort. [log](log/s015.dj) +- **S016** v - Web UI behavior tests: Vitest + happy-dom in + `app0/web/tests/` (fake in-memory BFF), 19 tests. [log](log/s016.dj) ## Open questions