diff --git a/web/src/lib/components/MobileNavDrawer.test.ts b/web/src/lib/components/MobileNavDrawer.test.ts index c094d85b..a1e66b48 100644 --- a/web/src/lib/components/MobileNavDrawer.test.ts +++ b/web/src/lib/components/MobileNavDrawer.test.ts @@ -1,5 +1,23 @@ -import { describe, it, expect, beforeEach } from 'vitest'; +import { describe, it, expect, beforeEach, vi } from 'vitest'; import { render, screen } from '@testing-library/svelte'; + +// SvelteKit's $app/state and $app/navigation can't be imported in vitest +// without bootstrapping the runtime; stub them. Mirrors the pattern used +// by Shell.test.ts and other route tests. +vi.mock('$app/state', () => ({ + page: { url: new URL('http://localhost/') } +})); + +vi.mock('$app/navigation', () => ({ + goto: vi.fn() +})); + +// auth/store reads $app — stub the bits MobileNavDrawer touches. +vi.mock('$lib/auth/store.svelte', () => ({ + user: { value: { username: 'alice', is_admin: false } }, + logout: vi.fn().mockResolvedValue(undefined) +})); + import MobileNavDrawer from './MobileNavDrawer.svelte'; import { mobileNav, openMobileNav, closeMobileNav } from '$lib/stores/mobileNav.svelte'; diff --git a/web/src/lib/components/PlayerBar.test.ts b/web/src/lib/components/PlayerBar.test.ts index 859666ca..71c7f5cd 100644 --- a/web/src/lib/components/PlayerBar.test.ts +++ b/web/src/lib/components/PlayerBar.test.ts @@ -105,7 +105,9 @@ describe('PlayerBar', () => { test('play button click calls togglePlay', async () => { render(PlayerBar); - await fireEvent.click(screen.getByRole('button', { name: /play|pause/i })); + // Anchored regex — "Player options" (the new overflow ⋮) also matches + // /play|pause/i otherwise. + await fireEvent.click(screen.getByRole('button', { name: /^(play|pause)$/i })); expect(togglePlay).toHaveBeenCalledTimes(1); }); diff --git a/web/src/lib/components/RowActionsMenu.svelte b/web/src/lib/components/RowActionsMenu.svelte index 68886e2c..281a9a79 100644 --- a/web/src/lib/components/RowActionsMenu.svelte +++ b/web/src/lib/components/RowActionsMenu.svelte @@ -9,6 +9,10 @@ onclick: () => void; danger?: boolean; disabled?: boolean; + /** Override the accessible name (defaults to label). Use to disambiguate + identical labels across rows for screen readers + tests, e.g. + `Approve {row.title}`. */ + ariaLabel?: string; } @@ -46,6 +50,7 @@