mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 07:40:42 +00:00
test: tighten plugin loader empty array assertions
This commit is contained in:
@@ -1929,7 +1929,7 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
onlyPluginIds: [],
|
||||
});
|
||||
|
||||
expect(registry.plugins).toEqual([]);
|
||||
expect(registry.plugins).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it("skips discovery and manifest registry loading entirely when onlyPluginIds is an explicit empty array", async () => {
|
||||
@@ -1957,7 +1957,7 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
onlyPluginIds: [],
|
||||
});
|
||||
|
||||
expect(registry.plugins).toEqual([]);
|
||||
expect(registry.plugins).toStrictEqual([]);
|
||||
expect(discoverySpy).not.toHaveBeenCalled();
|
||||
expect(manifestSpy).not.toHaveBeenCalled();
|
||||
|
||||
@@ -1999,7 +1999,7 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
|
||||
expect(scoped.plugins.find((entry) => entry.id === "command-plugin")?.status).toBe("loaded");
|
||||
expect(scoped.commands.map((entry) => entry.command.name)).toEqual(["pair"]);
|
||||
expect(getPluginCommandSpecs("telegram")).toEqual([]);
|
||||
expect(getPluginCommandSpecs("telegram")).toStrictEqual([]);
|
||||
|
||||
const active = loadOpenClawPlugins({
|
||||
cache: false,
|
||||
@@ -2065,7 +2065,7 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(listAgentHarnessIds()).toEqual([]);
|
||||
expect(listAgentHarnessIds()).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it("rejects malformed plugin agent harness registrations", () => {
|
||||
@@ -2096,7 +2096,7 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
onlyPluginIds: ["bad-harness"],
|
||||
});
|
||||
|
||||
expect(listAgentHarnessIds()).toEqual([]);
|
||||
expect(listAgentHarnessIds()).toStrictEqual([]);
|
||||
expect(registry.diagnostics).toContainEqual(
|
||||
expect.objectContaining({
|
||||
level: "error",
|
||||
@@ -2137,7 +2137,7 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
"loaded",
|
||||
);
|
||||
expect(scoped.hooks.map((entry) => entry.entry.hook.name)).toEqual(["snapshot-hook"]);
|
||||
expect(getRegisteredEventKeys()).toEqual([]);
|
||||
expect(getRegisteredEventKeys()).toStrictEqual([]);
|
||||
|
||||
clearInternalHooks();
|
||||
});
|
||||
@@ -2315,19 +2315,19 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
expect(registry.plugins.find((entry) => entry.id === "failing-side-effects")?.status).toBe(
|
||||
"error",
|
||||
);
|
||||
expect(getRegisteredEventKeys()).toEqual([]);
|
||||
expect(getPluginCommandSpecs()).toEqual([]);
|
||||
expect(registry.reloads).toEqual([]);
|
||||
expect(registry.nodeHostCommands).toEqual([]);
|
||||
expect(registry.nodeInvokePolicies).toEqual([]);
|
||||
expect(registry.securityAuditCollectors).toEqual([]);
|
||||
expect(getRegisteredEventKeys()).toStrictEqual([]);
|
||||
expect(getPluginCommandSpecs()).toStrictEqual([]);
|
||||
expect(registry.reloads).toStrictEqual([]);
|
||||
expect(registry.nodeHostCommands).toStrictEqual([]);
|
||||
expect(registry.nodeInvokePolicies).toStrictEqual([]);
|
||||
expect(registry.securityAuditCollectors).toStrictEqual([]);
|
||||
expect(resolvePluginInteractiveNamespaceMatch("slack", "failme:payload")).toBeNull();
|
||||
expect(getContextEngineFactory("failme-context")).toBeUndefined();
|
||||
expect(listContextEngineIds()).not.toContain("failme-context");
|
||||
|
||||
const event = createInternalHookEvent("gateway", "startup", "gateway:startup");
|
||||
await triggerInternalHook(event);
|
||||
expect(event.messages).toEqual([]);
|
||||
expect(event.messages).toStrictEqual([]);
|
||||
|
||||
clearInternalHooks();
|
||||
clearPluginCommands();
|
||||
@@ -2365,8 +2365,8 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
expect(record?.status).toBe("error");
|
||||
expect(record?.failurePhase).toBe("register");
|
||||
expect(record?.error).toContain("hook registration missing name");
|
||||
expect(registry.hooks).toEqual([]);
|
||||
expect(getRegisteredEventKeys()).toEqual([]);
|
||||
expect(registry.hooks).toStrictEqual([]);
|
||||
expect(getRegisteredEventKeys()).toStrictEqual([]);
|
||||
expectDiagnosticContaining({
|
||||
registry,
|
||||
level: "error",
|
||||
@@ -2633,11 +2633,11 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
});
|
||||
|
||||
expect(registry.plugins.find((entry) => entry.id === "failing-memory")?.status).toBe("error");
|
||||
expect(buildMemoryPromptSection({ availableTools: new Set() })).toEqual([]);
|
||||
expect(listMemoryCorpusSupplements()).toEqual([]);
|
||||
expect(buildMemoryPromptSection({ availableTools: new Set() })).toStrictEqual([]);
|
||||
expect(listMemoryCorpusSupplements()).toStrictEqual([]);
|
||||
expect(resolveMemoryFlushPlan({})).toBeNull();
|
||||
expect(getMemoryRuntime()).toBeUndefined();
|
||||
expect(listMemoryEmbeddingProviders()).toEqual([]);
|
||||
expect(listMemoryEmbeddingProviders()).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it("does not replace the active detached task runtime during non-activating loads", () => {
|
||||
@@ -2827,7 +2827,7 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
|
||||
clearPluginCommands();
|
||||
clearPluginInteractiveHandlerRegistrations();
|
||||
expect(getPluginCommandSpecs()).toEqual([]);
|
||||
expect(getPluginCommandSpecs()).toStrictEqual([]);
|
||||
expect(resolvePluginInteractiveNamespaceMatch("telegram", "hue:on")).toBeNull();
|
||||
|
||||
loadOpenClawPlugins(loadOptions);
|
||||
@@ -3088,7 +3088,7 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
},
|
||||
});
|
||||
|
||||
expect(registry.tools).toEqual([]);
|
||||
expect(registry.tools).toStrictEqual([]);
|
||||
expect(registry.diagnostics).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
@@ -3130,7 +3130,7 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
},
|
||||
});
|
||||
|
||||
expect(registry.tools).toEqual([]);
|
||||
expect(registry.tools).toStrictEqual([]);
|
||||
expect(registry.diagnostics).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
@@ -3178,7 +3178,7 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
expect(second).toBe(first);
|
||||
expect((globalThis as Record<string, unknown>)[marker]).toBe(1);
|
||||
expect(first.commands.map((entry) => entry.command.name)).toEqual(["snapshot-command"]);
|
||||
expect(getPluginCommandSpecs()).toEqual([]);
|
||||
expect(getPluginCommandSpecs()).toStrictEqual([]);
|
||||
|
||||
const active = loadOpenClawPlugins({
|
||||
workspaceDir: plugin.dir,
|
||||
@@ -4081,7 +4081,7 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
pluginId: "memory-prompt-supplement-malformed",
|
||||
message: "memory prompt supplement registration missing builder",
|
||||
});
|
||||
expect(listMemoryPromptSupplements()).toEqual([]);
|
||||
expect(listMemoryPromptSupplements()).toStrictEqual([]);
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -4315,7 +4315,7 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
expect(record?.gatewayDiscoveryServiceIds).toEqual(["shared-service"]);
|
||||
expect(registry.services).toHaveLength(1);
|
||||
expect(registry.gatewayDiscoveryServices).toHaveLength(1);
|
||||
expect(registry.diagnostics).toEqual([]);
|
||||
expect(registry.diagnostics).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it("rewrites removed registerHttpHandler failures into migration diagnostics", () => {
|
||||
@@ -4418,7 +4418,7 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
);
|
||||
expect(routes).toHaveLength(1);
|
||||
expect(routes[0]?.path).toBe("/demo");
|
||||
expect(registry.diagnostics).toEqual([]);
|
||||
expect(registry.diagnostics).toStrictEqual([]);
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -4489,7 +4489,7 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
||||
(entry) => entry.pluginId === "http-route-overlap-same-auth",
|
||||
);
|
||||
expect(routes).toHaveLength(2);
|
||||
expect(registry.diagnostics).toEqual([]);
|
||||
expect(registry.diagnostics).toStrictEqual([]);
|
||||
},
|
||||
},
|
||||
] as const;
|
||||
@@ -5620,7 +5620,7 @@ module.exports = {
|
||||
},
|
||||
});
|
||||
|
||||
expect(registry.typedHooks).toEqual([]);
|
||||
expect(registry.typedHooks).toStrictEqual([]);
|
||||
const blockedDiagnostics = registry.diagnostics.filter((diag) =>
|
||||
diag.message.includes(
|
||||
"non-bundled plugins must set plugins.entries.conversation-hooks.hooks.allowConversationAccess=true",
|
||||
@@ -6875,7 +6875,7 @@ module.exports = {
|
||||
},
|
||||
});
|
||||
|
||||
expect(warnings).toEqual([]);
|
||||
expect(warnings).toStrictEqual([]);
|
||||
expectDiagnosticContaining({
|
||||
registry,
|
||||
level: "warn",
|
||||
|
||||
Reference in New Issue
Block a user