test(briefwechsel): cover DistributionBar and fix Person fixture shape

Adds two new assertions for the extracted DistributionBar — it must
appear in bilateral mode and stay hidden in single-person mode — and
repairs the shared makeDoc fixture: the embedded Person now carries
personType + displayName so the fixture matches the regenerated
Document schema without TypeScript complaints.

Refs #305

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-23 14:49:21 +02:00
committed by marcel
parent df681be626
commit 4b893b4808

View File

@@ -30,6 +30,21 @@ const withPersons = {
filters: { ...baseData.filters, senderId: 'p1', receiverId: 'p2' }
};
const hansPerson = {
id: 'p1',
firstName: 'Hans',
lastName: 'Müller',
personType: 'PERSON' as const,
displayName: 'Hans Müller'
};
const annaPerson = {
id: 'p2',
firstName: 'Anna',
lastName: 'Schmidt',
personType: 'PERSON' as const,
displayName: 'Anna Schmidt'
};
const makeDoc = (overrides: Record<string, unknown> = {}) => ({
id: 'd1',
title: 'Testbrief',
@@ -39,8 +54,8 @@ const makeDoc = (overrides: Record<string, unknown> = {}) => ({
location: 'Berlin',
metadataComplete: false,
scriptType: 'UNKNOWN' as const,
sender: { id: 'p1', firstName: 'Hans', lastName: 'Müller' },
receivers: [{ id: 'p2', firstName: 'Anna', lastName: 'Schmidt' }],
sender: hansPerson,
receivers: [annaPerson],
tags: [],
transcription: undefined,
filePath: undefined,
@@ -201,6 +216,32 @@ describe('Briefwechsel page swap button', () => {
});
});
// ─── Distribution bar (bilateral only) ────────────────────────────────────────
describe('Briefwechsel page distribution bar', () => {
it('renders the DistributionBar when both persons are set and there are documents', async () => {
const data = {
...withPersons,
documents: [
makeDoc({ id: 'out1', sender: hansPerson, receivers: [annaPerson] }),
makeDoc({ id: 'in1', sender: annaPerson, receivers: [hansPerson] }),
makeDoc({ id: 'in2', sender: annaPerson, receivers: [hansPerson] })
]
};
render(Page, { data });
const bar = document.querySelector('[role="img"][aria-label*="Briefverteilung"]');
expect(bar).not.toBeNull();
expect(bar!.getAttribute('aria-label')).toContain('1 von Hans Müller');
expect(bar!.getAttribute('aria-label')).toContain('2 von Anna Schmidt');
});
it('does not render the DistributionBar in single-person mode', async () => {
render(Page, { data: { ...withSender, documents: [makeDoc()] } });
const bar = document.querySelector('[role="img"][aria-label*="Briefverteilung"]');
expect(bar).toBeNull();
});
});
// ─── Year dividers ────────────────────────────────────────────────────────────
describe('Briefwechsel page year dividers', () => {