mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 03:00:44 +00:00
test: invoke whatsapp setup validators
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user