mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
20c8fb0898
Introduce user-reported-issues and Goodreads shelf sync features and wire them into notifications. Adds Prisma migrations and schema changes (ReportedIssue, GoodreadsShelf, GoodreadsBookMapping), API endpoints for reporting (POST /audiobooks/[asin]/report-issue) and admin management (list, resolve/dismiss, replace), and an admin UI section to view/dismiss/replace reported issues. Adds a new notification event (issue_reported) with updates to notification schemas, docs and provider handling, plus a notification-events constants file. Refactors request creation to use createRequestForUser service, adds a Goodreads sync processor/service/hooks/UI modals, a scrape-resilience util, and related tests and minor integration updates.
53 lines
1.5 KiB
TypeScript
53 lines
1.5 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(),
|
|
$queryRaw: vi.fn(),
|
|
$disconnect: vi.fn(),
|
|
});
|