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:
@@ -30,20 +30,22 @@ const withPersons = {
|
|||||||
filters: { ...baseData.filters, senderId: 'p1', receiverId: 'p2' }
|
filters: { ...baseData.filters, senderId: 'p1', receiverId: 'p2' }
|
||||||
};
|
};
|
||||||
|
|
||||||
const hansPerson = {
|
const makePerson = (overrides: Record<string, unknown> = {}) => ({
|
||||||
id: 'p1',
|
id: 'p1',
|
||||||
firstName: 'Hans',
|
firstName: 'Hans',
|
||||||
lastName: 'Müller',
|
lastName: 'Müller',
|
||||||
personType: 'PERSON' as const,
|
personType: 'PERSON' as const,
|
||||||
displayName: 'Hans Müller'
|
displayName: 'Hans Müller',
|
||||||
};
|
...overrides
|
||||||
const annaPerson = {
|
});
|
||||||
|
|
||||||
|
const hansPerson = makePerson();
|
||||||
|
const annaPerson = makePerson({
|
||||||
id: 'p2',
|
id: 'p2',
|
||||||
firstName: 'Anna',
|
firstName: 'Anna',
|
||||||
lastName: 'Schmidt',
|
lastName: 'Schmidt',
|
||||||
personType: 'PERSON' as const,
|
|
||||||
displayName: 'Anna Schmidt'
|
displayName: 'Anna Schmidt'
|
||||||
};
|
});
|
||||||
|
|
||||||
const makeDoc = (overrides: Record<string, unknown> = {}) => ({
|
const makeDoc = (overrides: Record<string, unknown> = {}) => ({
|
||||||
id: 'd1',
|
id: 'd1',
|
||||||
@@ -54,8 +56,15 @@ const makeDoc = (overrides: Record<string, unknown> = {}) => ({
|
|||||||
location: 'Berlin',
|
location: 'Berlin',
|
||||||
metadataComplete: false,
|
metadataComplete: false,
|
||||||
scriptType: 'UNKNOWN' as const,
|
scriptType: 'UNKNOWN' as const,
|
||||||
sender: hansPerson,
|
sender: makePerson(),
|
||||||
receivers: [annaPerson],
|
receivers: [
|
||||||
|
makePerson({
|
||||||
|
id: 'p2',
|
||||||
|
firstName: 'Anna',
|
||||||
|
lastName: 'Schmidt',
|
||||||
|
displayName: 'Anna Schmidt'
|
||||||
|
})
|
||||||
|
],
|
||||||
tags: [],
|
tags: [],
|
||||||
transcription: undefined,
|
transcription: undefined,
|
||||||
filePath: undefined,
|
filePath: undefined,
|
||||||
@@ -229,17 +238,33 @@ describe('Briefwechsel page – distribution bar', () => {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
render(Page, { data });
|
render(Page, { data });
|
||||||
const bar = document.querySelector('[role="img"][aria-label*="Briefverteilung"]');
|
const bar = document.querySelector('[role="img"]');
|
||||||
expect(bar).not.toBeNull();
|
expect(bar).not.toBeNull();
|
||||||
expect(bar!.getAttribute('aria-label')).toContain('1 von Hans Müller');
|
const label = bar!.getAttribute('aria-label') ?? '';
|
||||||
expect(bar!.getAttribute('aria-label')).toContain('2 von Anna Schmidt');
|
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 () => {
|
it('does not render the DistributionBar in single-person mode', async () => {
|
||||||
render(Page, { data: { ...withSender, documents: [makeDoc()] } });
|
render(Page, { data: { ...withSender, documents: [makeDoc()] } });
|
||||||
const bar = document.querySelector('[role="img"][aria-label*="Briefverteilung"]');
|
const bar = document.querySelector('[role="img"]');
|
||||||
expect(bar).toBeNull();
|
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 ────────────────────────────────────────────────────────────
|
// ─── Year dividers ────────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user