mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
cbf02d3e24
Introduce watched lists for series and authors end-to-end. - Add DB migration to create watched_series and watched_authors tables with indexes and foreign keys. - Implement API routes: GET/POST for listing/adding and DELETE by id for both /api/user/watched-series and /api/user/watched-authors. Validation, ownership checks, and immediate targeted job triggers are included. - Add client hooks (useWatchedSeries, useWatchedAuthors) with add/delete helpers and SWR revalidation. - Add UI components: WatchButton (toggle/confirm) and WatchedListsSection for profile display and removal UX. - Add processor (check-watched-lists.processor) and service (watched-lists.service) to scrape Audible, deduplicate, check library ownership, and auto-create requests; supports targeted checks for newly watched items. - Include tests for the watched-lists service. These changes implement the watched-lists feature to let users watch series/authors and have the system automatically detect and request new releases.
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
/**
|
|
* Component: Prisma Mock Factory
|
|
* Documentation: documentation/backend/database.md
|
|
*/
|
|
|
|
import { vi } from 'vitest';
|
|
|
|
type PrismaModelMock = {
|
|
findMany: ReturnType<typeof vi.fn>;
|
|
findFirst: ReturnType<typeof vi.fn>;
|
|
findUnique: ReturnType<typeof vi.fn>;
|
|
create: ReturnType<typeof vi.fn>;
|
|
update: ReturnType<typeof vi.fn>;
|
|
updateMany: ReturnType<typeof vi.fn>;
|
|
upsert: ReturnType<typeof vi.fn>;
|
|
delete: ReturnType<typeof vi.fn>;
|
|
deleteMany: ReturnType<typeof vi.fn>;
|
|
count: ReturnType<typeof vi.fn>;
|
|
};
|
|
|
|
const createModelMock = (): PrismaModelMock => ({
|
|
findMany: vi.fn(),
|
|
findFirst: vi.fn(),
|
|
findUnique: vi.fn(),
|
|
create: vi.fn(() => Promise.resolve({})),
|
|
update: vi.fn(() => Promise.resolve({})),
|
|
updateMany: vi.fn(() => Promise.resolve({})),
|
|
upsert: vi.fn(() => Promise.resolve({})),
|
|
delete: vi.fn(() => Promise.resolve({})),
|
|
deleteMany: vi.fn(() => Promise.resolve({})),
|
|
count: vi.fn(),
|
|
});
|
|
|
|
export const createPrismaMock = () => ({
|
|
configuration: createModelMock(),
|
|
user: createModelMock(),
|
|
request: createModelMock(),
|
|
audiobook: createModelMock(),
|
|
downloadHistory: createModelMock(),
|
|
plexLibrary: createModelMock(),
|
|
audibleCache: createModelMock(),
|
|
job: createModelMock(),
|
|
jobEvent: createModelMock(),
|
|
scheduledJob: createModelMock(),
|
|
bookDateConfig: createModelMock(),
|
|
bookDateRecommendation: createModelMock(),
|
|
bookDateSwipe: createModelMock(),
|
|
goodreadsShelf: createModelMock(),
|
|
goodreadsBookMapping: createModelMock(),
|
|
work: createModelMock(),
|
|
workAsin: createModelMock(),
|
|
watchedSeries: createModelMock(),
|
|
watchedAuthor: createModelMock(),
|
|
$queryRaw: vi.fn(),
|
|
$disconnect: vi.fn(),
|
|
});
|