bdd.mdx previously banned "Given/When/Then ceremony" outright, which
directly contradicted WP-70's own acceptance tests (Acceptance/
BesluitLifecycleTests.cs already used // Given/When/Then comments) and
the backend's organically-evolved PascalCase_snake_sentence convention,
which the doc gave zero guidance for. Reverses that rule: every test is
now structured Given -> When -> Then, with a genuinely empty phase
omitted rather than faked; present-tense declarative naming and the
one-behaviour-per-test rule are unchanged. ADR-0006 gets a cross-reference
so both documents agree everywhere, not just in acceptance tests.
Also closes out the doc's other named-but-unenforced rules found by the
audit: fixes the 5 files asserting rendered $localize copy instead of
the underlying tag/message-id (the compliant pattern already existed in
werkvoorraad-item-view.spec.ts), splits the multi-behaviour titles the
doc itself calls a smell (";", "and", "/"), and fixes bdd.mdx's own false
citation of registratie-wizard.machine.spec.ts as "one transition per
test" by actually splitting that test into one-transition-per-test.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
76 lines
3.1 KiB
TypeScript
76 lines
3.1 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { statusLabel, detailRows, TYPE_LABELS } from './beoordeling-view';
|
|
import { BeoordelingView } from './beoordeling';
|
|
|
|
const base: Omit<BeoordelingView, 'status'> = {
|
|
id: '1',
|
|
type: 'herregistratie',
|
|
owner: '*****2333',
|
|
submittedAt: '2024-05-12',
|
|
documenten: [],
|
|
canBesluiten: true,
|
|
};
|
|
|
|
describe('statusLabel', () => {
|
|
it('labels every tag distinctly', () => {
|
|
const labels = [
|
|
statusLabel({ tag: 'Ingediend', referentie: 'R1' }),
|
|
statusLabel({ tag: 'InBehandeling', referentie: 'R1', manual: false }),
|
|
statusLabel({ tag: 'InBehandeling', referentie: 'R1', manual: true }),
|
|
statusLabel({ tag: 'MeerInfoGevraagd', referentie: 'R1', reden: 'x' }),
|
|
statusLabel({ tag: 'Goedgekeurd', referentie: 'R1' }),
|
|
statusLabel({ tag: 'Afgewezen', referentie: 'R1', reden: 'x' }),
|
|
];
|
|
expect(new Set(labels).size).toBe(labels.length);
|
|
});
|
|
});
|
|
|
|
describe('detailRows', () => {
|
|
it('lists soort/status/referentie/eigenaar/ingediend', () => {
|
|
// Given a case InBehandeling.
|
|
// When its detail rows are derived...
|
|
const rows = detailRows({
|
|
...base,
|
|
status: { tag: 'InBehandeling', referentie: 'R1', manual: false },
|
|
});
|
|
const values = rows.map((r) => r.value);
|
|
|
|
// Then the type label (via TYPE_LABELS, not a literal), the reference, and the
|
|
// owner all appear as rows.
|
|
expect(values).toContain(TYPE_LABELS.herregistratie);
|
|
expect(values).toContain('R1');
|
|
expect(values).toContain(base.owner);
|
|
expect(rows.length).toBe(5);
|
|
});
|
|
|
|
// One behaviour ("a reden row is added exactly for the two statuses that carry a
|
|
// reden") checked as a truth table over three statuses — kept together per
|
|
// bdd.mdx's "truth-table of one rule" exception, rather than split apart.
|
|
//
|
|
// `reden` itself is raw domain data (a free-text field on the status union, not an
|
|
// enum), passed through `detailRows` unchanged and never wrapped by `$localize` —
|
|
// there is no reason-code/tag to assert on instead; the value under test IS the
|
|
// string the Given supplied, so checking it reappears in the Then is a
|
|
// pass-through check, not a translated-copy assertion.
|
|
it('a reden row is present only for Afgewezen and MeerInfoGevraagd', () => {
|
|
// Given three cases: rejected, more-info-requested, and approved.
|
|
// When their detail rows are derived...
|
|
const afgewezen = detailRows({
|
|
...base,
|
|
status: { tag: 'Afgewezen', referentie: 'R1', reden: 'Onvoldoende uren' },
|
|
});
|
|
const meerInfo = detailRows({
|
|
...base,
|
|
status: { tag: 'MeerInfoGevraagd', referentie: 'R1', reden: 'Diploma ontbreekt' },
|
|
});
|
|
const goedgekeurd = detailRows({ ...base, status: { tag: 'Goedgekeurd', referentie: 'R1' } });
|
|
|
|
// Then only the rejected and more-info-requested cases gain a reden row (carrying
|
|
// the reason through unchanged); the approved case does not.
|
|
expect(afgewezen.length).toBe(6);
|
|
expect(afgewezen.map((r) => r.value)).toContain('Onvoldoende uren');
|
|
expect(meerInfo.length).toBe(6);
|
|
expect(goedgekeurd.length).toBe(5);
|
|
});
|
|
});
|