From 5112d0e5163df6dff485f97f3dc4d467442cb609 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 2 Oct 2026 23:26:49 +0000 Subject: [PATCH] test(adapters): give the consolidation unit tests the profile lock The write transaction now takes the per-user profile lock, so the mocked client answers the lock query, and the first case checks the lock is taken. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u --- packages/adapters/src/profile-consolidation.test.ts | 4 ++++ 1 file changed, 4 insertions(+) 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." },