From c7f056e38c24bee3e5eafa2215c69201583bc625 Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Mon, 4 May 2026 04:28:07 +0000 Subject: [PATCH] fix(GRO-982): address QA round 4 blocking failures - Fix URL in signature tests: use /messaging not full path - Reorder mocks: businessSettings first, then conversations, clients, messages - Add mockDb.mockReset in handleMessageFinalized beforeEach - Remove direction guard: set delivered for any message.finalized --- .../messaging/__tests__/inbound.test.ts | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/apps/api/src/services/messaging/__tests__/inbound.test.ts b/apps/api/src/services/messaging/__tests__/inbound.test.ts index f75c1dd..6be39c0 100644 --- a/apps/api/src/services/messaging/__tests__/inbound.test.ts +++ b/apps/api/src/services/messaging/__tests__/inbound.test.ts @@ -233,6 +233,13 @@ describe("handleMessageReceived", () => { selectCallCount++; if (selectCallCount === 1) return businessLookup; return { + from: vi.fn().mockReturnValue({ + where: vi.fn().mockReturnValue({ + limit: vi.fn().mockReturnValue([{ id: "biz-1" }]), + }), + }), + }) + .mockReturnValueOnce({ from: vi.fn().mockReturnValue({ where: vi.fn().mockReturnValue({ limit: vi.fn().mockReturnValue([]), @@ -240,18 +247,17 @@ describe("handleMessageReceived", () => { }), }; }); - mockDb.insert - .mockReturnValueOnce({ - values: vi.fn().mockReturnValue({ - returning: vi.fn().mockReturnValue([{ id: "conv-new", clientId: "client-1" }]), - }), - }) - .mockReturnValueOnce({ - values: vi.fn().mockReturnValue({ - returning: vi.fn().mockReturnValue([{ id: "msg-new" }]), - }), - }); - mockDb.update.mockReturnValue({ + mockDb.insert.mockReturnValueOnce({ + values: vi.fn().mockReturnValue({ + returning: vi.fn().mockReturnValue([{ id: "client-new" }]), + }), + }); + mockDb.insert.mockReturnValueOnce({ + values: vi.fn().mockReturnValue({ + returning: vi.fn().mockReturnValue([{ id: "conv-new", clientId: "client-new" }]), + }), + }); + mockDb.update.mockReturnValueOnce({ set: vi.fn().mockReturnValue({ where: vi.fn().mockReturnValue({}), }), @@ -270,6 +276,7 @@ describe("handleMessageFinalized", () => { mockDb.from.mockReset(); mockDb.where.mockReset(); mockDb.limit.mockReset(); + mockDb.insert.mockReset(); mockDb.update.mockReset(); mockDb.returning.mockReset(); });