From 8ccc9aba1a99c5481aedc3bab8d51ca41f5ae443 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 12 May 2026 16:37:54 +0200 Subject: [PATCH] fix(notification): replace view-all anchor with button to prevent iframe navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SvelteKit's capture-phase link interceptor fires before the component's onclick handler, so e.preventDefault() was structurally too late to stop iframe navigation in vitest-browser. Replacing the with a diff --git a/frontend/src/lib/notification/NotificationDropdown.svelte.test.ts b/frontend/src/lib/notification/NotificationDropdown.svelte.test.ts index e72573be..3c410403 100644 --- a/frontend/src/lib/notification/NotificationDropdown.svelte.test.ts +++ b/frontend/src/lib/notification/NotificationDropdown.svelte.test.ts @@ -6,7 +6,10 @@ import NotificationDropdown from './NotificationDropdown.svelte'; vi.mock('$app/navigation', () => ({ goto: vi.fn() })); -afterEach(cleanup); +afterEach(() => { + cleanup(); + vi.clearAllMocks(); +}); const makeNotification = (overrides: Record = {}) => ({ id: 'n1', @@ -156,7 +159,7 @@ describe('NotificationDropdown', () => { expect(onMarkAllRead).toHaveBeenCalledOnce(); }); - it('calls onClose when the view-all link is clicked', async () => { + it('calls onClose when the view-all button is clicked', async () => { const onClose = vi.fn(); render(NotificationDropdown, { props: { @@ -167,11 +170,23 @@ describe('NotificationDropdown', () => { } }); - const viewAllLink = page.getByRole('link', { name: /alle aktivitäten|view all/i }); - await expect.element(viewAllLink).toHaveAttribute('href', '/aktivitaeten'); - await viewAllLink.click(); + await page.getByRole('button', { name: /alle aktivitäten|view all/i }).click(); expect(onClose).toHaveBeenCalledOnce(); + }); + + it('navigates to /aktivitaeten when the view-all button is clicked', async () => { + render(NotificationDropdown, { + props: { + notifications: [], + onMarkRead: () => {}, + onMarkAllRead: () => {}, + onClose: () => {} + } + }); + + await page.getByRole('button', { name: /alle aktivitäten|view all/i }).click(); + expect(goto).toHaveBeenCalledWith('/aktivitaeten'); });