






















@@ -26,7 +26,7 @@ vi.mock("../commands/doctor/shared/channel-doctor.js", () => ({
2626collectChannelDoctorStaleConfigMutationsMock(cfg),
2727}));
282829-const MATRIX_REPO_INSTALL_SPEC = repoInstallSpec("matrix");
29+const DISCORD_REPO_INSTALL_SPEC = repoInstallSpec("discord");
30303131function makeSnapshot(overrides: Partial<ConfigFileSnapshot> = {}): ConfigFileSnapshot {
3232return {
@@ -40,18 +40,18 @@ function makeSnapshot(overrides: Partial<ConfigFileSnapshot> = {}): ConfigFileSn
4040runtimeConfig: { plugins: {} } as ConfigFileSnapshot["runtimeConfig"],
4141config: { plugins: {} } as OpenClawConfig,
4242hash: "abc",
43-issues: [{ path: "plugins.installs.matrix", message: "stale path" }],
43+issues: [{ path: "plugins.installs.discord", message: "stale path" }],
4444warnings: [],
4545legacyIssues: [],
4646 ...overrides,
4747};
4848}
49495050describe("loadConfigForInstall", () => {
51-const matrixNpmRequest = {
52-rawSpec: "@openclaw/matrix",
53-normalizedSpec: "@openclaw/matrix",
54-bundledPluginId: "matrix",
51+const discordNpmRequest = {
52+rawSpec: "@openclaw/discord",
53+normalizedSpec: "@openclaw/discord",
54+bundledPluginId: "discord",
5555allowInvalidConfigRecovery: true,
5656} satisfies PluginInstallRequestContext;
5757@@ -68,22 +68,22 @@ describe("loadConfigForInstall", () => {
6868});
69697070it("returns the source config and base hash when the snapshot is valid", async () => {
71-const cfg = { plugins: { entries: { matrix: { enabled: true } } } } as OpenClawConfig;
71+const cfg = { plugins: { entries: { discord: { enabled: true } } } } as OpenClawConfig;
7272readConfigFileSnapshotMock.mockResolvedValue(
7373makeSnapshot({
7474valid: true,
7575sourceConfig: cfg,
76-config: { plugins: { entries: { matrix: { enabled: true } }, enabled: true } },
76+config: { plugins: { entries: { discord: { enabled: true } }, enabled: true } },
7777hash: "config-1",
7878issues: [],
7979}),
8080);
818182-const result = await loadConfigForInstall(matrixNpmRequest);
82+const result = await loadConfigForInstall(discordNpmRequest);
8383expect(result).toEqual({ config: cfg, baseHash: "config-1" });
8484});
858586-it("does not run stale Matrix cleanup on the happy path", async () => {
86+it("does not run stale Discord cleanup on the happy path", async () => {
8787const cfg = { plugins: {} } as OpenClawConfig;
8888readConfigFileSnapshotMock.mockResolvedValue(
8989makeSnapshot({
@@ -94,56 +94,56 @@ describe("loadConfigForInstall", () => {
9494}),
9595);
969697-const result = await loadConfigForInstall(matrixNpmRequest);
97+const result = await loadConfigForInstall(discordNpmRequest);
9898expect(collectChannelDoctorStaleConfigMutationsMock).not.toHaveBeenCalled();
9999expect(result.config).toBe(cfg);
100100});
101101102102it("falls back to snapshot config for explicit bundled-plugin reinstall when issues match the known upgrade failure", async () => {
103103const snapshotCfg = {
104-plugins: { installs: { matrix: { source: "path", installPath: "/gone" } } },
104+plugins: { installs: { discord: { source: "path", installPath: "/gone" } } },
105105} as unknown as OpenClawConfig;
106106readConfigFileSnapshotMock.mockResolvedValue(
107107makeSnapshot({
108-parsed: { plugins: { installs: { matrix: {} } } },
108+parsed: { plugins: { installs: { discord: {} } } },
109109config: snapshotCfg,
110110issues: [
111-{ path: "channels.matrix", message: "unknown channel id: matrix" },
111+{ path: "channels.discord", message: "unknown channel id: discord" },
112112{ path: "plugins.load.paths", message: "plugin: plugin path not found: /gone" },
113113],
114114}),
115115);
116116117-const result = await loadConfigForInstall(matrixNpmRequest);
117+const result = await loadConfigForInstall(discordNpmRequest);
118118expect(readConfigFileSnapshotMock).toHaveBeenCalled();
119119expect(collectChannelDoctorStaleConfigMutationsMock).toHaveBeenCalledWith(snapshotCfg);
120120expect(result).toEqual({ config: snapshotCfg, baseHash: "abc" });
121121});
122122123123it("allows npm:-prefixed bundled-plugin reinstall recovery", async () => {
124124const snapshotCfg = {
125-plugins: { installs: { matrix: { source: "path", installPath: "/gone" } } },
125+plugins: { installs: { discord: { source: "path", installPath: "/gone" } } },
126126} as unknown as OpenClawConfig;
127127readConfigFileSnapshotMock.mockResolvedValue(
128128makeSnapshot({
129-parsed: { plugins: { installs: { matrix: {} } } },
129+parsed: { plugins: { installs: { discord: {} } } },
130130config: snapshotCfg,
131131issues: [
132-{ path: "channels.matrix", message: "unknown channel id: matrix" },
132+{ path: "channels.discord", message: "unknown channel id: discord" },
133133{ path: "plugins.load.paths", message: "plugin: plugin path not found: /gone" },
134134],
135135}),
136136);
137137138138const request = resolvePluginInstallRequestContext({
139-rawSpec: "npm:@openclaw/matrix",
139+rawSpec: "npm:@openclaw/discord",
140140});
141141if (!request.ok) {
142142throw new Error(request.error);
143143}
144144145145expect(request.request).toMatchObject({
146-bundledPluginId: "matrix",
146+bundledPluginId: "discord",
147147allowInvalidConfigRecovery: true,
148148});
149149const result = await loadConfigForInstall(request.request);
@@ -156,20 +156,20 @@ describe("loadConfigForInstall", () => {
156156readConfigFileSnapshotMock.mockResolvedValue(
157157makeSnapshot({
158158config: snapshotCfg,
159-issues: [{ path: "channels.matrix", message: "unknown channel id: matrix" }],
159+issues: [{ path: "channels.discord", message: "unknown channel id: discord" }],
160160}),
161161);
162162163163const repoRequest = resolvePluginInstallRequestContext({
164-rawSpec: MATRIX_REPO_INSTALL_SPEC,
164+rawSpec: DISCORD_REPO_INSTALL_SPEC,
165165});
166166if (!repoRequest.ok) {
167167throw new Error(repoRequest.error);
168168}
169169170170const result = await loadConfigForInstall({
171171 ...repoRequest.request,
172-resolvedPath: bundledPluginRootAt("/tmp/repo", "matrix"),
172+resolvedPath: bundledPluginRootAt("/tmp/repo", "discord"),
173173});
174174expect(result.config).toBe(snapshotCfg);
175175});
@@ -181,12 +181,12 @@ describe("loadConfigForInstall", () => {
181181}),
182182);
183183184-await expect(loadConfigForInstall(matrixNpmRequest)).rejects.toThrow(
185-"Config invalid outside the bundled recovery path for matrix",
184+await expect(loadConfigForInstall(discordNpmRequest)).rejects.toThrow(
185+"Config invalid outside the bundled recovery path for discord",
186186);
187187});
188188189-it("rejects non-Matrix install requests when config is invalid", async () => {
189+it("rejects non-Discord install requests when config is invalid", async () => {
190190readConfigFileSnapshotMock.mockResolvedValue(makeSnapshot());
191191192192await expect(
@@ -205,15 +205,15 @@ describe("loadConfigForInstall", () => {
205205}),
206206);
207207208-await expect(loadConfigForInstall(matrixNpmRequest)).rejects.toThrow(
208+await expect(loadConfigForInstall(discordNpmRequest)).rejects.toThrow(
209209"Config file could not be parsed; run `openclaw doctor` to repair it.",
210210);
211211});
212212213213it("throws when invalid snapshot config file does not exist", async () => {
214214readConfigFileSnapshotMock.mockResolvedValue(makeSnapshot({ exists: false, parsed: {} }));
215215216-await expect(loadConfigForInstall(matrixNpmRequest)).rejects.toThrow(
216+await expect(loadConfigForInstall(discordNpmRequest)).rejects.toThrow(
217217"Config file could not be parsed; run `openclaw doctor` to repair it.",
218218);
219219});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。