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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u
This commit is contained in:
parent
84a95f0a3b
commit
5112d0e516
@ -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(/<conversation>/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." },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user