test(documents): expand documents/[id] page coverage further

Sender/receivers populated, filePath set, full user object,
Escape vs other keys keydown handler, deep-link comment query.

6 new tests targeting ~14 branches.

Refs #496.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-10 05:28:31 +02:00
parent 38e1726c53
commit 82e151c42d

View File

@@ -168,4 +168,85 @@ describe('documents/[id] page', () => {
})
).not.toThrow();
});
it('renders without throwing with sender/receivers populated', async () => {
mockPage.url = new URL('http://localhost/documents/d7');
expect(() =>
render(DocumentDetailPage, {
props: {
data: baseData({
document: {
...baseDoc,
id: 'd7',
sender: { id: 's1', displayName: 'Anna Schmidt' },
receivers: [{ id: 'r1', displayName: 'Bert Meier' }]
}
})
}
})
).not.toThrow();
});
it('renders without throwing when filePath is set on the document', async () => {
mockPage.url = new URL('http://localhost/documents/d8');
expect(() =>
render(DocumentDetailPage, {
props: {
data: baseData({
document: {
...baseDoc,
id: 'd8',
filePath: 's3://bucket/file.pdf',
contentType: 'application/pdf'
}
})
}
})
).not.toThrow();
});
it('renders without throwing with a complete user object', async () => {
mockPage.url = new URL('http://localhost/documents/d9');
expect(() =>
render(DocumentDetailPage, {
props: {
data: baseData({
document: { ...baseDoc, id: 'd9' },
user: { id: 'u1', firstName: 'Anna', lastName: 'S', email: 'a@x' }
})
}
})
).not.toThrow();
});
it('handles Escape keydown without throwing (close transcribe path)', async () => {
mockPage.url = new URL('http://localhost/documents/d10');
render(DocumentDetailPage, {
props: { data: baseData({ document: { ...baseDoc, id: 'd10' } }) }
});
expect(() =>
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))
).not.toThrow();
});
it('handles non-Escape keydown without firing close handler', async () => {
mockPage.url = new URL('http://localhost/documents/d11');
render(DocumentDetailPage, {
props: { data: baseData({ document: { ...baseDoc, id: 'd11' } }) }
});
expect(() =>
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Tab', bubbles: true }))
).not.toThrow();
});
it('renders without throwing with a deep-link comment query param', async () => {
mockPage.url = new URL('http://localhost/documents/d12?comment=c-abc');
expect(() =>
render(DocumentDetailPage, {
props: { data: baseData({ document: { ...baseDoc, id: 'd12' } }) }
})
).not.toThrow();
});
});