test(refactor): dedupe preaction command coverage

This commit is contained in:
Peter Steinberger
2026-03-02 11:41:40 +00:00
parent 735216f7e4
commit 94e480f64a

View File

@@ -183,24 +183,21 @@ describe("registerPreActionHooks", () => {
expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledTimes(1); expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledTimes(1);
}); });
it("loads plugin registry for configure/onboard/agents commands", async () => { it("loads plugin registry for configure command", async () => {
const commands = ["configure", "onboard", "agents"] as const; const program = buildProgram(["configure"]);
const program = buildProgram(["configure", "onboard", "agents"]); await runCommand(
for (const command of commands) { {
vi.clearAllMocks(); parseArgv: ["configure"],
await runCommand( processArgv: ["node", "openclaw", "configure"],
{ },
parseArgv: [command], program,
processArgv: ["node", "openclaw", command], );
},
program, expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledTimes(1);
);
expect(ensurePluginRegistryLoadedMock, command).toHaveBeenCalledTimes(1);
}
}); });
it("skips config guard for doctor, completion, and secrets commands", async () => { it("skips config guard for doctor command", async () => {
const program = buildProgram(["doctor", "completion", "secrets"]); const program = buildProgram(["doctor"]);
await runCommand( await runCommand(
{ {
parseArgv: ["doctor"], parseArgv: ["doctor"],
@@ -208,20 +205,6 @@ describe("registerPreActionHooks", () => {
}, },
program, program,
); );
await runCommand(
{
parseArgv: ["completion"],
processArgv: ["node", "openclaw", "completion"],
},
program,
);
await runCommand(
{
parseArgv: ["secrets"],
processArgv: ["node", "openclaw", "secrets"],
},
program,
);
expect(ensureConfigReadyMock).not.toHaveBeenCalled(); expect(ensureConfigReadyMock).not.toHaveBeenCalled();
}); });