From 90e355a3b69615779cd02fd356bd2d0efd82f830 Mon Sep 17 00:00:00 2001 From: Shakker Date: Sun, 10 May 2026 19:47:59 +0100 Subject: [PATCH] test: tighten feishu comment reaction requests --- .../feishu/src/comment-reaction.test.ts | 74 +++++-------------- 1 file changed, 20 insertions(+), 54 deletions(-) diff --git a/extensions/feishu/src/comment-reaction.test.ts b/extensions/feishu/src/comment-reaction.test.ts index 4ecb39bc8fb..30c77028b2c 100644 --- a/extensions/feishu/src/comment-reaction.test.ts +++ b/extensions/feishu/src/comment-reaction.test.ts @@ -18,6 +18,21 @@ vi.mock("./client.js", () => ({ describe("createCommentTypingReactionLifecycle", () => { const request = vi.fn(); + const commentReactionUrl = + "/open-apis/drive/v2/files/doc_token_1/comments/reaction?file_type=docx"; + + function expectedTypingReactionRequest(action: "add" | "delete") { + return { + method: "POST", + url: commentReactionUrl, + data: { + action, + reply_id: "reply_1", + reaction_type: "Typing", + }, + timeout: 30_000, + }; + } afterAll(() => { vi.doUnmock("./accounts.js"); @@ -71,30 +86,8 @@ describe("createCommentTypingReactionLifecycle", () => { await lifecycle.start(); await lifecycle.cleanup(); - expect(request).toHaveBeenNthCalledWith( - 1, - expect.objectContaining({ - method: "POST", - url: "/open-apis/drive/v2/files/doc_token_1/comments/reaction?file_type=docx", - data: { - action: "add", - reply_id: "reply_1", - reaction_type: "Typing", - }, - }), - ); - expect(request).toHaveBeenNthCalledWith( - 2, - expect.objectContaining({ - method: "POST", - url: "/open-apis/drive/v2/files/doc_token_1/comments/reaction?file_type=docx", - data: { - action: "delete", - reply_id: "reply_1", - reaction_type: "Typing", - }, - }), - ); + expect(request).toHaveBeenNthCalledWith(1, expectedTypingReactionRequest("add")); + expect(request).toHaveBeenNthCalledWith(2, expectedTypingReactionRequest("delete")); }); it("skips requests when reply_id is missing", async () => { @@ -114,16 +107,7 @@ describe("createCommentTypingReactionLifecycle", () => { await lifecycle.cleanup(); expect(request).toHaveBeenCalledTimes(2); - expect(request).toHaveBeenNthCalledWith( - 2, - expect.objectContaining({ - data: { - action: "delete", - reply_id: "reply_1", - reaction_type: "Typing", - }, - }), - ); + expect(request).toHaveBeenNthCalledWith(2, expectedTypingReactionRequest("delete")); }); it("retries delete during later cleanup after an ambient delete failure", async () => { @@ -148,25 +132,7 @@ describe("createCommentTypingReactionLifecycle", () => { await lifecycle.cleanup(); expect(request).toHaveBeenCalledTimes(3); - expect(request).toHaveBeenNthCalledWith( - 2, - expect.objectContaining({ - data: { - action: "delete", - reply_id: "reply_1", - reaction_type: "Typing", - }, - }), - ); - expect(request).toHaveBeenNthCalledWith( - 3, - expect.objectContaining({ - data: { - action: "delete", - reply_id: "reply_1", - reaction_type: "Typing", - }, - }), - ); + expect(request).toHaveBeenNthCalledWith(2, expectedTypingReactionRequest("delete")); + expect(request).toHaveBeenNthCalledWith(3, expectedTypingReactionRequest("delete")); }); });