mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-23 02:21:12 +00:00
63 lines
1.8 KiB
TypeScript
63 lines
1.8 KiB
TypeScript
// Covers plugin activation context construction and lazy boundaries.
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import {
|
|
createPluginMetadataSnapshot,
|
|
makeRegistry,
|
|
} from "../config/plugin-auto-enable.test-helpers.js";
|
|
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
|
import {
|
|
clearCurrentPluginMetadataSnapshot,
|
|
setCurrentPluginMetadataSnapshot,
|
|
} from "./current-plugin-metadata-snapshot.js";
|
|
|
|
const applyPluginAutoEnableMock = vi.hoisted(() =>
|
|
vi.fn((params: { config?: OpenClawConfig }) => ({
|
|
config: params.config,
|
|
changes: [],
|
|
autoEnabledReasons: {},
|
|
})),
|
|
);
|
|
|
|
vi.mock("../config/plugin-auto-enable.js", () => ({
|
|
applyPluginAutoEnable: applyPluginAutoEnableMock,
|
|
}));
|
|
|
|
import { resolveBundledPluginCompatibleActivationInputs } from "./activation-context.js";
|
|
|
|
afterEach(() => {
|
|
clearCurrentPluginMetadataSnapshot();
|
|
applyPluginAutoEnableMock.mockClear();
|
|
});
|
|
|
|
describe("resolveBundledPluginCompatibleActivationInputs", () => {
|
|
it("passes the current manifest registry into activation auto-enable", () => {
|
|
const manifestRegistry = makeRegistry([{ id: "openai", channels: [], providers: ["openai"] }]);
|
|
const workspaceDir = "/tmp/openclaw-activation-workspace";
|
|
setCurrentPluginMetadataSnapshot(
|
|
createPluginMetadataSnapshot({
|
|
config: {},
|
|
manifestRegistry,
|
|
workspaceDir,
|
|
}),
|
|
{
|
|
config: {},
|
|
workspaceDir,
|
|
},
|
|
);
|
|
|
|
resolveBundledPluginCompatibleActivationInputs({
|
|
rawConfig: { plugins: { allow: ["openai"] } },
|
|
workspaceDir,
|
|
applyAutoEnable: true,
|
|
compatMode: {},
|
|
resolveCompatPluginIds: () => [],
|
|
});
|
|
|
|
expect(applyPluginAutoEnableMock).toHaveBeenCalledWith({
|
|
config: { plugins: { allow: ["openai"] } },
|
|
env: process.env,
|
|
manifestRegistry,
|
|
});
|
|
});
|
|
});
|