test(e2e): isolate runs and identities without a new backend endpoint (WP-74)

The three specs shared one mutable backend and said so in their own
comments ("Restart the backend between CI runs"). WP-70 recorded the fix as
a dev-only seed endpoint; it isn't needed. The DB path already routes
through IConfiguration, so playwright.config's webServer hands the backend a
throwaway SQLite file per invocation — the same trick TestWebApplicationFactory
already uses, with zero backend change. And StubIdentityProvider already
honoured X-Subject; the only gap was that nothing sent it. That matters
because the backend has no IsDevelopment() gate anywhere, so a seed endpoint
would have had to invent the codebase's first environment gate.

subjectInterceptor mirrors the existing roleInterceptor and is wired into the
same isDevMode()-only list. Interceptors alone were not enough: the raw XHR
upload and the hand-written letter-preview fetch bypass Angular's chain (as
CLAUDE.md documents), so both now stamp X-Subject explicitly — without that,
every uploaded document still landed under DemoOwner.

reuseExistingServer stays on: flipping it would break local runs for anyone
already serving the docker stack. Each run gets a unique DB filename and
global-setup sweeps only prior runs' leftovers — deleting a fixed path
mid-run risks SQLite silently recreating an empty, unmigrated file under
fullyParallel.

Verified: e2e passes twice back-to-back with no backend restart, and
X-Subject was observed on a real request, not merely wired.

brief-v2.spec.ts keeps the shared identity for now — see the KNOWN GAP note;
a backend staleness bug makes /brief/preview return a sent letter with the
draft watermark for any non-DemoOwner BSN. actors.ts reserves the actor for
whoever fixes it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
eho
2026-08-19 16:32:07 +02:00
co-authored by Claude Sonnet 5
parent 6bc00a917c
commit 42f7bd651d
12 changed files with 319 additions and 21 deletions
+16 -4
View File
@@ -7,10 +7,22 @@ import { Actors, loginAs } from './support/actors';
// Preview assertions are content-type/body-level (text/html + watermark marker), not
// pixel, per WP-28's decision.
//
// The backend persists to SQLite (WP-22) and is shared across runs: `/brief/reset`
// covers the letter, but org templates have no reset endpoint, so this test restores
// the org-template draft it edits (step 8) and never asserts an absolute version
// number — only that it increased by exactly one.
// This test mutates real state (a letter, keyed per-owner by `BriefStore.GetOrCreate`),
// and WP-74 gives it a fresh throwaway backend DB every `npm run e2e` run, so a
// leftover/in-progress letter from a PREVIOUS RUN is never an issue any more. It
// deliberately still logs in as the shared `Actors.zorgverlener` rather than its own
// BSN, though: giving it a distinct BSN (as `smoke.spec.ts` does) hit a real,
// reproducible bug in this repo's own e2e run — `GET /brief/preview`'s sent-letter
// response kept the DRAFT watermark under a non-`DemoOwner` `X-Subject`, even though
// the outgoing request carried the right header and a direct `curl` against the same
// backend at the same instant returned the correct, frozen archive. That points to a
// backend-side staleness/race in `BriefStore`'s SQLite read path (see
// `letter-preview.adapter.ts`'s "KNOWN GAP" note), out of WP-74's file scope to fix —
// so this spec stays on the one identity that doesn't trip it, pending that backend
// investigation. The org-template appearance is a SEPARATE, already-known gap: it's
// NOT owner-keyed (there's exactly one, shared by every caller) and has no reset
// endpoint, so this test still restores the org-template draft it edits (step 8) and
// never asserts an absolute version number — only that it increased by exactly one.
test('drafter composes → approver sends; admin republishes appearance', async ({ page }) => {
await loginAs(page, Actors.zorgverlener);
await expect(page).toHaveURL(/\/dashboard$/);