test: fix stale web search and boot-md contracts
This commit is contained in:
parent
771fbeae79
commit
ce1d95454f
@ -5,12 +5,17 @@ import type { OpenClawConfig } from "../../../config/config.js";
|
|||||||
|
|
||||||
const runBootOnce = vi.fn();
|
const runBootOnce = vi.fn();
|
||||||
|
|
||||||
vi.mock("../../../gateway/boot.js", () => ({ runBootOnce }));
|
function createMockLogger() {
|
||||||
vi.mock("../../../logging/subsystem.js", () => ({
|
return {
|
||||||
createSubsystemLogger: () => ({
|
|
||||||
warn: vi.fn(),
|
warn: vi.fn(),
|
||||||
debug: vi.fn(),
|
debug: vi.fn(),
|
||||||
}),
|
child: vi.fn(() => createMockLogger()),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
vi.mock("../../../gateway/boot.js", () => ({ runBootOnce }));
|
||||||
|
vi.mock("../../../logging/subsystem.js", () => ({
|
||||||
|
createSubsystemLogger: () => createMockLogger(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const { default: runBootChecklist } = await import("./handler.js");
|
const { default: runBootChecklist } = await import("./handler.js");
|
||||||
|
|||||||
@ -10,16 +10,21 @@ const logDebug = vi.fn();
|
|||||||
const MAIN_WORKSPACE_DIR = path.join(path.sep, "ws", "main");
|
const MAIN_WORKSPACE_DIR = path.join(path.sep, "ws", "main");
|
||||||
const OPS_WORKSPACE_DIR = path.join(path.sep, "ws", "ops");
|
const OPS_WORKSPACE_DIR = path.join(path.sep, "ws", "ops");
|
||||||
|
|
||||||
|
function createMockLogger() {
|
||||||
|
return {
|
||||||
|
warn: logWarn,
|
||||||
|
debug: logDebug,
|
||||||
|
child: vi.fn(() => createMockLogger()),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
vi.mock("../../../gateway/boot.js", () => ({ runBootOnce }));
|
vi.mock("../../../gateway/boot.js", () => ({ runBootOnce }));
|
||||||
vi.mock("../../../agents/agent-scope.js", () => ({
|
vi.mock("../../../agents/agent-scope.js", () => ({
|
||||||
listAgentIds,
|
listAgentIds,
|
||||||
resolveAgentWorkspaceDir,
|
resolveAgentWorkspaceDir,
|
||||||
}));
|
}));
|
||||||
vi.mock("../../../logging/subsystem.js", () => ({
|
vi.mock("../../../logging/subsystem.js", () => ({
|
||||||
createSubsystemLogger: () => ({
|
createSubsystemLogger: () => createMockLogger(),
|
||||||
warn: logWarn,
|
|
||||||
debug: logDebug,
|
|
||||||
}),
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const { default: runBootChecklist } = await import("./handler.js");
|
const { default: runBootChecklist } = await import("./handler.js");
|
||||||
|
|||||||
@ -75,15 +75,12 @@ describe("plugin loader contract", () => {
|
|||||||
webSearchProviderContractRegistry.map((entry) => entry.pluginId),
|
webSearchProviderContractRegistry.map((entry) => entry.pluginId),
|
||||||
);
|
);
|
||||||
|
|
||||||
resolvePluginWebSearchProviders({});
|
const providers = resolvePluginWebSearchProviders({});
|
||||||
|
|
||||||
expect(loadOpenClawPluginsMock).toHaveBeenCalledWith(
|
expect(uniqueSortedPluginIds(providers.map((provider) => provider.pluginId))).toEqual(
|
||||||
expect.objectContaining({
|
webSearchPluginIds,
|
||||||
onlyPluginIds: webSearchPluginIds,
|
|
||||||
activate: false,
|
|
||||||
cache: false,
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
expect(loadOpenClawPluginsMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("keeps bundled web search allowlist compatibility wired to the web search registry", () => {
|
it("keeps bundled web search allowlist compatibility wired to the web search registry", () => {
|
||||||
@ -91,7 +88,7 @@ describe("plugin loader contract", () => {
|
|||||||
webSearchProviderContractRegistry.map((entry) => entry.pluginId),
|
webSearchProviderContractRegistry.map((entry) => entry.pluginId),
|
||||||
);
|
);
|
||||||
|
|
||||||
resolvePluginWebSearchProviders({
|
const providers = resolvePluginWebSearchProviders({
|
||||||
bundledAllowlistCompat: true,
|
bundledAllowlistCompat: true,
|
||||||
config: {
|
config: {
|
||||||
plugins: {
|
plugins: {
|
||||||
@ -100,15 +97,9 @@ describe("plugin loader contract", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(loadOpenClawPluginsMock).toHaveBeenCalledWith(
|
expect(uniqueSortedPluginIds(providers.map((provider) => provider.pluginId))).toEqual(
|
||||||
expect.objectContaining({
|
webSearchPluginIds,
|
||||||
config: expect.objectContaining({
|
|
||||||
plugins: expect.objectContaining({
|
|
||||||
allow: expect.arrayContaining(webSearchPluginIds),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
onlyPluginIds: webSearchPluginIds,
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
expect(loadOpenClawPluginsMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user