mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-25 22:49:34 +00:00
105 lines
2.8 KiB
TypeScript
105 lines
2.8 KiB
TypeScript
import { beforeEach, describe, expect, it } from "vitest";
|
|
import { createPluginRecord } from "../plugins/status.test-helpers.js";
|
|
import {
|
|
buildPluginDiagnosticsReport,
|
|
buildPluginInspectReport,
|
|
buildPluginSnapshotReport,
|
|
resetPluginsCliTestState,
|
|
runPluginsCommand,
|
|
runtimeLogs,
|
|
} from "./plugins-cli-test-helpers.js";
|
|
|
|
describe("plugins cli list", () => {
|
|
beforeEach(() => {
|
|
resetPluginsCliTestState();
|
|
});
|
|
|
|
it("includes imported state in JSON output", async () => {
|
|
buildPluginSnapshotReport.mockReturnValue({
|
|
workspaceDir: "/workspace",
|
|
plugins: [
|
|
createPluginRecord({
|
|
id: "demo",
|
|
imported: true,
|
|
activated: true,
|
|
explicitlyEnabled: true,
|
|
}),
|
|
],
|
|
diagnostics: [],
|
|
});
|
|
|
|
await runPluginsCommand(["plugins", "list", "--json"]);
|
|
|
|
expect(buildPluginSnapshotReport).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
logger: expect.objectContaining({
|
|
info: expect.any(Function),
|
|
warn: expect.any(Function),
|
|
error: expect.any(Function),
|
|
}),
|
|
}),
|
|
);
|
|
|
|
expect(JSON.parse(runtimeLogs[0] ?? "null")).toEqual({
|
|
workspaceDir: "/workspace",
|
|
plugins: [
|
|
expect.objectContaining({
|
|
id: "demo",
|
|
imported: true,
|
|
activated: true,
|
|
explicitlyEnabled: true,
|
|
}),
|
|
],
|
|
diagnostics: [],
|
|
});
|
|
});
|
|
|
|
it("keeps doctor on a module-loading snapshot", async () => {
|
|
buildPluginDiagnosticsReport.mockReturnValue({
|
|
plugins: [],
|
|
diagnostics: [],
|
|
});
|
|
|
|
await runPluginsCommand(["plugins", "doctor"]);
|
|
|
|
expect(buildPluginDiagnosticsReport).toHaveBeenCalledWith();
|
|
expect(runtimeLogs).toContain("No plugin issues detected.");
|
|
});
|
|
|
|
it("shows conversation-access hook policy in inspect output", async () => {
|
|
buildPluginInspectReport.mockReturnValue({
|
|
workspaceDir: "/workspace",
|
|
plugin: createPluginRecord({ id: "openclaw-mem0", name: "Mem0" }),
|
|
shape: "hook-only",
|
|
capabilityMode: "plain",
|
|
capabilityCount: 1,
|
|
capabilities: [],
|
|
typedHooks: [{ name: "agent_end" }],
|
|
customHooks: [],
|
|
tools: [],
|
|
commands: [],
|
|
cliCommands: [],
|
|
services: [],
|
|
gatewayDiscoveryServices: [],
|
|
gatewayMethods: [],
|
|
mcpServers: [],
|
|
lspServers: [],
|
|
httpRouteCount: 0,
|
|
bundleCapabilities: [],
|
|
diagnostics: [],
|
|
policy: {
|
|
allowConversationAccess: true,
|
|
allowedModels: [],
|
|
hasAllowedModelsConfig: false,
|
|
},
|
|
usesLegacyBeforeAgentStart: false,
|
|
compatibility: [],
|
|
});
|
|
|
|
await runPluginsCommand(["plugins", "inspect", "openclaw-mem0"]);
|
|
|
|
expect(runtimeLogs.join("\n")).toContain("Policy");
|
|
expect(runtimeLogs.join("\n")).toContain("allowConversationAccess: true");
|
|
});
|
|
});
|