mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 04:20:43 +00:00
fix(cli): trim plugin preloads for setup-safe commands
This commit is contained in:
@@ -13,6 +13,7 @@ vi.mock("../../../globals.js", () => ({
|
||||
vi.mock("../../plugin-registry.js", () => ({
|
||||
ensurePluginRegistryLoaded: vi.fn(),
|
||||
}));
|
||||
const { ensurePluginRegistryLoaded } = await import("../../plugin-registry.js");
|
||||
|
||||
const hasHooksMock = vi.fn((_hookName: string) => false);
|
||||
const runGatewayStopMock = vi.fn(
|
||||
@@ -95,6 +96,7 @@ describe("runMessageAction", () => {
|
||||
it("calls exit(0) after successful message delivery", async () => {
|
||||
await runSendAction();
|
||||
|
||||
expect(ensurePluginRegistryLoaded).toHaveBeenCalledOnce();
|
||||
expect(exitMock).toHaveBeenCalledOnce();
|
||||
expect(exitMock).toHaveBeenCalledWith(0);
|
||||
});
|
||||
|
||||
@@ -122,6 +122,7 @@ describe("registerPreActionHooks", () => {
|
||||
.command("agent")
|
||||
.requiredOption("-m, --message <text>")
|
||||
.option("--local")
|
||||
.option("--json")
|
||||
.action(() => {});
|
||||
program
|
||||
.command("status")
|
||||
@@ -214,15 +215,15 @@ describe("registerPreActionHooks", () => {
|
||||
|
||||
vi.clearAllMocks();
|
||||
await runPreAction({
|
||||
parseArgv: ["message", "send"],
|
||||
processArgv: ["node", "openclaw", "message", "send"],
|
||||
parseArgv: ["agents", "list"],
|
||||
processArgv: ["node", "openclaw", "agents", "list"],
|
||||
});
|
||||
|
||||
expect(setVerboseMock).toHaveBeenCalledWith(false);
|
||||
expect(process.env.NODE_NO_WARNINGS).toBe("1");
|
||||
expect(ensureConfigReadyMock).toHaveBeenCalledWith({
|
||||
runtime: runtimeMock,
|
||||
commandPath: ["message", "send"],
|
||||
commandPath: ["agents", "list"],
|
||||
});
|
||||
expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledWith({ scope: "all" });
|
||||
processTitleSetSpy.mockRestore();
|
||||
@@ -393,8 +394,8 @@ describe("registerPreActionHooks", () => {
|
||||
|
||||
it("routes logs to stderr in --json mode so stdout stays clean", async () => {
|
||||
await runPreAction({
|
||||
parseArgv: ["message", "send"],
|
||||
processArgv: ["node", "openclaw", "message", "send", "--json"],
|
||||
parseArgv: ["agent"],
|
||||
processArgv: ["node", "openclaw", "agent", "--message", "hi", "--json"],
|
||||
});
|
||||
|
||||
expect(routeLogsToStderrMock).toHaveBeenCalledOnce();
|
||||
@@ -473,8 +474,8 @@ describe("registerPreActionHooks", () => {
|
||||
});
|
||||
|
||||
await runPreAction({
|
||||
parseArgv: ["message", "send"],
|
||||
processArgv: ["node", "openclaw", "message", "send", "--json"],
|
||||
parseArgv: ["agent"],
|
||||
processArgv: ["node", "openclaw", "agent", "--message", "hi", "--json"],
|
||||
});
|
||||
|
||||
expect(ensurePluginRegistryLoadedMock).toHaveBeenCalled();
|
||||
|
||||
Reference in New Issue
Block a user