diff --git a/frontend/src/routes/documents/page.svelte.test.ts b/frontend/src/routes/documents/page.svelte.test.ts index 4b285f77..5731ea18 100644 --- a/frontend/src/routes/documents/page.svelte.test.ts +++ b/frontend/src/routes/documents/page.svelte.test.ts @@ -30,7 +30,10 @@ vi.mock('$app/state', () => ({ const { default: DocumentsListPage } = await import('./+page.svelte'); const { bulkSelectionStore } = await import('$lib/document/bulkSelection.svelte'); -afterEach(cleanup); +afterEach(() => { + cleanup(); + bulkSelectionStore.clear(); +}); const baseData = (overrides: Record = {}) => ({ items: [] as { id: string; title: string }[], @@ -128,7 +131,6 @@ describe('documents/+ page', () => { it('displays the no-results state when items is empty (via DocumentList)', async () => { render(DocumentsListPage, { props: { data: baseData({ items: [], totalElements: 0 }) } }); - // DocumentList renders the empty placeholder expect(document.body.textContent).toMatch(/keine|noch|empty/i); }); @@ -174,38 +176,44 @@ describe('documents/+ page', () => { expect(input?.value).toBe('kurrent'); }); - it('renders without throwing when from/to date filters are preselected', async () => { - expect(() => - render(DocumentsListPage, { - props: { data: baseData({ from: '1899-01-01', to: '1950-12-31' }) } - }) - ).not.toThrow(); + it('opens the advanced-filter section when from/to date filters are preselected', async () => { + render(DocumentsListPage, { + props: { data: baseData({ from: '1899-01-01', to: '1950-12-31' }) } + }); + + // hasAdvancedFilters() returns true when from/to is set, which forces showAdvanced=true onMount, + // revealing the advanced filter section. The "Von" / "Bis" date labels are part of it. + await expect.element(page.getByText('Von')).toBeVisible(); + await expect.element(page.getByText('Bis')).toBeVisible(); }); - it('renders without throwing when tag filters are preselected', async () => { - expect(() => - render(DocumentsListPage, { - props: { data: baseData({ tags: ['Kurrent', 'Familie'] }) } - }) - ).not.toThrow(); + it('opens the advanced-filter section when tag filters are preselected', async () => { + render(DocumentsListPage, { + props: { data: baseData({ tags: ['Kurrent', 'Familie'] }) } + }); + + // Tag filter pills are part of the advanced filter section. + await expect.element(page.getByText('Schlagworte')).toBeVisible(); }); - it('renders without throwing when sender/receiver filters are set', async () => { - expect(() => - render(DocumentsListPage, { - props: { - data: baseData({ - senderId: 'p-1', - initialSenderName: 'Anna Schmidt', - receiverId: 'p-2', - initialReceiverName: 'Bert Meier' - }) - } - }) - ).not.toThrow(); + it('opens the advanced-filter section when sender/receiver filters are set', async () => { + render(DocumentsListPage, { + props: { + data: baseData({ + senderId: 'p-1', + initialSenderName: 'Anna Schmidt', + receiverId: 'p-2', + initialReceiverName: 'Bert Meier' + }) + } + }); + + // PersonTypeahead's combobox input is labelled by the "Absender" / "Empfänger"