test(whatsapp): add context isolation coverage
Includes outbound gating, threading fallback, and web auto-reply context assertions.
This commit is contained in:
@@ -12,6 +12,14 @@ const slackConfig = {
|
||||
},
|
||||
} as ClawdbotConfig;
|
||||
|
||||
const whatsappConfig = {
|
||||
channels: {
|
||||
whatsapp: {
|
||||
allowFrom: ["*"],
|
||||
},
|
||||
},
|
||||
} as ClawdbotConfig;
|
||||
|
||||
describe("runMessageAction context isolation", () => {
|
||||
it("allows send when target matches current channel", async () => {
|
||||
const result = await runMessageAction({
|
||||
@@ -60,4 +68,36 @@ describe("runMessageAction context isolation", () => {
|
||||
}),
|
||||
).rejects.toThrow(/Cross-context messaging denied/);
|
||||
});
|
||||
|
||||
it("allows WhatsApp send when target matches current chat", async () => {
|
||||
const result = await runMessageAction({
|
||||
cfg: whatsappConfig,
|
||||
action: "send",
|
||||
params: {
|
||||
channel: "whatsapp",
|
||||
to: "group:123@g.us",
|
||||
message: "hi",
|
||||
},
|
||||
toolContext: { currentChannelId: "123@g.us" },
|
||||
dryRun: true,
|
||||
});
|
||||
|
||||
expect(result.kind).toBe("send");
|
||||
});
|
||||
|
||||
it("blocks WhatsApp send when target differs from current chat", async () => {
|
||||
await expect(
|
||||
runMessageAction({
|
||||
cfg: whatsappConfig,
|
||||
action: "send",
|
||||
params: {
|
||||
channel: "whatsapp",
|
||||
to: "456@g.us",
|
||||
message: "hi",
|
||||
},
|
||||
toolContext: { currentChannelId: "123@g.us" },
|
||||
dryRun: true,
|
||||
}),
|
||||
).rejects.toThrow(/Cross-context messaging denied/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user