test(stammbaum): assert no canonical SPOUSE_OF carries fromYear (#361)

@Sara on PR #693: canonical_fixture_multi_spouse_falls_through_to_displayName
_when_no_fromYear asserts the *fallback* branch of the multi-spouse sort
(NULLS LAST, then displayName). It only exercises the name branch while
every SPOUSE_OF row in the fixture has fromYear=undefined. The day a year
gets backfilled in canonical import, the test would silently start
asserting year-order with no notice.

Add a precondition at the head of the test that fails fast with a clear
maintainer message ("update or split into year-branch / name-branch")
when any canonical SPOUSE_OF row gains a fromYear.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-28 20:41:17 +02:00
parent 6d8655bad1
commit fd624f6ec8

View File

@@ -274,6 +274,22 @@ describe('buildLayout — multi-spouse ordering (#361)', () => {
// displayName for the only multi-spouse person (Albert de Gruyter).
const fixtureNodes = canonicalFixture.nodes as unknown as PersonNodeDTO[];
const fixtureEdges = canonicalFixture.edges as unknown as RelationshipDTO[];
// Precondition: this test asserts the *fallback* branch of the
// multi-spouse sort (fromYear ASC NULLS LAST, displayName ASC), which
// only collapses to alphabetical-by-displayName when every SPOUSE_OF
// row is null on fromYear. The day any canonical row gets a year
// backfilled, this test would silently start asserting year-order;
// fail fast instead so the maintainer either updates the test or
// splits into a year-branch / name-branch pair.
const spouseEdgesWithYear = fixtureEdges.filter(
(e) => e.relationType === 'SPOUSE_OF' && e.fromYear != null
);
expect(
spouseEdgesWithYear,
'Precondition violated: a canonical SPOUSE_OF row now carries fromYear. Update this test (or split into year-branch / name-branch).'
).toHaveLength(0);
const layout = buildLayout(fixtureNodes, fixtureEdges);
const partners = new Map<string, Set<string>>();