Files
openclaw/extensions/whatsapp/setup-entry.test.ts
2026-05-09 05:16:20 +01:00

43 lines
1.5 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
vi.mock("@whiskeysockets/baileys", () => {
throw new Error("setup plugin load must not load Baileys");
});
describe("whatsapp setup entry", () => {
it("loads the setup plugin without installing or importing runtime dependencies", async () => {
const { default: setupEntry } = await import("./setup-entry.js");
expect(setupEntry.kind).toBe("bundled-channel-setup-entry");
expect(setupEntry.features).toEqual({
legacySessionSurfaces: true,
legacyStateMigrations: true,
});
const whatsappSetupPlugin = setupEntry.loadSetupPlugin();
expect(whatsappSetupPlugin.id).toBe("whatsapp");
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",
}),
).toStrictEqual([]);
expect(setupEntry.loadLegacySessionSurface?.()).toEqual({
canonicalizeLegacySessionKey: expect.any(Function),
isLegacyGroupSessionKey: expect.any(Function),
});
});
it("loads the delegated setup wizard without importing runtime dependencies", async () => {
const { whatsappSetupWizard } = await import("./src/setup-surface.js");
expect(whatsappSetupWizard.channel).toBe("whatsapp");
});
});