test: align whatsapp expectations with current contracts

This commit is contained in:
Tak Hoffman 2026-03-18 23:17:48 -05:00
parent b8b1e2cf50
commit 16567ba4e7
No known key found for this signature in database
3 changed files with 11 additions and 7 deletions

View File

@ -35,6 +35,10 @@ describe("whatsappPlugin outbound sendPoll", () => {
});
expectWhatsAppPollSent(hoisted.sendPollWhatsApp, { cfg, poll, to, accountId });
expect(result).toEqual({ messageId: "wa-poll-1", toJid: "1555@s.whatsapp.net" });
expect(result).toEqual({
channel: "whatsapp",
messageId: "wa-poll-1",
toJid: "1555@s.whatsapp.net",
});
});
});

View File

@ -84,7 +84,7 @@ describe("whatsapp resolveTarget", () => {
if (!result.ok) {
throw result.error;
}
expect(result.to).toBe("5511999999999@s.whatsapp.net");
expect(result.to).toBe("+5511999999999");
});
it("should resolve target in implicit mode with wildcard", () => {
@ -98,7 +98,7 @@ describe("whatsapp resolveTarget", () => {
if (!result.ok) {
throw result.error;
}
expect(result.to).toBe("5511999999999@s.whatsapp.net");
expect(result.to).toBe("+5511999999999");
});
it("should resolve target in implicit mode when in allowlist", () => {
@ -112,7 +112,7 @@ describe("whatsapp resolveTarget", () => {
if (!result.ok) {
throw result.error;
}
expect(result.to).toBe("5511999999999@s.whatsapp.net");
expect(result.to).toBe("+5511999999999");
});
it("should allow group JID regardless of allowlist", () => {

View File

@ -22,7 +22,7 @@ async function emitCredsUpdateAndReadSaveCreds() {
}
function mockCredsJsonSpies(readContents: string) {
const credsSuffix = path.join(".openclaw", "credentials", "whatsapp", "default", "creds.json");
const credsSuffix = path.join("/tmp", "openclaw-oauth", "whatsapp", "default", "creds.json");
const copySpy = vi.spyOn(fsSync, "copyFileSync").mockImplementation(() => {});
const existsSpy = vi.spyOn(fsSync, "existsSync").mockImplementation((p) => {
if (typeof p !== "string") {
@ -263,8 +263,8 @@ describe("web session", () => {
it("rotates creds backup when creds.json is valid JSON", async () => {
const creds = mockCredsJsonSpies("{}");
const backupSuffix = path.join(
".openclaw",
"credentials",
"/tmp",
"openclaw-oauth",
"whatsapp",
"default",
"creds.json.bak",