test(frontend): replay real messages instead of hand-built state literals (WP-70)

Every machine spec redefined its own throwaway fixture helper (editing1/2/3,
editingWith), hardcoding fields like errors: {} that assert against shapes
the reducer may never actually produce. given(reduce, initial)(...msgs)
(libs/shared/src/testing/machine.ts) replaces them by replaying real Msgs
through the real reduce, so a fixture is provably reachable. Adds the same
idiom for value objects (unwrapOk) and RemoteData (loading/success/failure),
plus intake.acceptance.spec.ts as a worked full-journey example.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
eho
2026-08-18 15:31:06 +02:00
co-authored by Claude Sonnet 5
parent 2eea860efe
commit a73a1c6f1e
12 changed files with 264 additions and 56 deletions
@@ -1,11 +1,11 @@
import { describe, it, expect } from 'vitest';
import { given } from '@shared/testing/machine';
import { ChangeRequestState, reduce, initial } from './change-request.machine';
const editingWith = (telefoon: string): ChangeRequestState => ({
tag: 'Editing',
draft: { telefoon },
errors: {},
});
const givenChangeRequest = given(reduce, initial);
const editingWith = (telefoon: string): ChangeRequestState =>
givenChangeRequest({ tag: 'SetField', key: 'telefoon', value: telefoon });
describe('change-request reduce', () => {
it('SetField updates the draft while editing', () => {