























@@ -32,14 +32,15 @@ describe("plugins cli policy mutations", () => {
3232}
33333434it("refreshes the persisted plugin registry after enabling a plugin", async () => {
35+const sourceConfig = {} as OpenClawConfig;
3536const enabledConfig = {
3637plugins: {
3738entries: {
3839alpha: { enabled: true },
3940},
4041},
4142} as OpenClawConfig;
42-loadConfig.mockReturnValue({} as OpenClawConfig);
43+loadConfig.mockReturnValue(sourceConfig);
4344enablePluginInConfig.mockReturnValue({
4445config: enabledConfig,
4546enabled: true,
@@ -49,6 +50,9 @@ describe("plugins cli policy mutations", () => {
49505051await runPluginsCommand(["plugins", "enable", "alpha"]);
515253+expect(enablePluginInConfig).toHaveBeenCalledWith(sourceConfig, "alpha", {
54+updateChannelConfig: false,
55+});
5256expect(writeConfigFile).toHaveBeenCalledWith(enabledConfig);
5357expect(refreshPluginRegistry).toHaveBeenCalledWith({
5458config: enabledConfig,
@@ -100,7 +104,9 @@ describe("plugins cli policy mutations", () => {
100104101105await runPluginsCommand(["plugins", "enable", alias]);
102106103-expect(enablePluginInConfig).toHaveBeenCalledWith(sourceConfig, pluginId);
107+expect(enablePluginInConfig).toHaveBeenCalledWith(sourceConfig, pluginId, {
108+updateChannelConfig: false,
109+});
104110expect(writeConfigFile).toHaveBeenCalledWith(enabledConfig);
105111},
106112);
@@ -142,4 +148,15 @@ describe("plugins cli policy mutations", () => {
142148expect(refreshPluginRegistry).not.toHaveBeenCalled();
143149},
144150);
151+152+it("does not create a channel config when disabling a channel plugin by policy", async () => {
153+loadConfig.mockReturnValue({} as OpenClawConfig);
154+mockPluginRegistry(["twitch"]);
155+156+await runPluginsCommand(["plugins", "disable", "twitch"]);
157+158+const nextConfig = writeConfigFile.mock.calls[0]?.[0] as OpenClawConfig;
159+expect(nextConfig.plugins?.entries?.twitch?.enabled).toBe(false);
160+expect(nextConfig.channels?.twitch).toBeUndefined();
161+});
145162});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。