mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 20:35:39 -06:00
a1e0c9ea09
* test(channels): share DM policy contract suite * refactor(memory): remove dead host CLI routes * refactor(acp): use canonical normalization helpers * refactor(web): fold provider runtime into core * refactor(packages): remove dead runtime exports * chore(knip): drop retired ACP entry roots
102 lines
2.7 KiB
TypeScript
102 lines
2.7 KiB
TypeScript
// Discord tests cover setup surface plugin behavior.
|
|
import { installChannelDmPolicyContractSuite } from "openclaw/plugin-sdk/channel-test-helpers";
|
|
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
|
|
import { describe, expect, it } from "vitest";
|
|
import { createDiscordSetupWizardBase } from "./setup-core.js";
|
|
|
|
const discordSetupWizard = createDiscordSetupWizardBase({
|
|
promptAllowFrom: async ({ cfg }) => cfg,
|
|
resolveAllowFromEntries: async ({ entries }) =>
|
|
entries.map((entry) => ({
|
|
input: entry,
|
|
resolved: false,
|
|
id: null,
|
|
})),
|
|
resolveGroupAllowlist: async ({ entries }) =>
|
|
entries.map((entry) => ({
|
|
input: entry,
|
|
resolved: false,
|
|
})),
|
|
});
|
|
|
|
describe("discordSetupWizard.dmPolicy", () => {
|
|
installChannelDmPolicyContractSuite({
|
|
dmPolicy: discordSetupWizard.dmPolicy!,
|
|
cases: [
|
|
{
|
|
name: "Discord named accounts",
|
|
channel: "discord",
|
|
accountId: "alerts",
|
|
accountConfig: { token: "discord-token" },
|
|
inheritedAllowFrom: ["123"],
|
|
},
|
|
],
|
|
});
|
|
});
|
|
|
|
describe("discordSetupWizard.status", () => {
|
|
it("uses configured defaultAccount for omitted setup configured state", async () => {
|
|
const configured = await discordSetupWizard.status.resolveConfigured({
|
|
cfg: {
|
|
channels: {
|
|
discord: {
|
|
defaultAccount: "work",
|
|
token: "discord-root-token",
|
|
accounts: {
|
|
alerts: {
|
|
token: "discord-alerts-token",
|
|
},
|
|
work: {
|
|
token: "",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
} as OpenClawConfig,
|
|
});
|
|
|
|
expect(configured).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("discordSetupWizard.groupAccess", () => {
|
|
it("writes resolved Discord channel rows to their selected guild and channel", () => {
|
|
const next = discordSetupWizard.groupAccess?.applyAllowlist?.({
|
|
cfg: {
|
|
channels: {
|
|
discord: {
|
|
guilds: {
|
|
existing: {
|
|
channels: {
|
|
keep: { enabled: true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
} as OpenClawConfig,
|
|
accountId: "default",
|
|
resolved: [
|
|
{
|
|
input: "OpenClaw/#triage",
|
|
resolved: true,
|
|
guildId: "guild-1",
|
|
channelId: "channel-1",
|
|
},
|
|
{
|
|
input: "missing",
|
|
resolved: false,
|
|
},
|
|
],
|
|
});
|
|
|
|
expect(next?.channels?.discord?.guilds?.["guild-1"]?.channels?.["channel-1"]).toEqual({
|
|
enabled: true,
|
|
});
|
|
expect(next?.channels?.discord?.guilds?.["*"]).toBeUndefined();
|
|
expect(next?.channels?.discord?.guilds?.existing?.channels?.keep).toEqual({
|
|
enabled: true,
|
|
});
|
|
});
|
|
});
|