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

@@ -23,6 +23,21 @@ describe("buildThreadingToolContext", () => {
expect(result.currentChannelId).toBe("123@g.us");
});
it("falls back to To for WhatsApp when From is missing", () => {
const sessionCtx = {
Provider: "whatsapp",
To: "+15550001",
} as TemplateContext;
const result = buildThreadingToolContext({
sessionCtx,
config: cfg,
hasRepliedRef: undefined,
});
expect(result.currentChannelId).toBe("+15550001");
});
it("uses the recipient id for other channels", () => {
const sessionCtx = {
Provider: "telegram",