refactor: trim whatsapp test helper exports

This commit is contained in:
Peter Steinberger
2026-05-01 18:54:17 +01:00
parent 1c76065ccd
commit 3961f52ab2
3 changed files with 13 additions and 17 deletions

View File

@@ -16,7 +16,6 @@ import {
} from "./test-helpers.js";
export {
resetBaileysMocks,
resetLoadConfigMock,
setLoadConfigMock,
setRuntimeConfigSourceSnapshotMock,
@@ -56,7 +55,7 @@ type MockSessionSocket = {
user: { id: string };
};
export const TEST_NET_IP = "93.184.216.34";
const TEST_NET_IP = "93.184.216.34";
const WEB_AUTO_REPLY_SOCKETS_KEY = Symbol.for("openclaw:webAutoReplySessionSockets");
function getSessionSockets(): MockSessionSocket[] {
@@ -97,7 +96,7 @@ export function getLastWebAutoReplySessionSocket(): MockSessionSocket {
return last;
}
export function resetWebAutoReplySessionSockets() {
function resetWebAutoReplySessionSockets() {
getSessionSockets().length = 0;
}
@@ -115,7 +114,7 @@ vi.mock("openclaw/plugin-sdk/agent-runtime", () => ({
runEmbeddedPiAgent: vi.fn(),
}));
export async function rmDirWithRetries(
async function rmDirWithRetries(
dir: string,
opts?: { attempts?: number; delayMs?: number },
): Promise<void> {
@@ -314,7 +313,7 @@ export function createWebInboundDeliverySpies(): AnyExport {
};
}
export function createWebAutoReplyRuntime(): WebAutoReplyRuntime {
function createWebAutoReplyRuntime(): WebAutoReplyRuntime {
return {
log: vi.fn(),
error: vi.fn(),

View File

@@ -152,10 +152,7 @@ function setWhatsAppSelfChatMode(
return mergeWhatsAppConfig(cfg, accountId, { selfChatMode });
}
export async function detectWhatsAppLinked(
cfg: OpenClawConfig,
accountId: string,
): Promise<boolean> {
async function detectWhatsAppLinked(cfg: OpenClawConfig, accountId: string): Promise<boolean> {
const { authDir } = resolveWhatsAppAuthDir({ cfg, accountId });
const credsPath = path.join(authDir, "creds.json");
return await pathExists(credsPath);

View File

@@ -23,12 +23,12 @@ type QueuedWizardPrompterFactory<T extends WizardPromptHarness> = (params: {
textValues?: string[];
}) => T;
export const WHATSAPP_OWNER_NUMBER_INPUT = "+1 (555) 555-0123";
export const WHATSAPP_OWNER_NUMBER = "+15555550123";
export const WHATSAPP_PERSONAL_NUMBER_INPUT = "+1 (555) 111-2222";
export const WHATSAPP_PERSONAL_NUMBER = "+15551112222";
export const WHATSAPP_ACCESS_NOTE_TITLE = "WhatsApp DM access";
export const WHATSAPP_LOGIN_NOTE_TITLE = "WhatsApp";
const WHATSAPP_OWNER_NUMBER_INPUT = "+1 (555) 555-0123";
const WHATSAPP_OWNER_NUMBER = "+15555550123";
const WHATSAPP_PERSONAL_NUMBER_INPUT = "+1 (555) 111-2222";
const WHATSAPP_PERSONAL_NUMBER = "+15551112222";
const WHATSAPP_ACCESS_NOTE_TITLE = "WhatsApp DM access";
const WHATSAPP_LOGIN_NOTE_TITLE = "WhatsApp";
export function createWhatsAppRootAllowFromConfig(): WhatsAppSetupConfig {
return {
@@ -99,7 +99,7 @@ export function createWhatsAppAllowlistModeInput(): {
};
}
export function expectWhatsAppDmAccess(
function expectWhatsAppDmAccess(
cfg: WhatsAppSetupConfig,
expected: {
selfChatMode: boolean;
@@ -123,7 +123,7 @@ export function expectWhatsAppWorkAccountOpenAccess(cfg: WhatsAppSetupConfig): v
expect(cfg.channels?.whatsapp?.accounts?.work?.allowFrom).toEqual(["*", WHATSAPP_OWNER_NUMBER]);
}
export function expectWhatsAppOwnerNumberPrompt(harness: WizardPromptHarness): void {
function expectWhatsAppOwnerNumberPrompt(harness: WizardPromptHarness): void {
expect(harness.text).toHaveBeenCalledWith(
expect.objectContaining({
message: "Your personal WhatsApp number (the phone you will message from)",