test(e2e): shared Actors/SeedRefs/loginAs, kill duplicated magic strings (WP-70)

The demo BSN, password, and DigiD login sequence were copy-pasted verbatim
into all three specs; the diploma id #diploma-d1 was coupled to SeedData.cs's
ordering by comment only, with no compile-time check if the seed shape
changed. e2e/support/actors.ts names both: Actors.zorgverlener + loginAs()
for the login sequence, SeedRefs.diplomaZonderPolicyVragen for the seed
coupling (with the "why d1" reasoning attached to the name, not scattered
across specs). Zero assertions changed — pure extract-and-rename of test
setup. e2e test-isolation (the shared mutable backend) is a documented
follow-up, not fixed here — see ADR-0006.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
eho
2026-08-18 15:31:12 +02:00
co-authored by Claude Sonnet 5
parent a73a1c6f1e
commit a7bf228ca8
4 changed files with 58 additions and 13 deletions
+48
View File
@@ -0,0 +1,48 @@
import type { Page } from '@playwright/test';
/**
* A demo identity the fake DigiD login accepts. Auth is faked (CLAUDE.md) — the
* form only ever emits `bsn` on submit, so `wachtwoord` is never actually checked;
* it's filled in anyway because the field is marked required in the UI.
*/
export interface Actor {
readonly bsn: string;
readonly wachtwoord: string;
}
/**
* The demo identities seeded by the backend. Today there is exactly one seeded
* citizen (`backend/src/BigRegister.Api/Data/SeedData.cs`'s `Person`/`Registration`,
* whose BSN also matches `DocumentStore.DemoOwner`) — named for the ROLE it plays
* in a spec, not its BSN, so a spec reads as "log in as the zorgverlener", not
* "log in as 123456782".
*/
export const Actors = {
zorgverlener: { bsn: '123456782', wachtwoord: 'demo' },
} as const satisfies Record<string, Actor>;
/** The shared DigiD-style mock login sequence every e2e spec starts from. */
export async function loginAs(page: Page, actor: Actor): Promise<void> {
await page.goto('/login');
await page.getByLabel('BSN').fill(actor.bsn);
await page.getByLabel('Wachtwoord').fill(actor.wachtwoord);
await page.getByRole('button', { name: 'Inloggen met DigiD' }).click();
}
/**
* Seeded fixtures specs depend on by id, named by
* `backend/src/BigRegister.Api/Data/SeedData.cs`'s seed order — reseeding that
* file in a different order silently breaks these with no compile error, so give
* the raw id a name instead of leaving it a bare literal in each spec.
*/
export const SeedRefs = {
/**
* The first DUO diploma (id "d1": Geneeskunde, Universiteit Leiden, non-English).
* Chosen deliberately, not arbitrarily: it's the one seeded diploma that carries
* zero policy questions, so it drives the wizard down its minimum required path
* — the only required upload is identiteit.
*/
diplomaZonderPolicyVragen: 'd1',
/** The seeded registration's BIG-nummer (`SeedData.Registration`). */
bigNummer: '19012345601',
} as const;