mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 15:30:44 +00:00
fix(plugins): preserve source activation config
This commit is contained in:
@@ -12,6 +12,8 @@ const resolveDefaultAgentIdMock = vi.fn<
|
||||
|
||||
let resolvePluginRuntimeLoadContext: typeof import("./load-context.js").resolvePluginRuntimeLoadContext;
|
||||
let buildPluginRuntimeLoadOptions: typeof import("./load-context.js").buildPluginRuntimeLoadOptions;
|
||||
let clearRuntimeConfigSnapshot: typeof import("../../config/runtime-snapshot.js").clearRuntimeConfigSnapshot;
|
||||
let setRuntimeConfigSnapshot: typeof import("../../config/runtime-snapshot.js").setRuntimeConfigSnapshot;
|
||||
|
||||
vi.mock("../../config/config.js", () => ({
|
||||
loadConfig: loadConfigMock,
|
||||
@@ -29,6 +31,8 @@ vi.mock("../../agents/agent-scope.js", () => ({
|
||||
describe("resolvePluginRuntimeLoadContext", () => {
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
({ clearRuntimeConfigSnapshot, setRuntimeConfigSnapshot } =
|
||||
await import("../../config/runtime-snapshot.js"));
|
||||
({ resolvePluginRuntimeLoadContext, buildPluginRuntimeLoadOptions } =
|
||||
await import("./load-context.js"));
|
||||
loadConfigMock.mockReset();
|
||||
@@ -42,6 +46,7 @@ describe("resolvePluginRuntimeLoadContext", () => {
|
||||
changes: [],
|
||||
autoEnabledReasons: {},
|
||||
}));
|
||||
clearRuntimeConfigSnapshot();
|
||||
});
|
||||
|
||||
it("builds the runtime plugin load context from the auto-enabled config", () => {
|
||||
@@ -88,6 +93,27 @@ describe("resolvePluginRuntimeLoadContext", () => {
|
||||
expect(resolveAgentWorkspaceDirMock).toHaveBeenCalledWith(resolvedConfig, "default");
|
||||
});
|
||||
|
||||
it("uses the source runtime snapshot for plugin activation source config", () => {
|
||||
const runtimeConfig = { plugins: {} };
|
||||
const sourceConfig = {
|
||||
plugins: {
|
||||
allow: ["trusted-plugin"],
|
||||
},
|
||||
};
|
||||
|
||||
setRuntimeConfigSnapshot(runtimeConfig, sourceConfig);
|
||||
loadConfigMock.mockReturnValue(runtimeConfig);
|
||||
|
||||
const context = resolvePluginRuntimeLoadContext();
|
||||
|
||||
expect(context.rawConfig).toBe(runtimeConfig);
|
||||
expect(context.activationSourceConfig).toBe(sourceConfig);
|
||||
expect(applyPluginAutoEnableMock).toHaveBeenCalledWith({
|
||||
config: runtimeConfig,
|
||||
env: process.env,
|
||||
});
|
||||
});
|
||||
|
||||
it("builds plugin load options from the shared runtime context", () => {
|
||||
const context = resolvePluginRuntimeLoadContext({
|
||||
config: { plugins: {} },
|
||||
|
||||
Reference in New Issue
Block a user