mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-28 16:11:14 +00:00
refactor(feishu): remove comment retry test seam (#109192)
This commit is contained in:
committed by
GitHub
parent
af42fbb6f3
commit
d4d7b80431
@@ -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 }]) =>
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user