Files
atomic-design-poc/apps/ssp/src/app/registratie/domain/registration.policy.spec.ts
T
ehoandClaude Sonnet 5 6fa27d1c53 test: close the remaining FE/BE seams (WP-75)
Three seams WP-71 documented but left unguarded.

Deletes the FE's isHerregistratieEligible and isStatusConsistent — both
uncalled, the first dead by its own doc-comment. Their tests used fixtures
completely disjoint from the backend's (the backend even had an exact-window
boundary case the FE lacked), so the two sides could diverge indefinitely
without failing anything. CLAUDE.md's policy of keeping server-owned rules
as FE "reference impls" is what kept them alive, so it is amended: the FE may
mirror a server-supplied value for instant feedback, never reimplement the
algorithm. registration.policy.ts keeps its three live exports.

check-seam.sh now also guards the Besluit tag list — the C# enum and the TS
BESLUIT_TAGS array are identical ordered name lists with nothing linking
them, and Enum.TryParse fails at request time rather than build time. Anchored
on the full declaration so it avoids the "greps all matches" trap WP-69 hit.

The phone-format divergence turned out to be real, not latent as recorded:
the backend returned 422 for +31612345678 and (06) 12345678, both of which
the FE's own parseTelefoonnummer accepts. A grep check would have compared
the shared ^0\d{9}$ regex and reported all clear — the difference was in
stripping. RejectPhoneChange now strips what the FE strips, pinned by a
contract test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-19 16:32:22 +02:00

39 lines
1.4 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { Registration } from './registration';
import { herregistratieDeadline, statusColor, statusLabel } from './registration.policy';
const reg = (status: Registration['status']): Registration => ({
bigNummer: '19012345601',
naam: 'Test',
beroep: 'Arts',
registratiedatum: '2012-09-01',
geboortedatum: '1985-03-14',
status,
});
describe('registration.policy', () => {
it('statusLabel echoes the tag', () => {
expect(statusLabel('Geregistreerd')).toBe('Geregistreerd');
expect(statusLabel('Doorgehaald')).toBe('Doorgehaald');
expect(statusLabel('Geschorst')).toBe('Geschorst');
});
it('statusColor is total over the union', () => {
expect(statusColor('Geregistreerd')).toContain('groen');
expect(statusColor('Doorgehaald')).toContain('rood');
expect(statusColor('Geschorst')).toContain('oranje');
});
it('herregistratieDeadline is only set for an active registration', () => {
expect(
herregistratieDeadline(reg({ tag: 'Geregistreerd', herregistratieDatum: '2027-01-01' })),
).toEqual(new Date('2027-01-01'));
expect(
herregistratieDeadline(reg({ tag: 'Doorgehaald', doorgehaaldOp: '2024-05-01', reden: 'x' })),
).toBeNull();
expect(
herregistratieDeadline(reg({ tag: 'Geschorst', geschorstTot: '2026-12-31', reden: 'x' })),
).toBeNull();
});
});