mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 04:40:09 +00:00
Add reported-issues, Goodreads sync & notifs
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.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Documentation: documentation/backend/services/scheduler.md
|
||||
*/
|
||||
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { createPrismaMock } from '../helpers/prisma';
|
||||
|
||||
const prismaMock = createPrismaMock();
|
||||
@@ -29,8 +29,20 @@ vi.mock('@/lib/services/thumbnail-cache.service', () => ({
|
||||
}));
|
||||
|
||||
describe('processAudibleRefresh', () => {
|
||||
let origSetTimeout: typeof global.setTimeout;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
origSetTimeout = global.setTimeout;
|
||||
// Replace setTimeout so the batch cooldown resolves instantly
|
||||
global.setTimeout = ((fn: (...args: any[]) => void) => {
|
||||
fn();
|
||||
return 0 as ReturnType<typeof setTimeout>;
|
||||
}) as any;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
global.setTimeout = origSetTimeout;
|
||||
});
|
||||
|
||||
it('refreshes popular and new releases, caching thumbnails', async () => {
|
||||
@@ -110,5 +122,3 @@ describe('processAudibleRefresh', () => {
|
||||
await expect(processAudibleRefresh({ jobId: 'job-2' })).rejects.toThrow('DB down');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import type { NotificationEvent } from '@/lib/constants/notification-events';
|
||||
|
||||
const notificationServiceMock = vi.hoisted(() => ({
|
||||
sendNotification: vi.fn(),
|
||||
@@ -92,7 +93,7 @@ describe('processSendNotification', () => {
|
||||
it('processes all event types correctly', async () => {
|
||||
const { processSendNotification } = await import('@/lib/processors/send-notification.processor');
|
||||
|
||||
const events: Array<'request_pending_approval' | 'request_approved' | 'request_available' | 'request_error'> = [
|
||||
const events: NotificationEvent[] = [
|
||||
'request_pending_approval',
|
||||
'request_approved',
|
||||
'request_available',
|
||||
|
||||
Reference in New Issue
Block a user