diff --git a/src/cli/program/register.maintenance.test.ts b/src/cli/program/register.maintenance.test.ts index af5c79781..192b11e13 100644 --- a/src/cli/program/register.maintenance.test.ts +++ b/src/cli/program/register.maintenance.test.ts @@ -73,4 +73,92 @@ describe("registerMaintenanceCommands doctor action", () => { expect(runtime.exit).toHaveBeenCalledWith(1); expect(runtime.exit).not.toHaveBeenCalledWith(0); }); + + it("maps --fix to repair=true", async () => { + doctorCommand.mockResolvedValue(undefined); + + await runMaintenanceCli(["doctor", "--fix"]); + + expect(doctorCommand).toHaveBeenCalledWith( + runtime, + expect.objectContaining({ + repair: true, + }), + ); + }); + + it("passes noOpen to dashboard command", async () => { + dashboardCommand.mockResolvedValue(undefined); + + await runMaintenanceCli(["dashboard", "--no-open"]); + + expect(dashboardCommand).toHaveBeenCalledWith( + runtime, + expect.objectContaining({ + noOpen: true, + }), + ); + }); + + it("passes reset options to reset command", async () => { + resetCommand.mockResolvedValue(undefined); + + await runMaintenanceCli([ + "reset", + "--scope", + "full", + "--yes", + "--non-interactive", + "--dry-run", + ]); + + expect(resetCommand).toHaveBeenCalledWith( + runtime, + expect.objectContaining({ + scope: "full", + yes: true, + nonInteractive: true, + dryRun: true, + }), + ); + }); + + it("passes uninstall options to uninstall command", async () => { + uninstallCommand.mockResolvedValue(undefined); + + await runMaintenanceCli([ + "uninstall", + "--service", + "--state", + "--workspace", + "--app", + "--all", + "--yes", + "--non-interactive", + "--dry-run", + ]); + + expect(uninstallCommand).toHaveBeenCalledWith( + runtime, + expect.objectContaining({ + service: true, + state: true, + workspace: true, + app: true, + all: true, + yes: true, + nonInteractive: true, + dryRun: true, + }), + ); + }); + + it("exits with code 1 when dashboard fails", async () => { + dashboardCommand.mockRejectedValue(new Error("dashboard failed")); + + await runMaintenanceCli(["dashboard"]); + + expect(runtime.error).toHaveBeenCalledWith("Error: dashboard failed"); + expect(runtime.exit).toHaveBeenCalledWith(1); + }); }); diff --git a/src/cli/program/register.maintenance.ts b/src/cli/program/register.maintenance.ts index 5aa668977..d8d05dd69 100644 --- a/src/cli/program/register.maintenance.ts +++ b/src/cli/program/register.maintenance.ts @@ -48,11 +48,11 @@ export function registerMaintenanceCommands(program: Command) { () => `\n${theme.muted("Docs:")} ${formatDocsLink("/cli/dashboard", "docs.openclaw.ai/cli/dashboard")}\n`, ) - .option("--no-open", "Print URL but do not launch a browser", false) + .option("--no-open", "Print URL but do not launch a browser") .action(async (opts) => { await runCommandWithRuntime(defaultRuntime, async () => { await dashboardCommand(defaultRuntime, { - noOpen: Boolean(opts.noOpen), + noOpen: opts.open === false, }); }); });