mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-15 20:10:42 +00:00
test: tighten message action normalization coverage
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user