




















@@ -38,6 +38,10 @@ import {
3838resolveInboundReplyDispatchCounts,
3939} from "./inbound-reply-dispatch.js";
404041+function readFirstMockArg(fn: unknown): unknown {
42+return (fn as { mock: { calls: unknown[][] } }).mock.calls[0]?.[0];
43+}
44+4145describe("recordInboundSessionAndDispatchReply", () => {
4246beforeEach(() => {
4347deliverInboundReplyWithMessageSendContext.mockReset();
@@ -86,12 +90,11 @@ describe("recordInboundSessionAndDispatchReply", () => {
8690});
87918892expect(recordInboundSession).toHaveBeenCalledTimes(1);
89-expect(recordInboundSession).toHaveBeenCalledWith(
90-expect.objectContaining({
91-sessionKey: "agent:main:test:peer",
92-ctx: ctxPayload,
93-}),
94-);
93+const recordParams = readFirstMockArg(recordInboundSession) as
94+| { ctx?: unknown; sessionKey?: string }
95+| undefined;
96+expect(recordParams?.sessionKey).toBe("agent:main:test:peer");
97+expect(recordParams?.ctx).toBe(ctxPayload);
9598expect(dispatchReplyWithBufferedBlockDispatcher).toHaveBeenCalledTimes(1);
9699expect(deliver).toHaveBeenCalledWith({
97100text: "hello",
@@ -198,17 +201,24 @@ describe("recordInboundSessionAndDispatchReply", () => {
198201onDispatchError: vi.fn(),
199202});
200203201-expect(deliverInboundReplyWithMessageSendContext).toHaveBeenCalledWith(
202-expect.objectContaining({
203-channel: "telegram",
204-accountId: "default",
205-agentId: "main",
206- ctxPayload,
207-payload: expect.objectContaining({ text: "hello durable" }),
208-info: { kind: "final" },
209-replyToMode: "first",
210-}),
211-);
204+const durableParams = readFirstMockArg(deliverInboundReplyWithMessageSendContext) as
205+| {
206+accountId?: string;
207+agentId?: string;
208+channel?: string;
209+ctxPayload?: unknown;
210+info?: unknown;
211+payload?: { text?: string };
212+replyToMode?: string;
213+}
214+| undefined;
215+expect(durableParams?.channel).toBe("telegram");
216+expect(durableParams?.accountId).toBe("default");
217+expect(durableParams?.agentId).toBe("main");
218+expect(durableParams?.ctxPayload).toBe(ctxPayload);
219+expect(durableParams?.payload?.text).toBe("hello durable");
220+expect(durableParams?.info).toEqual({ kind: "final" });
221+expect(durableParams?.replyToMode).toBe("first");
212222expect(deliver).not.toHaveBeenCalled();
213223});
214224此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。