test(coverage): drive browser tests to 80% on all metrics (#496) #505

Merged
marcel merged 189 commits from feat/issue-496-browser-coverage-tests into main 2026-05-11 21:50:39 +02:00
Showing only changes of commit bc24cb3461 - Show all commits

View File

@@ -91,4 +91,81 @@ describe('documents/[id] page', () => {
const stored = localStorage.getItem('familienarchiv.lastVisited');
expect(stored).toContain('d1');
});
it('uses doc.title as the document title when set', async () => {
mockPage.url = new URL('http://localhost/documents/d1');
render(DocumentDetailPage, { props: { data: baseData() } });
// The browser <title> reflects doc.title when set
await new Promise((r) => setTimeout(r, 30));
expect(document.title).toContain('Brief an Helene');
});
it('falls back to originalFilename when title is empty', async () => {
mockPage.url = new URL('http://localhost/documents/d2');
render(DocumentDetailPage, {
props: {
data: baseData({
document: { ...baseDoc, id: 'd2', title: '', originalFilename: 'fallback.pdf' }
})
}
});
await new Promise((r) => setTimeout(r, 30));
expect(document.title).toContain('fallback.pdf');
});
it('falls back to "Dokument" when title and originalFilename are empty', async () => {
mockPage.url = new URL('http://localhost/documents/d3');
render(DocumentDetailPage, {
props: {
data: baseData({
document: { ...baseDoc, id: 'd3', title: '', originalFilename: '' }
})
}
});
await new Promise((r) => setTimeout(r, 30));
expect(document.title).toContain('Dokument');
});
it('renders without throwing when canWrite is true', async () => {
mockPage.url = new URL('http://localhost/documents/d4');
expect(() =>
render(DocumentDetailPage, { props: { data: baseData({ canWrite: true }) } })
).not.toThrow();
});
it('renders without throwing when geschichten and inferredRelationship are set', async () => {
mockPage.url = new URL('http://localhost/documents/d5');
expect(() =>
render(DocumentDetailPage, {
props: {
data: baseData({
geschichten: [{ id: 'g1', title: 'Story', publishedAt: null }],
inferredRelationship: { label: 'PARENT_OF', from: 'p1', to: 'p2' },
canBlogWrite: true
})
}
})
).not.toThrow();
});
it('renders without throwing when doc.id is empty', async () => {
mockPage.url = new URL('http://localhost/documents/d-empty');
expect(() =>
render(DocumentDetailPage, {
props: { data: baseData({ document: { ...baseDoc, id: '', title: 'No ID' } }) }
})
).not.toThrow();
});
it('renders with task=transcribe in the URL without throwing', async () => {
mockPage.url = new URL('http://localhost/documents/d6?task=transcribe');
expect(() =>
render(DocumentDetailPage, {
props: { data: baseData({ document: { ...baseDoc, id: 'd6' } }) }
})
).not.toThrow();
});
});