forked from openclaw/openclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.official-plugins.test.ts
More file actions
201 lines (186 loc) · 6.12 KB
/
Copy pathsetup.official-plugins.test.ts
File metadata and controls
201 lines (186 loc) · 6.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
import { beforeEach, describe, expect, it, vi } from "vitest";
import { createWizardPrompter } from "../../test/helpers/wizard-prompter.js";
import { createNonExitingRuntime } from "../runtime.js";
import type { WizardPrompter } from "./prompts.js";
const ensureOnboardingPluginInstalled = vi.hoisted(() =>
vi.fn(async ({ cfg }: { cfg: Record<string, unknown> }) => ({
cfg,
installed: true,
status: "installed",
})),
);
vi.mock("../commands/onboarding-plugin-install.js", () => ({
ensureOnboardingPluginInstalled,
}));
import {
testing,
resolveOfficialPluginOnboardingInstallEntries,
setupOfficialPluginInstalls,
} from "./setup.official-plugins.js";
describe("resolveOfficialPluginOnboardingInstallEntries", () => {
it("lists optional generic official plugins without channel, provider, or search-owned entries", () => {
const entries = resolveOfficialPluginOnboardingInstallEntries({ config: {} });
const pluginIds = entries.map((entry) => entry.pluginId);
expect(pluginIds).toContain("diagnostics-otel");
expect(pluginIds).toContain("diagnostics-prometheus");
expect(pluginIds).toContain("acpx");
expect(pluginIds).not.toContain("brave");
expect(pluginIds).not.toContain("codex");
expect(pluginIds).not.toContain("discord");
});
it("hides already configured official plugins", () => {
const entries = resolveOfficialPluginOnboardingInstallEntries({
config: {
plugins: {
entries: {
acpx: { enabled: true },
},
installs: {
"diagnostics-otel": {
source: "npm",
spec: "@openclaw/diagnostics-otel",
installPath: "/tmp/diagnostics-otel",
},
},
},
},
});
const pluginIds = entries.map((entry) => entry.pluginId);
expect(pluginIds).not.toContain("acpx");
expect(pluginIds).not.toContain("diagnostics-otel");
expect(pluginIds).toContain("diagnostics-prometheus");
});
});
describe("formatInstallHint", () => {
it("describes dual-source npm-default installs as npm first", () => {
expect(
testing.formatInstallHint({
clawhubSpec: "clawhub:@openclaw/diagnostics-otel",
npmSpec: "@openclaw/diagnostics-otel",
defaultChoice: "npm",
}),
).toBe("npm, with ClawHub fallback");
});
it("keeps dual-source clawhub-default installs ClawHub first", () => {
expect(
testing.formatInstallHint({
clawhubSpec: "clawhub:@openclaw/diagnostics-otel",
npmSpec: "@openclaw/diagnostics-otel",
defaultChoice: "clawhub",
}),
).toBe("ClawHub, with npm fallback");
});
});
describe("setupOfficialPluginInstalls", () => {
beforeEach(() => {
vi.clearAllMocks();
ensureOnboardingPluginInstalled.mockImplementation(async ({ cfg }) => ({
cfg,
installed: true,
status: "installed",
}));
});
it("installs selected optional official plugins through the shared onboarding installer", async () => {
const multiselect = vi.fn(async () => ["diagnostics-otel"]);
const prompter = createWizardPrompter({
multiselect: multiselect as WizardPrompter["multiselect"],
});
const runtime = createNonExitingRuntime();
await setupOfficialPluginInstalls({
config: {},
prompter,
runtime,
workspaceDir: "/tmp/workspace",
});
expect(multiselect).toHaveBeenCalledExactlyOnceWith({
message: "Install optional plugins",
options: [
{
value: "__skip__",
label: "Skip for now",
hint: "Continue without installing optional plugins",
},
{
value: "acpx",
label: "ACPX Runtime",
hint: "OpenClaw ACP runtime backend",
},
{
value: "diagnostics-otel",
label: "Diagnostics OpenTelemetry",
hint: "OpenClaw diagnostics OpenTelemetry exporter",
},
{
value: "diagnostics-prometheus",
label: "Diagnostics Prometheus",
hint: "OpenClaw diagnostics Prometheus exporter",
},
{
value: "diffs-language-pack",
label: "Diff Viewer Language Pack",
hint: "OpenClaw diffs viewer syntax highlighting language pack",
},
{
value: "diffs",
label: "Diffs",
hint: "OpenClaw diff viewer plugin",
},
{
value: "google-meet",
label: "Google Meet",
hint: "OpenClaw Google Meet participant plugin",
},
{
value: "lobster",
label: "Lobster",
hint: "Lobster workflow tool plugin (typed pipelines + resumable approvals)",
},
{
value: "memory-lancedb",
label: "Memory LanceDB",
hint: "OpenClaw LanceDB-backed long-term memory plugin with auto-recall/capture",
},
{
value: "openshell",
label: "OpenShell Sandbox",
hint: "OpenClaw OpenShell sandbox backend",
},
{
value: "voice-call",
label: "Voice Call",
hint: "OpenClaw voice-call plugin",
},
],
});
expect(ensureOnboardingPluginInstalled).toHaveBeenCalledExactlyOnceWith({
cfg: {},
entry: {
pluginId: "diagnostics-otel",
label: "Diagnostics OpenTelemetry",
description: "OpenClaw diagnostics OpenTelemetry exporter",
install: {
clawhubSpec: "clawhub:@openclaw/diagnostics-otel",
npmSpec: "@openclaw/diagnostics-otel",
defaultChoice: "npm",
minHostVersion: ">=2026.4.25",
},
trustedSourceLinkedOfficialInstall: true,
},
prompter,
runtime,
workspaceDir: "/tmp/workspace",
promptInstall: false,
});
});
it("does not install when the user skips optional plugins", async () => {
const prompter = createWizardPrompter({
multiselect: vi.fn(async () => ["__skip__"]) as WizardPrompter["multiselect"],
});
await setupOfficialPluginInstalls({
config: {},
prompter,
runtime: createNonExitingRuntime(),
});
expect(ensureOnboardingPluginInstalled).not.toHaveBeenCalled();
});
});