























@@ -212,6 +212,18 @@ async function setupCommentMonitorHandler(): Promise<(data: unknown) => Promise<
212212});
213213}
214214215+function mockCallAt(
216+mock: { mock: { calls: Array<readonly unknown[]> } },
217+index: number,
218+label: string,
219+): readonly unknown[] {
220+const call = mock.mock.calls[index];
221+if (!call) {
222+throw new Error(`expected ${label} call`);
223+}
224+return call;
225+}
226+215227describe("resolveDriveCommentEventTurn", () => {
216228it("builds a real comment-turn prompt for add_comment notices", async () => {
217229const client = makeOpenApiClient({ includeTargetReplyInBatch: true });
@@ -828,7 +840,7 @@ describe("drive.notice.comment_add_v1 monitor handler", () => {
828840await onComment(makeDriveCommentEvent());
829841830842expect(handleFeishuCommentEventMock).toHaveBeenCalledTimes(1);
831-const handleArgs = handleFeishuCommentEventMock.mock.calls.at(0)?.[0] as
843+const handleArgs = mockCallAt(handleFeishuCommentEventMock, 0, "Feishu comment handler")[0] as
832844| {
833845accountId?: string;
834846botOpenId?: string;
@@ -880,12 +892,16 @@ describe("drive.notice.comment_add_v1 monitor handler", () => {
880892await vi.waitFor(() => {
881893expect(handleFeishuCommentEventMock).toHaveBeenCalledTimes(2);
882894});
883-const firstCallArgs = handleFeishuCommentEventMock.mock.calls.at(0) as
884-| [{ event?: { event_id?: string } }]
885-| undefined;
886-const secondCallArgs = handleFeishuCommentEventMock.mock.calls.at(1) as
887-| [{ event?: { event_id?: string } }]
888-| undefined;
895+const firstCallArgs = mockCallAt(
896+handleFeishuCommentEventMock,
897+0,
898+"first Feishu comment handler",
899+) as [{ event?: { event_id?: string } }] | undefined;
900+const secondCallArgs = mockCallAt(
901+handleFeishuCommentEventMock,
902+1,
903+"second Feishu comment handler",
904+) as [{ event?: { event_id?: string } }] | undefined;
889905const firstCall = firstCallArgs?.[0];
890906const secondCall = secondCallArgs?.[0];
891907expect(firstCall?.event?.event_id).toBe("evt_1");
@@ -917,8 +933,11 @@ describe("drive.notice.comment_add_v1 monitor handler", () => {
917933"feishu[default]: error handling drive comment notice: Error: post-send failure",
918934);
919935});
920-const [recordedMessageId, recordedNamespace, recordedLogger] =
921-(dedup.recordProcessedFeishuMessage as ReturnType<typeof vi.fn>).mock.calls.at(0) ?? [];
936+const [recordedMessageId, recordedNamespace, recordedLogger] = mockCallAt(
937+dedup.recordProcessedFeishuMessage as ReturnType<typeof vi.fn>,
938+0,
939+"Feishu processed-message record",
940+);
922941expect(recordedMessageId).toBe("drive-comment:10d9d60b990db39f96a4c2fd357fb877");
923942expect(recordedNamespace).toBe("default");
924943expect(typeof recordedLogger).toBe("function");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。