From 87bd6226bd2d5e5ff49626633a8ad75823e5151d Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 2 Mar 2026 14:52:30 +0000 Subject: [PATCH] test(perf): merge overlapping preaction hook scenarios --- src/cli/program/preaction.test.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/cli/program/preaction.test.ts b/src/cli/program/preaction.test.ts index 30987fff1..b2fded5ed 100644 --- a/src/cli/program/preaction.test.ts +++ b/src/cli/program/preaction.test.ts @@ -128,7 +128,7 @@ describe("registerPreActionHooks", () => { await preActionHook(program, actionCommand); } - it("emits banner, resolves config, and enables verbose from --debug", async () => { + it("handles debug mode and plugin-required command preaction", async () => { await runPreAction({ parseArgv: ["status"], processArgv: ["node", "openclaw", "status", "--debug"], @@ -142,9 +142,8 @@ describe("registerPreActionHooks", () => { }); expect(ensurePluginRegistryLoadedMock).not.toHaveBeenCalled(); expect(process.title).toBe("openclaw-status"); - }); - it("loads plugin registry for plugin-required commands", async () => { + vi.clearAllMocks(); await runPreAction({ parseArgv: ["message", "send"], processArgv: ["node", "openclaw", "message", "send"], @@ -159,7 +158,7 @@ describe("registerPreActionHooks", () => { expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledTimes(1); }); - it("skips preaction work when argv indicates help/version", async () => { + it("skips help/version preaction and respects banner opt-out", async () => { await runPreAction({ parseArgv: ["status"], processArgv: ["node", "openclaw", "--version"], @@ -168,10 +167,10 @@ describe("registerPreActionHooks", () => { expect(emitCliBannerMock).not.toHaveBeenCalled(); expect(setVerboseMock).not.toHaveBeenCalled(); expect(ensureConfigReadyMock).not.toHaveBeenCalled(); - }); - it("hides banner when OPENCLAW_HIDE_BANNER is truthy", async () => { + vi.clearAllMocks(); process.env.OPENCLAW_HIDE_BANNER = "1"; + await runPreAction({ parseArgv: ["status"], processArgv: ["node", "openclaw", "status"], @@ -181,7 +180,7 @@ describe("registerPreActionHooks", () => { expect(ensureConfigReadyMock).toHaveBeenCalledTimes(1); }); - it("suppresses doctor stdout for --json output command", async () => { + it("applies --json stdout suppression only for explicit JSON output commands", async () => { await runPreAction({ parseArgv: ["update", "status", "--json"], processArgv: ["node", "openclaw", "update", "status", "--json"], @@ -192,9 +191,8 @@ describe("registerPreActionHooks", () => { commandPath: ["update", "status"], suppressDoctorStdout: true, }); - }); - it("does not treat config set --json (strict-parse alias) as json output mode", async () => { + vi.clearAllMocks(); await runPreAction({ parseArgv: ["config", "set", "gateway.auth.mode", "{bad", "--json"], processArgv: ["node", "openclaw", "config", "set", "gateway.auth.mode", "{bad", "--json"],