






















@@ -1,11 +1,13 @@
11import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
22import {
33createTestWizardPrompter,
4+runSetupWizardPrepare,
45runSetupWizardFinalize,
56} from "openclaw/plugin-sdk/plugin-test-runtime";
67import type { WizardPrompter } from "openclaw/plugin-sdk/plugin-test-runtime";
78import { describe, expect, it, vi } from "vitest";
89import { createSlackSetupWizardBase } from "./setup-core.js";
10+import { buildSlackSetupLines } from "./setup-shared.js";
9111012const slackSetupWizard = createSlackSetupWizardBase({
1113promptAllowFrom: async ({ cfg }) => cfg,
@@ -18,16 +20,16 @@ const slackSetupWizard = createSlackSetupWizardBase({
1820resolveGroupAllowlist: async ({ entries }) => entries,
1921});
202221-describe("slackSetupWizard.finalize", () => {
22-const baseCfg = {
23-channels: {
24-slack: {
25-botToken: "xoxb-test",
26-appToken: "xapp-test",
27-},
23+const baseCfg = {
24+channels: {
25+slack: {
26+botToken: "xoxb-test",
27+appToken: "xapp-test",
2828},
29-} as OpenClawConfig;
29+},
30+} as OpenClawConfig;
303132+describe("slackSetupWizard.finalize", () => {
3133it("prompts to enable interactive replies for newly configured Slack accounts", async () => {
3234const confirm = vi.fn(async () => true);
3335@@ -75,6 +77,53 @@ describe("slackSetupWizard.finalize", () => {
7577});
7678});
777980+describe("slackSetupWizard.prepare", () => {
81+it("keeps the manifest out of framed intro note lines", () => {
82+const lines = buildSlackSetupLines();
83+84+expect(lines.join("\n")).not.toContain("Manifest (JSON):");
85+expect(lines.join("\n")).not.toContain('"display_information"');
86+expect(lines).toContain("Manifest JSON follows as plain text for copy/paste.");
87+});
88+89+it("prints the manifest as plain JSON when Slack is not configured", async () => {
90+const plain = vi.fn<NonNullable<WizardPrompter["plain"]>>(async () => {});
91+const note = vi.fn(async () => {});
92+93+await runSetupWizardPrepare({
94+prepare: slackSetupWizard.prepare,
95+cfg: { channels: { slack: {} } } as OpenClawConfig,
96+prompter: createTestWizardPrompter({
97+ plain,
98+note: note as WizardPrompter["note"],
99+}),
100+});
101+102+expect(plain).toHaveBeenCalledTimes(1);
103+expect(note).not.toHaveBeenCalled();
104+const manifest = plain.mock.calls[0]?.[0];
105+expect(typeof manifest).toBe("string");
106+expect(JSON.parse(manifest)).toMatchObject({
107+display_information: { name: "OpenClaw" },
108+settings: { socket_mode_enabled: true },
109+});
110+});
111+112+it("does not print the manifest after Slack credentials are configured", async () => {
113+const plain = vi.fn<NonNullable<WizardPrompter["plain"]>>(async () => {});
114+115+await runSetupWizardPrepare({
116+prepare: slackSetupWizard.prepare,
117+cfg: baseCfg,
118+prompter: createTestWizardPrompter({
119+ plain,
120+}),
121+});
122+123+expect(plain).not.toHaveBeenCalled();
124+});
125+});
126+78127describe("slackSetupWizard.dmPolicy", () => {
79128it("reads the named-account DM policy instead of the channel root", () => {
80129expect(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。