test(web): un-skip discover/requests route tests — mock $app (#374)

Root cause: discover.test.ts and requests.test.ts were the only route
page tests NOT mocking $app/state (+ $app/navigation), so rendering
the +page.svelte pulled in SvelteKit's client runtime and threw
`TypeError: notifiable_store is not a function` at module load. They'd
been describe.skip'd AND hard-excluded in vitest.config.ts.

Fix mirrors every other route test: vi.hoisted pageState +
vi.mock('$app/state', () => pageUrlModule(state)) +
vi.mock('$app/navigation', () => ({ goto: vi.fn() })). Un-skip both
describe blocks; drop the vitest.config exclude. The web test job
now runs both suites again.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-19 15:42:11 -04:00
parent 154626ae94
commit bb1ab3a2e3
3 changed files with 23 additions and 24 deletions
+11 -7
View File
@@ -3,6 +3,16 @@ import { render, screen, fireEvent, waitFor } from '@testing-library/svelte';
import { mockQuery } from '../../test-utils/query';
import { apiClientMock } from '../../test-utils/mocks/client';
import type { LidarrSearchResult } from '$lib/api/types';
import { pageUrlModule } from '../../test-utils/mocks/appState';
// $app/state / $app/navigation must be mocked or rendering the page
// pulls in SvelteKit's client runtime (`notifiable_store is not a
// function`) at module load. Same pattern as the other route tests.
const pageState = vi.hoisted(() => ({
pageUrl: new URL('http://localhost/discover')
}));
vi.mock('$app/state', () => pageUrlModule(pageState));
vi.mock('$app/navigation', () => ({ goto: vi.fn() }));
// Lidarr search query factory and createRequest are mocked at the module
// level so each test can shape what the page sees without standing up a
@@ -56,13 +66,7 @@ afterEach(() => {
vi.clearAllMocks();
});
// FIXME(M7 #374): suite errors at module-load with
// `TypeError: notifiable_store is not a function` from SvelteKit's
// internal client.js. Surfaces only on the new dev-push CI; PR-to-main
// runs were green. Probably a vitest module-resolution interaction
// with a recent SvelteKit; needs targeted triage. Skipped to unblock
// CI for #372 — the page itself isn't broken, the test harness is.
describe.skip('Discover page', () => {
describe('Discover page', () => {
test('initial state (no query) shows the suggestion feed', () => {
render(DiscoverPage);
expect(screen.getByText(/suggested for you/i)).toBeInTheDocument();