test: tighten feishu comment reaction requests

This commit is contained in:
Shakker
2026-05-10 19:47:59 +01:00
parent cfaf8c8d5d
commit 90e355a3b6

View File

@@ -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"));
});
});