Files
openclaw/src/plugin-sdk/whatsapp-auth-presence.test.ts
Vincent Koc 7771c69caf fix(plugins): enforce activation before shipped imports (#59136)
* fix(plugins): enforce activation before shipped imports

* fix(plugins): remove more ambient bundled loads

* fix(plugins): tighten scoped loader matching

* fix(plugins): remove channel-id scoped loader matches

* refactor(plugin-sdk): relocate ambient provider helpers

* fix(plugin-sdk): preserve unicode ADC credential paths

* fix(plugins): restore safe setup fallback
2026-04-02 11:18:49 +09:00

41 lines
1.1 KiB
TypeScript

import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import { hasAnyWhatsAppAuth } from "./whatsapp-auth-presence.js";
const tempDirs: string[] = [];
afterEach(async () => {
await Promise.all(
tempDirs.splice(0, tempDirs.length).map((dir) => fs.rm(dir, { recursive: true, force: true })),
);
});
describe("hasAnyWhatsAppAuth", () => {
it("resolves account authDir against the provided environment", async () => {
const homeDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-wa-auth-"));
tempDirs.push(homeDir);
const authDir = path.join(homeDir, "wa-auth");
await fs.mkdir(authDir, { recursive: true });
await fs.writeFile(path.join(authDir, "creds.json"), "{}\n", "utf8");
expect(
hasAnyWhatsAppAuth(
{
channels: {
whatsapp: {
accounts: {
custom: {
authDir: "~/wa-auth",
},
},
},
},
},
{ HOME: homeDir } as NodeJS.ProcessEnv,
),
).toBe(true);
});
});