diff --git a/packages/adapters/src/profile-consolidation.test.ts b/packages/adapters/src/profile-consolidation.test.ts index 7175f97..01aa3b2 100644 --- a/packages/adapters/src/profile-consolidation.test.ts +++ b/packages/adapters/src/profile-consolidation.test.ts @@ -178,6 +178,8 @@ function fakePrisma( createMany: vi.fn(async () => ({ count: 1 })), updateMany: vi.fn(async () => ({ count: 1 })), }, + // The per-user profile lock taken inside the write transaction. + $queryRaw: vi.fn(async () => []), $transaction: vi.fn(), }; prisma.$transaction.mockImplementation(async (work: (tx: typeof prisma) => unknown) => @@ -334,6 +336,8 @@ describe("consolidateProfile", () => { expect(request.prompt).not.toContain("asthma"); expect(request.prompt.match(//g)).toHaveLength(2); + // Facts are written under the same per-user lock as every other profile writer. + expect(prisma.$queryRaw).toHaveBeenCalledTimes(1); expect(prisma.userProfile.updateMany).toHaveBeenCalledWith({ where: { userId: "user-1", consolidatedAt: null, summary: "Runs." }, data: { consolidatedAt: expect.any(Date), summary: "Nurse in Berlin who runs." },