mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 23:08:28 +00:00
Docker: fix WhatsApp config typing in onboarding + add tests
This commit is contained in:
committed by
Peter Steinberger
parent
8b7b86ada8
commit
3c2e848a8e
57
src/commands/onboard-providers.test.ts
Normal file
57
src/commands/onboard-providers.test.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { ClawdbotConfig } from "../config/config.js";
|
||||
import {
|
||||
setWhatsAppAllowFrom,
|
||||
setWhatsAppDmPolicy,
|
||||
setWhatsAppSelfChatMode,
|
||||
} from "./onboard-providers.js";
|
||||
|
||||
describe("onboard-providers WhatsApp setters", () => {
|
||||
it("preserves existing WhatsApp fields when updating allowFrom", () => {
|
||||
const cfg: ClawdbotConfig = {
|
||||
whatsapp: {
|
||||
selfChatMode: true,
|
||||
dmPolicy: "pairing",
|
||||
allowFrom: ["*"],
|
||||
accounts: {
|
||||
default: { enabled: false },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const next = setWhatsAppAllowFrom(cfg, ["+15555550123"]);
|
||||
|
||||
expect(next.whatsapp?.selfChatMode).toBe(true);
|
||||
expect(next.whatsapp?.dmPolicy).toBe("pairing");
|
||||
expect(next.whatsapp?.allowFrom).toEqual(["+15555550123"]);
|
||||
expect(next.whatsapp?.accounts?.default?.enabled).toBe(false);
|
||||
});
|
||||
|
||||
it("updates dmPolicy without dropping selfChatMode", () => {
|
||||
const cfg: ClawdbotConfig = {
|
||||
whatsapp: {
|
||||
selfChatMode: true,
|
||||
dmPolicy: "pairing",
|
||||
},
|
||||
};
|
||||
|
||||
const next = setWhatsAppDmPolicy(cfg, "open");
|
||||
|
||||
expect(next.whatsapp?.dmPolicy).toBe("open");
|
||||
expect(next.whatsapp?.selfChatMode).toBe(true);
|
||||
});
|
||||
|
||||
it("updates selfChatMode without dropping allowFrom", () => {
|
||||
const cfg: ClawdbotConfig = {
|
||||
whatsapp: {
|
||||
allowFrom: ["+15555550123"],
|
||||
},
|
||||
};
|
||||
|
||||
const next = setWhatsAppSelfChatMode(cfg, true);
|
||||
|
||||
expect(next.whatsapp?.selfChatMode).toBe(true);
|
||||
expect(next.whatsapp?.allowFrom).toEqual(["+15555550123"]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user