diff --git a/web/src/routes/admin/integrations/integrations.test.ts b/web/src/routes/admin/integrations/integrations.test.ts index d54ab06f..c7e79622 100644 --- a/web/src/routes/admin/integrations/integrations.test.ts +++ b/web/src/routes/admin/integrations/integrations.test.ts @@ -5,8 +5,14 @@ import type { LidarrConfig } from '$lib/api/types'; import type { CoverProvider, SMTPConfig } from '$lib/api/admin'; // useQueryClient is wrapped so the page can call invalidateQueries() without -// a real QueryClient context. Everything else from svelte-query passes through. +// a real QueryClient context. Per-file mock OVERRIDES the vitest.setup default +// so assertions see this named spy rather than the setup's anonymous fn. const invalidateQueries = vi.fn(); +vi.mock('@tanstack/svelte-query', async (orig) => { + const actual = (await orig()) as Record; + return { ...actual, useQueryClient: () => ({ invalidateQueries }) }; +}); + vi.mock('$lib/api/admin', () => ({ createLidarrConfigQuery: vi.fn(), createQualityProfilesQuery: vi.fn(), diff --git a/web/src/routes/requests/requests.test.ts b/web/src/routes/requests/requests.test.ts index 6bae206e..8d29eb92 100644 --- a/web/src/routes/requests/requests.test.ts +++ b/web/src/routes/requests/requests.test.ts @@ -4,8 +4,13 @@ import { mockQuery } from '../../test-utils/query'; import type { LidarrRequest } from '$lib/api/types'; // Capture invalidateQueries on the mocked QueryClient so the cancel test can -// assert against the same instance the page consumed. +// assert against the same instance the page consumed. Per-file mock OVERRIDES +// the vitest.setup default so assertions see this named spy. const invalidateQueries = vi.fn().mockResolvedValue(undefined); +vi.mock('@tanstack/svelte-query', async (orig) => { + const actual = (await orig()) as Record; + return { ...actual, useQueryClient: () => ({ invalidateQueries }) }; +}); vi.mock('$lib/api/requests', () => ({ createMyRequestsQuery: vi.fn(),