refactor: extract toWizardErrors, adopted by all 3 wizards (RD-20)

Each wizard flattened its per-field error record into the shell's
WizardError[] summary with its own copy of the same loop. Extract one
pure helper, wizard-errors.ts, next to naarStapLabel. Add a spec that
covers a flat record, an empty record, skipped undefined/empty-string
values, the idPrefix, and a skipped nested object.

registratie-wizard.machine.ts changes Errors from an interface to a
type alias, because only a type alias gets an implicit index
signature and is assignable to the helper's Record<string, unknown>
parameter. The other two machines already declare their error maps as
type aliases, so this also makes the three consistent.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
eho
2026-09-04 22:00:04 +02:00
co-authored by Claude Sonnet 5
parent a196a380ce
commit 831940f1b9
9 changed files with 239 additions and 24 deletions
+10 -1
View File
@@ -20,7 +20,7 @@ tested where._
Every bullet below is a real test name from the suite — an `it()` title (frontend) or a test
method name (backend), read as a sentence. Nothing here is hand-written prose: this page
**is** the suite, reshaped for a business reader. 532 frontend behaviours across
**is** the suite, reshaped for a business reader. 538 frontend behaviours across
9 contexts; 261 backend behaviours across 42 test
classes.
@@ -973,6 +973,15 @@ classes.
- unwraps a Success value
- is the fallback for every other state
#### toWizardErrors
- flattens a flat record of field errors
- returns an empty list for an empty record
- skips a value that is undefined
- skips a value that is an empty string
- prefixes every id with idPrefix when given
- skips a value that is a nested object, so the caller can flatten it separately
#### upload lifecycle messages
- queued → progress → complete