From 789730d1a3004d16a45d9a52c385d2818757a82a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 17 Mar 2026 09:46:25 +0000 Subject: [PATCH] test: merge telegram reaction id cases --- src/channels/plugins/actions/actions.test.ts | 60 ++++++++------------ 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/src/channels/plugins/actions/actions.test.ts b/src/channels/plugins/actions/actions.test.ts index 1b558336180..57047a99976 100644 --- a/src/channels/plugins/actions/actions.test.ts +++ b/src/channels/plugins/actions/actions.test.ts @@ -986,16 +986,28 @@ describe("telegramMessageActions", () => { expectedChatId: "123", expectedMessageId: "9001", }, + { + name: "missing messageId soft-falls through to telegram-actions", + params: { + chatId: "123", + emoji: "ok", + }, + toolContext: undefined, + expectedChatId: "123", + expectedMessageId: undefined, + }, ] as const) { handleTelegramAction.mockClear(); - await telegramMessageActions.handleAction?.({ - channel: "telegram", - action: "react", - params: testCase.params, - cfg, - accountId: undefined, - toolContext: testCase.toolContext, - }); + await expect( + telegramMessageActions.handleAction?.({ + channel: "telegram", + action: "react", + params: testCase.params, + cfg, + accountId: undefined, + toolContext: testCase.toolContext, + }), + ).resolves.toBeDefined(); expect(handleTelegramAction, testCase.name).toHaveBeenCalledTimes(1); const call = handleTelegramAction.mock.calls[0]?.[0]; @@ -1005,35 +1017,13 @@ describe("telegramMessageActions", () => { const callPayload = call as Record; expect(callPayload.action, testCase.name).toBe("react"); expect(String(callPayload.chatId), testCase.name).toBe(testCase.expectedChatId); - expect(String(callPayload.messageId), testCase.name).toBe(testCase.expectedMessageId); + if (testCase.expectedMessageId === undefined) { + expect(callPayload.messageId, testCase.name).toBeUndefined(); + } else { + expect(String(callPayload.messageId), testCase.name).toBe(testCase.expectedMessageId); + } } }); - - it("forwards missing reaction messageId to telegram-actions for soft-fail handling", async () => { - const cfg = telegramCfg(); - - await expect( - telegramMessageActions.handleAction?.({ - channel: "telegram", - action: "react", - params: { - chatId: "123", - emoji: "ok", - }, - cfg, - accountId: undefined, - }), - ).resolves.toBeDefined(); - - expect(handleTelegramAction).toHaveBeenCalledTimes(1); - const call = handleTelegramAction.mock.calls[0]?.[0]; - if (!call) { - throw new Error("missing telegram action call"); - } - const callPayload = call as Record; - expect(callPayload.action).toBe("react"); - expect(callPayload.messageId).toBeUndefined(); - }); }); describe("signalMessageActions", () => {