Files
openclaw-zero-token/plugins/cli.browser-plugin.integration.test.ts
sjhu 571e14a236 feat: upgrade to upstream v2026.3.28
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
2026-03-30 17:58:12 +08:00

69 lines
2.1 KiB
TypeScript

import path from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createBundledBrowserPluginFixture } from "../../test/helpers/browser-bundled-plugin-fixture.js";
import type { OpenClawConfig } from "../config/config.js";
import { clearPluginDiscoveryCache } from "./discovery.js";
import { clearPluginLoaderCache, loadOpenClawPlugins } from "./loader.js";
import { clearPluginManifestRegistryCache } from "./manifest-registry.js";
import { resetPluginRuntimeStateForTest } from "./runtime.js";
function resetPluginState() {
clearPluginLoaderCache();
clearPluginDiscoveryCache();
clearPluginManifestRegistryCache();
resetPluginRuntimeStateForTest();
}
describe("registerPluginCliCommands browser plugin integration", () => {
let bundledFixture: ReturnType<typeof createBundledBrowserPluginFixture> | null = null;
beforeEach(() => {
bundledFixture = createBundledBrowserPluginFixture();
vi.stubEnv("OPENCLAW_BUNDLED_PLUGINS_DIR", bundledFixture.rootDir);
resetPluginState();
});
afterEach(() => {
resetPluginState();
vi.unstubAllEnvs();
bundledFixture?.cleanup();
bundledFixture = null;
});
it("registers the browser command from the bundled browser plugin", () => {
const registry = loadOpenClawPlugins({
config: {
plugins: {
allow: ["browser"],
},
} as OpenClawConfig,
cache: false,
env: {
...process.env,
OPENCLAW_BUNDLED_PLUGINS_DIR:
bundledFixture?.rootDir ?? path.join(process.cwd(), "extensions"),
} as NodeJS.ProcessEnv,
});
expect(registry.cliRegistrars.flatMap((entry) => entry.commands)).toContain("browser");
});
it("omits the browser command when the bundled browser plugin is disabled", () => {
const registry = loadOpenClawPlugins({
config: {
plugins: {
allow: ["browser"],
entries: {
browser: {
enabled: false,
},
},
},
} as OpenClawConfig,
cache: false,
});
expect(registry.cliRegistrars.flatMap((entry) => entry.commands)).not.toContain("browser");
});
});