test(briefwechsel): makePerson factory + per-row tile assertion

Consolidates the hansPerson / annaPerson fixture into a makePerson()
factory matching the makeDoc convention, adds an assertion that
the bilateral list renders one ConversationThumbnail tile per
document (catches a broken {#each} keying wired around the
DistributionBar), and decouples the DistributionBar aria-label
assertion from the German locale now that i18n lands via Paraglide.

Refs #305
Fixes @saraholt concerns 3 + 4 from PR review

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-23 20:34:00 +02:00
parent 0a3e5d6260
commit 3b83141ddf

View File

@@ -30,20 +30,22 @@ const withPersons = {
filters: { ...baseData.filters, senderId: 'p1', receiverId: 'p2' }
};
const hansPerson = {
const makePerson = (overrides: Record<string, unknown> = {}) => ({
id: 'p1',
firstName: 'Hans',
lastName: 'Müller',
personType: 'PERSON' as const,
displayName: 'Hans Müller'
};
const annaPerson = {
displayName: 'Hans Müller',
...overrides
});
const hansPerson = makePerson();
const annaPerson = makePerson({
id: 'p2',
firstName: 'Anna',
lastName: 'Schmidt',
personType: 'PERSON' as const,
displayName: 'Anna Schmidt'
};
});
const makeDoc = (overrides: Record<string, unknown> = {}) => ({
id: 'd1',
@@ -54,8 +56,15 @@ const makeDoc = (overrides: Record<string, unknown> = {}) => ({
location: 'Berlin',
metadataComplete: false,
scriptType: 'UNKNOWN' as const,
sender: hansPerson,
receivers: [annaPerson],
sender: makePerson(),
receivers: [
makePerson({
id: 'p2',
firstName: 'Anna',
lastName: 'Schmidt',
displayName: 'Anna Schmidt'
})
],
tags: [],
transcription: undefined,
filePath: undefined,
@@ -229,17 +238,33 @@ describe('Briefwechsel page distribution bar', () => {
]
};
render(Page, { data });
const bar = document.querySelector('[role="img"][aria-label*="Briefverteilung"]');
const bar = document.querySelector('[role="img"]');
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');
const label = bar!.getAttribute('aria-label') ?? '';
expect(label).toContain('Hans Müller');
expect(label).toContain('Anna Schmidt');
expect(label).toMatch(/\b1\b/);
expect(label).toMatch(/\b2\b/);
});
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"]');
const bar = document.querySelector('[role="img"]');
expect(bar).toBeNull();
});
it('renders a ConversationThumbnail tile for each document in the list', async () => {
// A broken `{#each}` wiring in ConversationTimeline would silently stop
// rendering rows while the DistributionBar above it kept working. Assert
// the per-row tile so that class of regression is caught.
const data = {
...withPersons,
documents: [makeDoc({ id: 'd-a' }), makeDoc({ id: 'd-b' }), makeDoc({ id: 'd-c' })]
};
render(Page, { data });
const tiles = document.querySelectorAll('[data-testid="conv-thumb-tile"]');
expect(tiles).toHaveLength(3);
});
});
// ─── Year dividers ────────────────────────────────────────────────────────────