mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-08 15:51:06 +00:00
fix(plugins): preserve live hook registry during gateway runs
This commit is contained in:
52
src/agents/runtime-plugins.test.ts
Normal file
52
src/agents/runtime-plugins.test.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const hoisted = vi.hoisted(() => ({
|
||||
loadOpenClawPlugins: vi.fn(),
|
||||
getActivePluginRegistryKey: vi.fn<() => string | null>(),
|
||||
}));
|
||||
|
||||
vi.mock("../plugins/loader.js", () => ({
|
||||
loadOpenClawPlugins: hoisted.loadOpenClawPlugins,
|
||||
}));
|
||||
|
||||
vi.mock("../plugins/runtime.js", () => ({
|
||||
getActivePluginRegistryKey: hoisted.getActivePluginRegistryKey,
|
||||
}));
|
||||
|
||||
const { ensureRuntimePluginsLoaded } = await import("./runtime-plugins.js");
|
||||
|
||||
describe("ensureRuntimePluginsLoaded", () => {
|
||||
beforeEach(() => {
|
||||
hoisted.loadOpenClawPlugins.mockReset();
|
||||
hoisted.getActivePluginRegistryKey.mockReset();
|
||||
hoisted.getActivePluginRegistryKey.mockReturnValue(null);
|
||||
});
|
||||
|
||||
it("does not reactivate plugins when a process already has an active registry", () => {
|
||||
hoisted.getActivePluginRegistryKey.mockReturnValue("gateway-registry");
|
||||
|
||||
ensureRuntimePluginsLoaded({
|
||||
config: {} as never,
|
||||
workspaceDir: "/tmp/workspace",
|
||||
allowGatewaySubagentBinding: true,
|
||||
});
|
||||
|
||||
expect(hoisted.loadOpenClawPlugins).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("loads runtime plugins when no active registry exists", () => {
|
||||
ensureRuntimePluginsLoaded({
|
||||
config: {} as never,
|
||||
workspaceDir: "/tmp/workspace",
|
||||
allowGatewaySubagentBinding: true,
|
||||
});
|
||||
|
||||
expect(hoisted.loadOpenClawPlugins).toHaveBeenCalledWith({
|
||||
config: {} as never,
|
||||
workspaceDir: "/tmp/workspace",
|
||||
runtimeOptions: {
|
||||
allowGatewaySubagentBinding: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user