mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-22 22:52:03 +00:00
test: speed up channel setup entry tests
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
});
|
||||
|
||||
3
extensions/discord/setup-plugin-api.ts
Normal file
3
extensions/discord/setup-plugin-api.ts
Normal 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";
|
||||
@@ -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";
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
});
|
||||
|
||||
3
extensions/whatsapp/setup-plugin-api.ts
Normal file
3
extensions/whatsapp/setup-plugin-api.ts
Normal 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";
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user