refactor(feishu): remove comment retry test seam (#109192)

This commit is contained in:
Peter Steinberger
2026-07-16 09:46:29 -07:00
committed by GitHub
parent af42fbb6f3
commit d4d7b80431
2 changed files with 10 additions and 11 deletions

View File

@@ -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 }]) =>

View File

@@ -61,7 +61,6 @@ type ResolveDriveCommentEventParams = {
verificationTimeoutMs?: number;
logger?: (message: string) => void;
abortSignal?: AbortSignal;
waitMs?: (ms: number, abortSignal?: AbortSignal) => Promise<boolean>;
};
type ResolvedDriveCommentEventTurn = {
@@ -729,7 +728,6 @@ async function fetchDriveCommentContext(params: {
logger?: (message: string) => void;
accountId: string;
abortSignal?: AbortSignal;
waitMs: (ms: number, abortSignal?: AbortSignal) => Promise<boolean>;
}): 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,