From c004c3bc6f4fca0652b4d3e114cafca80c15c796 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 23 Apr 2026 14:49:21 +0200 Subject: [PATCH] test(briefwechsel): cover DistributionBar and fix Person fixture shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../routes/briefwechsel/page.svelte.spec.ts | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/frontend/src/routes/briefwechsel/page.svelte.spec.ts b/frontend/src/routes/briefwechsel/page.svelte.spec.ts index 9994ba58..b1973e27 100644 --- a/frontend/src/routes/briefwechsel/page.svelte.spec.ts +++ b/frontend/src/routes/briefwechsel/page.svelte.spec.ts @@ -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 = {}) => ({ id: 'd1', title: 'Testbrief', @@ -39,8 +54,8 @@ const makeDoc = (overrides: Record = {}) => ({ 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', () => {