From 256c91ca6d4a0db2d331d197a4b96a382cf78339 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 13 Mar 2026 21:22:15 +0000 Subject: [PATCH] test: tighten message action normalization coverage --- .../message-action-normalization.test.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/infra/outbound/message-action-normalization.test.ts b/src/infra/outbound/message-action-normalization.test.ts index 5f0647b955c..87fa7a8503c 100644 --- a/src/infra/outbound/message-action-normalization.test.ts +++ b/src/infra/outbound/message-action-normalization.test.ts @@ -72,6 +72,62 @@ describe("normalizeMessageActionInput", () => { expect(normalized.channel).toBe("slack"); }); + it("does not infer a target for actions that do not accept one", () => { + const normalized = normalizeMessageActionInput({ + action: "broadcast", + args: {}, + toolContext: { + currentChannelId: "channel:C1", + }, + }); + + expect("target" in normalized).toBe(false); + expect("to" in normalized).toBe(false); + }); + + it("does not backfill a non-deliverable tool-context channel", () => { + const normalized = normalizeMessageActionInput({ + action: "send", + args: { + target: "channel:C1", + }, + toolContext: { + currentChannelProvider: "webchat", + }, + }); + + expect("channel" in normalized).toBe(false); + }); + + it("keeps alias-based targets without inferring the current channel", () => { + const normalized = normalizeMessageActionInput({ + action: "edit", + args: { + messageId: "msg_123", + }, + toolContext: { + currentChannelId: "channel:C1", + }, + }); + + expect(normalized.messageId).toBe("msg_123"); + expect("target" in normalized).toBe(false); + expect("to" in normalized).toBe(false); + }); + + it("maps legacy channelId inputs through canonical target for channel-id actions", () => { + const normalized = normalizeMessageActionInput({ + action: "channel-info", + args: { + channelId: "C123", + }, + }); + + expect(normalized.target).toBe("C123"); + expect(normalized.channelId).toBe("C123"); + expect("to" in normalized).toBe(false); + }); + it("throws when required target remains unresolved", () => { expect(() => normalizeMessageActionInput({