test(whatsapp): add context isolation coverage

Includes outbound gating, threading fallback, and web auto-reply context assertions.
This commit is contained in:
Peter Steinberger
2026-01-14 23:23:28 +00:00
parent a70937c926
commit fd41000bc3
3 changed files with 97 additions and 0 deletions

View File

@@ -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/);
});
});