























@@ -198,11 +198,20 @@ async function setupDebounceMonitor(params?: {
198198return onMessage;
199199}
200200201-function getFirstDispatchedEvent(): FeishuMessageEvent {
202-const firstCall = handleFeishuMessageMock.mock.calls.at(0);
203-if (!firstCall) {
204-throw new Error("missing dispatch call");
201+function mockCallAt(
202+mock: { mock: { calls: Array<readonly unknown[]> } },
203+index: number,
204+label: string,
205+): readonly unknown[] {
206+const call = mock.mock.calls[index];
207+if (!call) {
208+throw new Error(`expected ${label} call`);
205209}
210+return call;
211+}
212+213+function getFirstDispatchedEvent(): FeishuMessageEvent {
214+const firstCall = mockCallAt(handleFeishuMessageMock, 0, "Feishu message dispatch");
206215const firstParams = firstCall[0] as { event?: FeishuMessageEvent } | undefined;
207216if (!firstParams?.event) {
208217throw new Error("missing dispatched event payload");
@@ -576,7 +585,7 @@ describe("Feishu inbound debounce regressions", () => {
576585await vi.advanceTimersByTimeAsync(25);
577586578587expect(handleFeishuMessageMock).toHaveBeenCalledTimes(1);
579-const firstParams = handleFeishuMessageMock.mock.calls.at(0)?.[0] as
588+const firstParams = mockCallAt(handleFeishuMessageMock, 0, "Feishu message dispatch")[0] as
580589| { botName?: string }
581590| undefined;
582591expect(firstParams?.botName).toBe("OpenClaw Bot");
@@ -680,7 +689,11 @@ describe("Feishu inbound debounce regressions", () => {
680689const combined = JSON.parse(dispatched.message.content) as { text?: string };
681690expect(combined.text).toBe("fresh");
682691expect(recordSpy).toHaveBeenCalledTimes(1);
683-const [recordedMessageId, recordedNamespace, recordedLogger] = recordSpy.mock.calls.at(0) ?? [];
692+const [recordedMessageId, recordedNamespace, recordedLogger] = mockCallAt(
693+recordSpy,
694+0,
695+"Feishu processed-message record",
696+);
684697expect(recordedMessageId).toBe("om_old_latest_fresh");
685698expect(recordedNamespace).toBe("default");
686699expect(typeof recordedLogger).toBe("function");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。