diff --git a/tests/app/profile.page.test.tsx b/tests/app/profile.page.test.tsx index 71e2e19..8070a37 100644 --- a/tests/app/profile.page.test.tsx +++ b/tests/app/profile.page.test.tsx @@ -17,6 +17,15 @@ vi.mock('@/lib/hooks/useRequests', () => ({ useRequests: useRequestsMock, })); +vi.mock('@/contexts/PreferencesContext', () => ({ + usePreferences: () => ({ + cardSize: 5, + setCardSize: vi.fn(), + squareCovers: true, + setSquareCovers: vi.fn(), + }), +})); + vi.mock('@/components/layout/Header', () => ({ Header: () =>
, })); diff --git a/tests/components/requests/InteractiveTorrentSearchModal.test.tsx b/tests/components/requests/InteractiveTorrentSearchModal.test.tsx index d169e03..3ac6fd1 100644 --- a/tests/components/requests/InteractiveTorrentSearchModal.test.tsx +++ b/tests/components/requests/InteractiveTorrentSearchModal.test.tsx @@ -17,6 +17,15 @@ const searchEbooksMock = vi.hoisted(() => vi.fn()); const selectEbookMock = vi.hoisted(() => vi.fn()); const searchEbooksByAsinMock = vi.hoisted(() => vi.fn()); const selectEbookByAsinMock = vi.hoisted(() => vi.fn()); +const replaceWithTorrentMock = vi.hoisted(() => vi.fn()); + +vi.mock('@/lib/hooks/useReportedIssues', () => ({ + useReplaceWithTorrent: () => ({ + replaceWithTorrent: replaceWithTorrentMock, + isLoading: false, + error: null, + }), +})); vi.mock('@/lib/hooks/useRequests', () => ({ useInteractiveSearch: () => ({ diff --git a/tests/services/audiobookshelf-api.test.ts b/tests/services/audiobookshelf-api.test.ts index 19d9338..e8af2cb 100644 --- a/tests/services/audiobookshelf-api.test.ts +++ b/tests/services/audiobookshelf-api.test.ts @@ -275,9 +275,12 @@ describe('Audiobookshelf API client', () => { }); await expect(deleteABSItem('item-1')).resolves.toBeUndefined(); - expect(fetchMock).toHaveBeenCalledWith('http://abs/api/items/item-1', expect.objectContaining({ + expect(fetchMock).toHaveBeenCalledWith('http://abs/api/items/item-1?hard=1', { method: 'DELETE', - })); + headers: { + 'Authorization': 'Bearer token', + }, + }); }); it('throws when delete fails', async () => { diff --git a/tests/utils/audiobook-matcher.test.ts b/tests/utils/audiobook-matcher.test.ts index 6ea8896..2194838 100644 --- a/tests/utils/audiobook-matcher.test.ts +++ b/tests/utils/audiobook-matcher.test.ts @@ -6,7 +6,12 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; import { createPrismaMock } from '../helpers/prisma'; -const prismaMock = createPrismaMock(); +const prismaMock = createPrismaMock() as ReturnType & { + reportedIssue: { findMany: ReturnType }; +}; + +// Add reportedIssue mock (not yet in shared helper) for getOpenIssuesByAsins +(prismaMock as any).reportedIssue = { findMany: vi.fn() }; vi.mock('@/lib/db', () => ({ prisma: prismaMock, @@ -122,6 +127,9 @@ describe('audiobook-matcher', () => { }, ]); + // Mock reported issues (none for this test) + prismaMock.reportedIssue.findMany.mockResolvedValue([]); + const { enrichAudiobooksWithMatches } = await import('@/lib/utils/audiobook-matcher'); const results = await enrichAudiobooksWithMatches( [