fix: stabilize plugin-sdk test loading

This commit is contained in:
Peter Steinberger
2026-03-27 13:14:11 +00:00
parent 9d10a2e242
commit b5a8d5a230
10 changed files with 524 additions and 104 deletions

View File

@@ -1,11 +1,14 @@
import { Command } from "commander";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { afterAll, afterEach, beforeEach, describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { registerPluginCliCommands } from "./cli.js";
import { clearPluginLoaderCache } from "./loader.js";
import { clearPluginManifestRegistryCache } from "./manifest-registry.js";
import { resetPluginRuntimeStateForTest } from "./runtime.js";
const previousPreferDistPluginSdk = process.env.OPENCLAW_PLUGIN_SDK_PREFER_DIST;
process.env.OPENCLAW_PLUGIN_SDK_PREFER_DIST = "1";
function resetPluginState() {
clearPluginLoaderCache();
clearPluginManifestRegistryCache();
@@ -21,6 +24,14 @@ describe("registerPluginCliCommands browser plugin integration", () => {
resetPluginState();
});
afterAll(() => {
if (previousPreferDistPluginSdk === undefined) {
delete process.env.OPENCLAW_PLUGIN_SDK_PREFER_DIST;
} else {
process.env.OPENCLAW_PLUGIN_SDK_PREFER_DIST = previousPreferDistPluginSdk;
}
});
it("registers the browser command from the bundled browser plugin", () => {
const program = new Command();
registerPluginCliCommands(program, {