diff --git a/backend/src/modules/note-collaborators/routes.test.ts b/backend/src/modules/note-collaborators/routes.test.ts index 86632cd..4c1d8da 100644 --- a/backend/src/modules/note-collaborators/routes.test.ts +++ b/backend/src/modules/note-collaborators/routes.test.ts @@ -14,22 +14,25 @@ vi.mock('../../lib/embeddings.js', () => ({ stripHtmlForEmbedding: vi.fn((s: string) => s.replace(/<[^>]*>/g, ' ').trim()), })); -const getNoteMock = vi.fn(async () => null); +type NoteDoc = { id: string; userId?: string; productId?: string; title?: string; body?: string }; +type CollabDoc = Record; + +const getNoteMock = vi.fn<(id: string, userId: string) => Promise>(); vi.mock('../notes/repository.js', () => ({ - getNote: (...args: unknown[]) => getNoteMock(...args), + getNote: (...args: [string, string]) => getNoteMock(...args), })); -const createCollaboratorMock = vi.fn(async (doc: Record) => doc); -const listCollaboratorsForNoteMock = vi.fn(async () => []); -const listSharedWithMeMock = vi.fn(async () => []); -const findCollaboratorMock = vi.fn(async () => null); -const deleteCollaboratorMock = vi.fn(async () => undefined); +const createCollaboratorMock = vi.fn<(doc: CollabDoc) => Promise>(); +const listCollaboratorsForNoteMock = vi.fn<(noteId: string, productId: string) => Promise>(); +const listSharedWithMeMock = vi.fn<(userId: string, productId: string) => Promise>(); +const findCollaboratorMock = vi.fn<(noteId: string, userId: string, productId: string) => Promise>(); +const deleteCollaboratorMock = vi.fn<(id: string, partitionKey: string) => Promise>(); vi.mock('./repository.js', () => ({ - createCollaborator: (...args: unknown[]) => createCollaboratorMock(...args as [Record]), - listCollaboratorsForNote: (...args: unknown[]) => listCollaboratorsForNoteMock(...args), - listSharedWithMe: (...args: unknown[]) => listSharedWithMeMock(...args), - findCollaborator: (...args: unknown[]) => findCollaboratorMock(...args), - deleteCollaborator: (...args: unknown[]) => deleteCollaboratorMock(...args), + createCollaborator: (...args: [CollabDoc]) => createCollaboratorMock(...args), + listCollaboratorsForNote: (...args: [string, string]) => listCollaboratorsForNoteMock(...args), + listSharedWithMe: (...args: [string, string]) => listSharedWithMeMock(...args), + findCollaborator: (...args: [string, string, string]) => findCollaboratorMock(...args), + deleteCollaborator: (...args: [string, string]) => deleteCollaboratorMock(...args), })); import { buildTestApp } from '../../test-helpers.js';