test: speed up channel setup entry tests

This commit is contained in:
Peter Steinberger
2026-04-07 17:36:25 +01:00
parent 0828db93e9
commit d4eb3e12c9
7 changed files with 53 additions and 8 deletions

View File

@@ -1,4 +1,3 @@
// Keep bundled channel entry imports narrow so bootstrap/discovery paths do
// not drag the broad Discord API barrel into lightweight plugin loads.
// not drag setup-only surfaces into lightweight channel plugin loads.
export { discordPlugin } from "./src/channel.js";
export { discordSetupPlugin } from "./src/channel.setup.js";

View File

@@ -3,7 +3,7 @@ import { defineBundledChannelSetupEntry } from "openclaw/plugin-sdk/channel-entr
export default defineBundledChannelSetupEntry({
importMetaUrl: import.meta.url,
plugin: {
specifier: "./channel-plugin-api.js",
specifier: "./setup-plugin-api.js",
exportName: "discordSetupPlugin",
},
});

View File

@@ -0,0 +1,3 @@
// Keep bundled setup entry imports narrow so setup loads do not pull the
// broader Discord channel plugin surface.
export { discordSetupPlugin } from "./src/channel.setup.js";

View File

@@ -1,4 +1,3 @@
// Keep bundled channel bootstrap loads narrow so lightweight config-presence
// probes do not import the broad WhatsApp API barrel.
// Keep bundled channel bootstrap loads narrow so lightweight channel entry
// loads do not import setup-only surfaces.
export { whatsappPlugin } from "./src/channel.js";
export { whatsappSetupPlugin } from "./src/channel.setup.js";

View File

@@ -3,7 +3,7 @@ import { defineBundledChannelSetupEntry } from "openclaw/plugin-sdk/channel-entr
export default defineBundledChannelSetupEntry({
importMetaUrl: import.meta.url,
plugin: {
specifier: "./channel-plugin-api.js",
specifier: "./setup-plugin-api.js",
exportName: "whatsappSetupPlugin",
},
});

View File

@@ -0,0 +1,3 @@
// Keep bundled setup entry imports narrow so setup loads do not pull the
// broader WhatsApp channel plugin surface.
export { whatsappSetupPlugin } from "./src/channel.setup.js";

View File

@@ -1,11 +1,52 @@
import { mkdtemp, rm } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { createScopedDmSecurityResolver } from "openclaw/plugin-sdk/channel-config-helpers";
import { withEnvAsync } from "openclaw/plugin-sdk/testing";
import { describe, expect, it } from "vitest";
import { createPluginSetupWizardStatus } from "../../../test/helpers/plugins/setup-wizard.js";
import type { OpenClawConfig } from "../runtime-api.js";
import "./zalo-js.test-mocks.js";
import { zalouserSetupPlugin } from "./channel.setup.js";
import {
listZalouserAccountIds,
resolveDefaultZalouserAccountId,
resolveZalouserAccountSync,
} from "./accounts.js";
import { zalouserSetupAdapter } from "./setup-core.js";
import { zalouserSetupWizard } from "./setup-surface.js";
const zalouserSetupPlugin = {
id: "zalouser",
meta: {
id: "zalouser",
label: "ZaloUser",
selectionLabel: "ZaloUser",
docsPath: "/channels/zalouser",
blurb: "Unofficial Zalo personal account connector.",
},
capabilities: {
chatTypes: ["direct", "group"] as Array<"direct" | "group">,
},
config: {
listAccountIds: (cfg: unknown) => listZalouserAccountIds(cfg as never),
defaultAccountId: (cfg: unknown) => resolveDefaultZalouserAccountId(cfg as never),
resolveAccount: (cfg: OpenClawConfig, accountId?: string | null) =>
resolveZalouserAccountSync({ cfg, accountId }),
},
security: {
resolveDmPolicy: createScopedDmSecurityResolver({
channelKey: "zalouser",
resolvePolicy: (account: ReturnType<typeof resolveZalouserAccountSync>) =>
account.config.dmPolicy,
resolveAllowFrom: (account: ReturnType<typeof resolveZalouserAccountSync>) =>
account.config.allowFrom,
policyPathSuffix: "dmPolicy",
normalizeEntry: (raw: string) => raw.trim().replace(/^(zalouser|zlu):/i, ""),
}),
},
setup: zalouserSetupAdapter,
setupWizard: zalouserSetupWizard,
} as const;
const zalouserSetupGetStatus = createPluginSetupWizardStatus(zalouserSetupPlugin);