mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 07:10:43 +00:00
69 lines
2.3 KiB
TypeScript
69 lines
2.3 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import {
|
|
cleanupTempDirs,
|
|
expectPrivateQaLabRuntimeSurfaceLoad,
|
|
expectQaLabRuntimeSurfaceLoad,
|
|
restorePrivateQaCliEnv,
|
|
} from "./qa-runtime.test-helpers.js";
|
|
|
|
const loadBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());
|
|
const resolveOpenClawPackageRootSync = vi.hoisted(() => vi.fn());
|
|
|
|
vi.mock("./facade-runtime.js", () => ({
|
|
loadBundledPluginPublicSurfaceModuleSync,
|
|
}));
|
|
|
|
vi.mock("../infra/openclaw-root.js", () => ({
|
|
resolveOpenClawPackageRootSync,
|
|
}));
|
|
|
|
describe("plugin-sdk qa-runtime", () => {
|
|
const tempDirs: string[] = [];
|
|
const originalPrivateQaCli = process.env.OPENCLAW_ENABLE_PRIVATE_QA_CLI;
|
|
|
|
beforeEach(() => {
|
|
loadBundledPluginPublicSurfaceModuleSync.mockReset();
|
|
resolveOpenClawPackageRootSync.mockReset().mockReturnValue(null);
|
|
delete process.env.OPENCLAW_ENABLE_PRIVATE_QA_CLI;
|
|
});
|
|
|
|
afterEach(() => {
|
|
cleanupTempDirs(tempDirs);
|
|
restorePrivateQaCliEnv(originalPrivateQaCli);
|
|
});
|
|
|
|
it("stays cold until the runtime seam is used", async () => {
|
|
const module = await import("./qa-runtime.js");
|
|
|
|
expect(loadBundledPluginPublicSurfaceModuleSync).not.toHaveBeenCalled();
|
|
expect(typeof module.loadQaRuntimeModule).toBe("function");
|
|
expect(typeof module.isQaRuntimeAvailable).toBe("function");
|
|
});
|
|
|
|
it("loads the qa-lab runtime public surface through the generic seam", async () => {
|
|
await expectQaLabRuntimeSurfaceLoad({
|
|
importRuntime: () => import("./qa-runtime.js"),
|
|
loadBundledPluginPublicSurfaceModuleSync,
|
|
});
|
|
});
|
|
|
|
it("uses the source bundled tree for qa-lab runtime loading in private qa mode", async () => {
|
|
await expectPrivateQaLabRuntimeSurfaceLoad({
|
|
tempDirs,
|
|
importRuntime: () => import("./qa-runtime.js"),
|
|
loadBundledPluginPublicSurfaceModuleSync,
|
|
resolveOpenClawPackageRootSync,
|
|
});
|
|
});
|
|
|
|
it("reports the runtime as unavailable when the qa-lab surface is missing", async () => {
|
|
loadBundledPluginPublicSurfaceModuleSync.mockImplementation(() => {
|
|
throw new Error("Unable to resolve bundled plugin public surface qa-lab/runtime-api.js");
|
|
});
|
|
|
|
const module = await import("./qa-runtime.js");
|
|
|
|
expect(module.isQaRuntimeAvailable()).toBe(false);
|
|
});
|
|
});
|