diff --git a/src/app/api/workouts/__tests__/batch-create.test.ts b/src/app/api/workouts/__tests__/batch-create.test.ts index f9bd64a51..bb2c1c809 100644 --- a/src/app/api/workouts/__tests__/batch-create.test.ts +++ b/src/app/api/workouts/__tests__/batch-create.test.ts @@ -524,7 +524,19 @@ describe("POST /api/workouts/batch — user source-priority (v1.4.43 W9)", () => }), ); expect(res.status).toBe(200); - expect(prisma.user.findUnique).toHaveBeenCalledTimes(1); + // Counted by SELECT shape rather than by raw call count: the route also + // resolves the user's timezone and module map through the arrival seam, + // which are separate cached lookups. The guard here is that the + // source-priority blob is read ONCE PER BATCH and never once per workout — + // two workouts must still produce exactly one read. + const sourcePriorityReads = vi + .mocked(prisma.user.findUnique) + .mock.calls.filter( + (call) => + (call[0] as { select?: Record })?.select + ?.sourcePriorityJson === true, + ); + expect(sourcePriorityReads).toHaveLength(1); expect(prisma.user.findUnique).toHaveBeenCalledWith({ where: { id: "user-1" }, select: { sourcePriorityJson: true }, diff --git a/src/lib/arrivals/__tests__/backfill-immunity.test.ts b/src/lib/arrivals/__tests__/backfill-immunity.test.ts index a8229eeef..d04a13f71 100644 --- a/src/lib/arrivals/__tests__/backfill-immunity.test.ts +++ b/src/lib/arrivals/__tests__/backfill-immunity.test.ts @@ -25,7 +25,9 @@ */ import { beforeEach, describe, expect, it, vi } from "vitest"; -const sendMock = vi.fn(async () => "job-id"); +const sendMock = vi.fn( + async (_queue: string, _payload: unknown, _opts: unknown) => "job-id", +); const annotateMock = vi.fn(); let moduleMap: Record = {}; let timezone = "Europe/Berlin"; diff --git a/src/lib/jobs/__tests__/data-arrival-worker.test.ts b/src/lib/jobs/__tests__/data-arrival-worker.test.ts index da2e0ec66..b57980226 100644 --- a/src/lib/jobs/__tests__/data-arrival-worker.test.ts +++ b/src/lib/jobs/__tests__/data-arrival-worker.test.ts @@ -29,8 +29,8 @@ vi.mock("@/lib/jobs/reminder/shared", () => ({ workerLog: vi.fn(), })); -const createMany = vi.fn(async () => ({ count: 1 })); -const updateMany = vi.fn(async () => ({ count: 1 })); +const createMany = vi.fn(async (_args: unknown) => ({ count: 1 })); +const updateMany = vi.fn(async (_args: unknown) => ({ count: 1 })); const fakePrisma = { arrivalReaction: { createMany, updateMany } }; const { runDataArrival } = await import("../data-arrival");