From 47c316e21156f52b6e263f5e77e9f7b3374f2b70 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Fri, 8 May 2026 11:26:19 -0400 Subject: [PATCH] fix(web/test): restore named-mock svelte-query overrides B3 stripped (integrations + requests) --- web/src/routes/admin/integrations/integrations.test.ts | 8 +++++++- web/src/routes/requests/requests.test.ts | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) 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(),