test: invoke whatsapp setup validators

This commit is contained in:
Peter Steinberger
2026-05-08 06:31:10 +01:00
parent 0f31b6424e
commit 765ca52915
2 changed files with 18 additions and 5 deletions

View File

@@ -16,7 +16,18 @@ describe("whatsapp setup entry", () => {
const whatsappSetupPlugin = setupEntry.loadSetupPlugin();
expect(whatsappSetupPlugin.id).toBe("whatsapp");
expect(setupEntry.loadLegacyStateMigrationDetector?.()).toEqual(expect.any(Function));
const detectLegacyStateMigrations = setupEntry.loadLegacyStateMigrationDetector?.();
if (!detectLegacyStateMigrations) {
throw new Error("expected WhatsApp legacy state migration detector");
}
expect(
detectLegacyStateMigrations({
cfg: {},
env: {},
oauthDir: "/tmp/openclaw-whatsapp-empty",
stateDir: "/tmp/openclaw-state",
}),
).toEqual([]);
expect(setupEntry.loadLegacySessionSurface?.()).toEqual({
canonicalizeLegacySessionKey: expect.any(Function),
isLegacyGroupSessionKey: expect.any(Function),

View File

@@ -183,10 +183,12 @@ describe("whatsapp setup wizard", () => {
const prompt = harness.text.mock.calls[0]?.[0] as
| { validate?: (value: string) => string | undefined }
| undefined;
expect(prompt?.validate).toEqual(expect.any(Function));
expect(prompt?.validate?.("abc")).toBe("Invalid number: abc");
expect(prompt?.validate?.("whatsapp:")).toBe("Invalid number: whatsapp:");
expect(prompt?.validate?.("+1 (555) 555-0123")).toBeUndefined();
if (!prompt?.validate) {
throw new Error("expected owner number validator");
}
expect(prompt.validate("abc")).toBe("Invalid number: abc");
expect(prompt.validate("whatsapp:")).toBe("Invalid number: whatsapp:");
expect(prompt.validate("+1 (555) 555-0123")).toBeUndefined();
});
it("supports disabled DM policy for separate-phone setup", async () => {