test: tighten message action normalization coverage

This commit is contained in:
Peter Steinberger
2026-03-13 21:22:15 +00:00
parent 651ccf9901
commit 256c91ca6d

View File

@@ -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({