docs: ADR-0006 test-data builders, close out WP-70
Writes up the principle behind WP-70's three tracks ("build test data
through the same door production code uses") as ADR-0006, with a decision
table for which fixture idiom fits which test type. Updates the
test-strategy skill (adds the Fixtures rule, fixes its stale pre-monorepo
src/app/... worked-example paths) and the shared Storybook testing.mdx page
to match. Closes WP-70 with the signatures/counts as actually shipped.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,13 @@ No `TestBed` for domain. Never assert on user-facing copy.
|
||||
only for wiring axe can't see.
|
||||
- **Never assert on `$localize` copy.** It changes per locale/edit — assert on the
|
||||
`Result`, the value object, or the message id.
|
||||
- **Fixtures go through the production door, never a hand-built literal** (ADR-0006).
|
||||
Replay real `Msg`s through the real `reduce` (`given(reduce, initial)(...msgs)`) for a
|
||||
state machine; `unwrapOk(parseX(raw))` for a value object; a type-state builder
|
||||
(`Given.Concept().Submitted()...`) for a backend aggregate with an ordered lifecycle.
|
||||
The one deliberate exception is a trust-boundary `parse*` spec, below — there the fixture
|
||||
must be a raw, possibly-malformed literal, because the test's whole point is "what if this
|
||||
shape is wrong." See ADR-0006's decision table for which idiom fits which test type.
|
||||
|
||||
## Skeleton
|
||||
|
||||
@@ -54,9 +61,13 @@ describe('parseThing', () => {
|
||||
|
||||
## Worked examples
|
||||
|
||||
- `src/app/registratie/domain/value-objects/postcode.spec.ts` — parser style.
|
||||
- `src/app/registratie/infrastructure/brp.adapter.spec.ts` — trust boundary (`null`/`{}`).
|
||||
- `src/app/registratie/domain/registratie-wizard.machine.spec.ts` — pure reducer.
|
||||
- `apps/ssp/src/app/registratie/domain/value-objects/postcode.spec.ts` — parser style.
|
||||
- `apps/ssp/src/app/registratie/infrastructure/brp.adapter.spec.ts` — trust boundary (`null`/`{}`).
|
||||
- `apps/ssp/src/app/registratie/domain/registratie-wizard.machine.spec.ts` — pure reducer.
|
||||
- `libs/shared/src/testing/{machine,remote-data,value-object}.ts` — the shared fixture
|
||||
helpers (ADR-0006); `apps/ssp/src/app/herregistratie/domain/intake.testing.ts` — a
|
||||
per-context wrapper (`givenIntake = given(reduce, initial)`); `intake.acceptance.spec.ts`
|
||||
— a full journey expressed as one replayed message sequence.
|
||||
|
||||
## Verify
|
||||
|
||||
|
||||
Reference in New Issue
Block a user