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 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-10 06:36:08 +02:00
committed by marcel
parent 8be1c0e55a
commit 96f2b99dec

View File

@@ -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();
});
});