test: dedupe plugin utility config suites

This commit is contained in:
Peter Steinberger
2026-03-28 04:43:20 +00:00
parent c9d5d12183
commit 25fea00bc7
6 changed files with 123 additions and 68 deletions

View File

@@ -54,6 +54,33 @@ function expectPluginLoaderConfig(config: OpenClawConfig) {
);
}
function createAutoEnabledCliFixture() {
const rawConfig = {
plugins: {},
channels: { demo: { enabled: true } },
} as OpenClawConfig;
const autoEnabledConfig = {
...rawConfig,
plugins: {
entries: {
demo: { enabled: true },
},
},
} as OpenClawConfig;
return { rawConfig, autoEnabledConfig };
}
function expectAutoEnabledCliLoad(params: {
rawConfig: OpenClawConfig;
autoEnabledConfig: OpenClawConfig;
}) {
expect(mocks.applyPluginAutoEnable).toHaveBeenCalledWith({
config: params.rawConfig,
env: process.env,
});
expectPluginLoaderConfig(params.autoEnabledConfig);
}
describe("registerPluginCliCommands", () => {
beforeEach(() => {
mocks.memoryRegister.mockClear();
@@ -89,27 +116,12 @@ describe("registerPluginCliCommands", () => {
it("loads plugin CLI commands from the auto-enabled config snapshot", () => {
const program = createProgram();
const rawConfig = {
plugins: {},
channels: { demo: { enabled: true } },
} as OpenClawConfig;
const autoEnabledConfig = {
...rawConfig,
plugins: {
entries: {
demo: { enabled: true },
},
},
} as OpenClawConfig;
const { rawConfig, autoEnabledConfig } = createAutoEnabledCliFixture();
mocks.applyPluginAutoEnable.mockReturnValue({ config: autoEnabledConfig, changes: [] });
registerPluginCliCommands(program, rawConfig);
expect(mocks.applyPluginAutoEnable).toHaveBeenCalledWith({
config: rawConfig,
env: process.env,
});
expectPluginLoaderConfig(autoEnabledConfig);
expectAutoEnabledCliLoad({ rawConfig, autoEnabledConfig });
expect(mocks.memoryRegister).toHaveBeenCalledWith(
expect.objectContaining({
config: autoEnabledConfig,