From 3c4cdf72c9cd496eeca34ce9294a6f50da3e4afa Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 1 Mar 2026 11:59:31 -0800 Subject: [PATCH] CLI routes: test conditional plugin preload behavior --- src/cli/program/routes.test.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/cli/program/routes.test.ts b/src/cli/program/routes.test.ts index 9442785b083..843c0257da4 100644 --- a/src/cli/program/routes.test.ts +++ b/src/cli/program/routes.test.ts @@ -13,9 +13,20 @@ describe("program routes", () => { await expect(route?.run(argv)).resolves.toBe(false); } - it("matches status route and preserves plugin loading", () => { + it("matches status route and loads plugins for human-readable output", () => { const route = expectRoute(["status"]); - expect(route?.loadPlugins).toBe(true); + expect(typeof route?.loadPlugins).toBe("function"); + const loadPlugins = route?.loadPlugins; + if (typeof loadPlugins !== "function") { + throw new Error("expected status route loadPlugins predicate"); + } + expect(loadPlugins(["node", "openclaw", "status"])).toBe(true); + expect(loadPlugins(["node", "openclaw", "status", "--json"])).toBe(false); + }); + + it("matches health route without eager plugin loading", () => { + const route = expectRoute(["health"]); + expect(route?.loadPlugins).toBeUndefined(); }); it("returns false when status timeout flag value is missing", async () => {