test(backend): split RuleTests.cs by aggregate, refresh DDD doc (WP-71)
RuleTests.cs held five aggregates' rules as nested classes in one file, misaligned with Domain/<Aggregate>/ and with the Acceptance/Builders/ folder convention WP-70 started. Split into Domain/<Aggregate>RuleTests.cs (pure move — same names, same bodies, same count) plus a new ApplicationRuleTests.cs (the enum invariant moved out of the WebApplicationFactory-booting ApplicationTests.cs, since it's a pure Enum.GetNames check with no business needing a web host) and OrgTemplateRuleTests.cs (RejectDraft had no direct unit test before, only endpoint coverage). libs/shared/docs/layers.mdx still taught the pre-WP-67 shape (six contexts, no apps/libs split, enforcement via ESLint) — updated to the real monorepo structure and to dependency-cruiser as the actual enforcement mechanism. Adds specs for registration.policy.ts's isStatusConsistent (untested; its backend mirror is) and both apps' auth/domain/session.ts. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { Registration } from './registration';
|
||||
import { isHerregistratieEligible, statusColor } from './registration.policy';
|
||||
import { Registration, RegistrationStatus } from './registration';
|
||||
import { isHerregistratieEligible, isStatusConsistent, statusColor } from './registration.policy';
|
||||
|
||||
const reg = (status: Registration['status']): Registration => ({
|
||||
bigNummer: '19012345601',
|
||||
@@ -38,4 +38,26 @@ describe('registration.policy', () => {
|
||||
expect(statusColor('Doorgehaald')).toContain('rood');
|
||||
expect(statusColor('Geschorst')).toContain('oranje');
|
||||
});
|
||||
|
||||
it('a well-formed status is always consistent', () => {
|
||||
expect(
|
||||
isStatusConsistent(reg({ tag: 'Geregistreerd', herregistratieDatum: '2027-01-01' }).status),
|
||||
).toBe(true);
|
||||
expect(
|
||||
isStatusConsistent(
|
||||
reg({ tag: 'Doorgehaald', doorgehaaldOp: '2024-05-01', reden: 'x' }).status,
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
isStatusConsistent(reg({ tag: 'Geschorst', geschorstTot: '2026-12-31', reden: 'x' }).status),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('a Geregistreerd status without its herregistratieDatum is inconsistent', () => {
|
||||
// The union itself makes this unrepresentable through normal construction (every
|
||||
// Geregistreerd literal must carry a herregistratieDatum) — only reachable here by
|
||||
// bypassing the type system, the way malformed runtime/serialized data could.
|
||||
const malformed = { tag: 'Geregistreerd' } as unknown as RegistrationStatus;
|
||||
expect(isStatusConsistent(malformed)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user