diff --git a/frontend/src/routes/documents/[id]/page.svelte.test.ts b/frontend/src/routes/documents/[id]/page.svelte.test.ts index 766be59a..0b1aa471 100644 --- a/frontend/src/routes/documents/[id]/page.svelte.test.ts +++ b/frontend/src/routes/documents/[id]/page.svelte.test.ts @@ -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(); + }); });