From 96f2b99decf32f790e6b5450f2cb603ae23d6eb9 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 10 May 2026 06:36:08 +0200 Subject: [PATCH] test(routes): add documents page input event handlers + bulk store Adds search input typing, focus/blur events, and rendering with bulkSelectionStore containing items. 3 new tests covering ~6 branches. Refs #496. Co-Authored-By: Claude Sonnet 4.6 --- .../src/routes/documents/page.svelte.test.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/frontend/src/routes/documents/page.svelte.test.ts b/frontend/src/routes/documents/page.svelte.test.ts index 871eb990..ce442bb5 100644 --- a/frontend/src/routes/documents/page.svelte.test.ts +++ b/frontend/src/routes/documents/page.svelte.test.ts @@ -28,6 +28,7 @@ vi.mock('$app/state', () => ({ })); const { default: DocumentsListPage } = await import('./+page.svelte'); +const { bulkSelectionStore } = await import('$lib/document/bulkSelection.svelte'); afterEach(cleanup); @@ -336,4 +337,35 @@ describe('documents/+ page', () => { }) ).not.toThrow(); }); + + it('typing in the search input triggers handleTextSearch callback', async () => { + render(DocumentsListPage, { props: { data: baseData() } }); + + const input = document.querySelector('input[type="text"]') as HTMLInputElement; + if (input) { + input.value = 'kurrent'; + expect(() => input.dispatchEvent(new Event('input', { bubbles: true }))).not.toThrow(); + } + }); + + it('focus and blur on search input toggle qFocused without throwing', async () => { + render(DocumentsListPage, { props: { data: baseData() } }); + + const input = document.querySelector('input[type="text"]') as HTMLInputElement; + if (input) { + expect(() => { + input.dispatchEvent(new Event('focus', { bubbles: true })); + input.dispatchEvent(new Event('blur', { bubbles: true })); + }).not.toThrow(); + } + }); + + it('renders without throwing with the bulk-selection store containing items', async () => { + bulkSelectionStore.toggle('doc-x'); + bulkSelectionStore.toggle('doc-y'); + + expect(() => + render(DocumentsListPage, { props: { data: baseData({ canWrite: true }) } }) + ).not.toThrow(); + }); });