mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-23 15:11:42 +00:00
* 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
41 lines
1.1 KiB
TypeScript
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);
|
|
});
|
|
});
|