fix(web/test): restore named-mock svelte-query overrides B3 stripped (integrations + requests)
This commit is contained in:
@@ -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<string, unknown>;
|
||||
return { ...actual, useQueryClient: () => ({ invalidateQueries }) };
|
||||
});
|
||||
|
||||
vi.mock('$lib/api/admin', () => ({
|
||||
createLidarrConfigQuery: vi.fn(),
|
||||
createQualityProfilesQuery: vi.fn(),
|
||||
|
||||
@@ -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<string, unknown>;
|
||||
return { ...actual, useQueryClient: () => ({ invalidateQueries }) };
|
||||
});
|
||||
|
||||
vi.mock('$lib/api/requests', () => ({
|
||||
createMyRequestsQuery: vi.fn(),
|
||||
|
||||
Reference in New Issue
Block a user