diff --git a/extensions/zalo/src/monitor.reply-once.lifecycle.test.ts b/extensions/zalo/src/monitor.reply-once.lifecycle.test.ts index c8a23e5d4ad..807606306b6 100644 --- a/extensions/zalo/src/monitor.reply-once.lifecycle.test.ts +++ b/extensions/zalo/src/monitor.reply-once.lifecycle.test.ts @@ -60,6 +60,15 @@ describe("Zalo reply-once lifecycle", () => { }); } + function requireRecordInboundSessionArgs() { + const [call] = recordInboundSessionMock.mock.calls; + if (!call) { + throw new Error("expected inbound session record call"); + } + const [recordArgs] = call; + return recordArgs; + } + it("routes one accepted webhook event to one visible reply across duplicate replay", async () => { dispatchReplyWithBufferedBlockDispatcherMock.mockImplementation( async ({ dispatcherOptions }) => { @@ -95,7 +104,7 @@ describe("Zalo reply-once lifecycle", () => { ); expect(recordInboundSessionMock).toHaveBeenCalledTimes(1); - const [recordArgs] = recordInboundSessionMock.mock.calls[0] ?? []; + const recordArgs = requireRecordInboundSessionArgs(); expect(recordArgs?.sessionKey).toBe("agent:main:zalo:direct:dm-chat-1"); expect(recordArgs?.ctx?.AccountId).toBe("acct-zalo-lifecycle"); expect(recordArgs?.ctx?.SessionKey).toBe("agent:main:zalo:direct:dm-chat-1");