From 82e151c42d4e8ef231e70ecf6bba961e67fe1054 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 10 May 2026 05:28:31 +0200 Subject: [PATCH] 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 --- .../routes/documents/[id]/page.svelte.test.ts | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) 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(); + }); });