From d4d7b80431e8cd55af4a09f4686d09bf13e6a08e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 16 Jul 2026 09:46:29 -0700 Subject: [PATCH] refactor(feishu): remove comment retry test seam (#109192) --- extensions/feishu/src/monitor.comment.test.ts | 15 +++++++++------ extensions/feishu/src/monitor.comment.ts | 6 +----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/extensions/feishu/src/monitor.comment.test.ts b/extensions/feishu/src/monitor.comment.test.ts index 5edfb42885d5..25f267d808fd 100644 --- a/extensions/feishu/src/monitor.comment.test.ts +++ b/extensions/feishu/src/monitor.comment.test.ts @@ -742,7 +742,7 @@ describe("resolveDriveCommentEventTurn", () => { }); it("retries comment reply lookup when the requested reply is not immediately visible", async () => { - const waitMs = vi.fn(async () => true); + vi.useFakeTimers(); const client = makeOpenApiClient({ includeTargetReplyInBatch: false, repliesSequence: [ @@ -770,7 +770,7 @@ describe("resolveDriveCommentEventTurn", () => { ], }); - const turn = await resolveDriveCommentEventTurn({ + const turnPromise = resolveDriveCommentEventTurn({ cfg: buildMonitorConfig(), accountId: "default", event: makeDriveCommentEvent({ @@ -782,14 +782,17 @@ describe("resolveDriveCommentEventTurn", () => { }), botOpenId: "ou_bot", createClient: () => client as never, - waitMs, }); + await vi.waitFor(() => { + expect(vi.getTimerCount()).toBe(1); + }); + await vi.advanceTimersByTimeAsync(2_000); + const turn = await turnPromise; + expect(turn?.targetReplyText).toBe("Insert a sentence below this paragraph"); expect(turn?.prompt).toContain("Insert a sentence below this paragraph"); - expect(waitMs).toHaveBeenCalledTimes(2); - expect(waitMs).toHaveBeenNthCalledWith(1, 1000, undefined); - expect(waitMs).toHaveBeenNthCalledWith(2, 1000, undefined); + expect(vi.getTimerCount()).toBe(0); expect( client.request.mock.calls.filter( ([request]: [{ method: string; url: string }]) => diff --git a/extensions/feishu/src/monitor.comment.ts b/extensions/feishu/src/monitor.comment.ts index 66086046bfa6..cb4f4738eb71 100644 --- a/extensions/feishu/src/monitor.comment.ts +++ b/extensions/feishu/src/monitor.comment.ts @@ -61,7 +61,6 @@ type ResolveDriveCommentEventParams = { verificationTimeoutMs?: number; logger?: (message: string) => void; abortSignal?: AbortSignal; - waitMs?: (ms: number, abortSignal?: AbortSignal) => Promise; }; type ResolvedDriveCommentEventTurn = { @@ -729,7 +728,6 @@ async function fetchDriveCommentContext(params: { logger?: (message: string) => void; accountId: string; abortSignal?: AbortSignal; - waitMs: (ms: number, abortSignal?: AbortSignal) => Promise; }): Promise<{ documentTitle?: string; documentUrl?: string; @@ -832,7 +830,7 @@ async function fetchDriveCommentContext(params: { `requested_reply=${params.replyId} attempt=${attempt}/${FEISHU_COMMENT_REPLY_MISS_RETRY_LIMIT} ` + `delay_ms=${FEISHU_COMMENT_REPLY_MISS_RETRY_DELAY_MS}`, ); - const delayElapsed = await params.waitMs( + const delayElapsed = await waitForAbortableDelay( FEISHU_COMMENT_REPLY_MISS_RETRY_DELAY_MS, params.abortSignal, ); @@ -1238,7 +1236,6 @@ async function resolveDriveCommentEventCore(params: ResolveDriveCommentEventPara verificationTimeoutMs = FEISHU_COMMENT_VERIFY_TIMEOUT_MS, logger, abortSignal, - waitMs = waitForAbortableDelay, } = params; const eventId = event.event_id?.trim(); const commentId = event.comment_id?.trim(); @@ -1288,7 +1285,6 @@ async function resolveDriveCommentEventCore(params: ResolveDriveCommentEventPara logger, accountId, abortSignal, - waitMs, }); return { eventId,