test(documents): more documents/[id] page coverage with full data shapes

Document with all metadata populated (sender, receivers, tags,
location, scriptType, trainingLabels, geschichten, inferredRelationship,
canBlogWrite, canWrite); URL-driven transcribe mode rendering.

2 new tests covering ~10 branches from prop-driven conditionals.

Refs #496.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-10 06:37:46 +02:00
committed by marcel
parent 96f2b99dec
commit d82ce1a48e

View File

@@ -249,4 +249,54 @@ describe('documents/[id] page', () => {
})
).not.toThrow();
});
it('renders without throwing with all metadata populated', async () => {
mockPage.url = new URL('http://localhost/documents/d-meta');
expect(() =>
render(DocumentDetailPage, {
props: {
data: baseData({
document: {
...baseDoc,
id: 'd-meta',
sender: { id: 's1', displayName: 'Anna' },
receivers: [
{ id: 'r1', displayName: 'Bert' },
{ id: 'r2', displayName: 'Carl' }
],
tags: [
{ id: 't1', name: 'Familie' },
{ id: 't2', name: 'Reise' }
],
location: 'Berlin',
scriptType: 'KURRENT',
trainingLabels: ['KURRENT_RECOGNITION']
},
user: { id: 'u1', firstName: 'Anna' },
geschichten: [{ id: 'g1', title: 'Story', publishedAt: null }],
inferredRelationship: { labelFromA: 'Vater', labelFromB: 'Tochter' },
canBlogWrite: true,
canWrite: true
})
}
})
).not.toThrow();
});
it('renders the transcribe-mode forced via query string', async () => {
mockPage.url = new URL('http://localhost/documents/d-task?task=transcribe');
render(DocumentDetailPage, {
props: {
data: baseData({
document: { ...baseDoc, id: 'd-task' },
canWrite: true
})
}
});
await new Promise((r) => setTimeout(r, 80));
// DocumentTopBar should mount; transcribeMode flag was set by the URL param
const main = document.body.firstElementChild;
expect(main).not.toBeNull();
});
});