openclaw/extensions/plugin-entry.cli-laziness.test.ts
Ben.Li bee32f9ec7
fix(plugins): avoid loading CLI-only code at startup (#133105)
* fix(plugins): keep CLI runtimes lazy

* test(plugins): exercise deferred CLI registration

Keep one cold-entry table and await captured voice-call registration
after plugin setup, matching the shared loader lifecycle.

Co-authored-by: ben.li <li.yang6@xydigit.com>

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
Co-authored-by: ben.li <li.yang6@xydigit.com>
2026-08-31 22:29:05 -07:00

23 lines
826 B
TypeScript

import { expect, it, vi } from "vitest";
vi.mock("./memory-wiki/src/cli.js", () => {
throw new Error("memory-wiki CLI eagerly imported");
});
vi.mock("./policy/src/cli.js", () => {
throw new Error("policy CLI eagerly imported");
});
vi.mock("./qa-lab/src/cli.js", () => {
throw new Error("qa-lab CLI eagerly imported");
});
vi.mock("./voice-call/src/cli.js", () => {
throw new Error("voice-call CLI eagerly imported");
});
it.each([
{ id: "memory-wiki", load: () => import("./memory-wiki/index.js") },
{ id: "policy", load: () => import("./policy/index.js") },
{ id: "qa-lab", load: () => import("./qa-lab/index.js") },
{ id: "voice-call", load: () => import("./voice-call/index.js") },
])("imports $id without evaluating its CLI", async ({ id, load }) => {
expect((await load()).default.id).toBe(id);
});