




















@@ -131,6 +131,29 @@ vi.mock("../commands/onboarding-plugin-install.js", () => ({
131131 ensureOnboardingPluginInstalled,
132132}));
133133134+function latestPluginInstallRequest(): {
135+autoConfirmSingleSource?: boolean;
136+entry?: {
137+install?: { npmSpec?: string };
138+label?: string;
139+pluginId?: string;
140+trustedSourceLinkedOfficialInstall?: boolean;
141+};
142+} {
143+const [request] = ensureOnboardingPluginInstalled.mock.calls.at(-1) as unknown as [
144+{
145+autoConfirmSingleSource?: boolean;
146+entry?: {
147+install?: { npmSpec?: string };
148+label?: string;
149+pluginId?: string;
150+trustedSourceLinkedOfficialInstall?: boolean;
151+};
152+},
153+];
154+return request;
155+}
156+134157describe("runSearchSetupFlow", () => {
135158beforeEach(() => {
136159ensureOnboardingPluginInstalled.mockClear();
@@ -154,17 +177,14 @@ describe("runSearchSetupFlow", () => {
154177prompter,
155178);
156179157-expect(next.plugins?.entries?.xai?.config?.webSearch).toMatchObject({
158-apiKey: "xai-test-key",
159-});
160-expect(next.tools?.web?.search).toMatchObject({
161-provider: "grok",
162-enabled: true,
163-});
164-expect(next.plugins?.entries?.xai?.config?.xSearch).toMatchObject({
165-enabled: true,
166-model: "grok-4-1-fast",
167-});
180+const xaiConfig = next.plugins?.entries?.xai?.config as
181+| { webSearch?: { apiKey?: string }; xSearch?: { enabled?: boolean; model?: string } }
182+| undefined;
183+expect(xaiConfig?.webSearch?.apiKey).toBe("xai-test-key");
184+expect(next.tools?.web?.search?.provider).toBe("grok");
185+expect(next.tools?.web?.search?.enabled).toBe(true);
186+expect(xaiConfig?.xSearch?.enabled).toBe(true);
187+expect(xaiConfig?.xSearch?.model).toBe("grok-4-1-fast");
168188});
169189170190it("shows provider credential notes before plaintext credential prompts", async () => {
@@ -278,14 +298,13 @@ describe("runSearchSetupFlow", () => {
278298prompter,
279299);
280300281-expect(next.tools?.web?.search).toMatchObject({
282-provider: "grok",
283-enabled: false,
284-});
285-expect(next.plugins?.entries?.xai?.config?.xSearch).toMatchObject({
286-enabled: true,
287-model: "grok-4-1-fast",
288-});
301+const xaiConfig = next.plugins?.entries?.xai?.config as
302+| { xSearch?: { enabled?: boolean; model?: string } }
303+| undefined;
304+expect(next.tools?.web?.search?.provider).toBe("grok");
305+expect(next.tools?.web?.search?.enabled).toBe(false);
306+expect(xaiConfig?.xSearch?.enabled).toBe(true);
307+expect(xaiConfig?.xSearch?.model).toBe("grok-4-1-fast");
289308});
290309291310it("installs an external catalog search provider before enabling it", async () => {
@@ -298,30 +317,21 @@ describe("runSearchSetupFlow", () => {
298317299318const next = await runSearchSetupFlow({}, createNonExitingRuntime(), prompter);
300319301-expect(ensureOnboardingPluginInstalled).toHaveBeenCalledWith(
302-expect.objectContaining({
303-entry: expect.objectContaining({
304-pluginId: "brave",
305-label: "Brave",
306-trustedSourceLinkedOfficialInstall: true,
307-install: expect.objectContaining({
308-npmSpec: "@openclaw/brave-plugin",
309-}),
310-}),
311-autoConfirmSingleSource: true,
312-}),
313-);
314-expect(next.tools?.web?.search).toMatchObject({
315-provider: "brave",
316-enabled: true,
317-});
318-expect(next.plugins?.entries?.brave?.config?.webSearch).toMatchObject({
319-apiKey: "brave-test-key",
320-});
321-expect(next.plugins?.installs?.brave).toMatchObject({
322-source: "npm",
323-spec: "@openclaw/brave-plugin",
324-});
320+expect(ensureOnboardingPluginInstalled).toHaveBeenCalledTimes(1);
321+const installRequest = latestPluginInstallRequest();
322+expect(installRequest.entry?.pluginId).toBe("brave");
323+expect(installRequest.entry?.label).toBe("Brave");
324+expect(installRequest.entry?.trustedSourceLinkedOfficialInstall).toBe(true);
325+expect(installRequest.entry?.install?.npmSpec).toBe("@openclaw/brave-plugin");
326+expect(installRequest.autoConfirmSingleSource).toBe(true);
327+expect(next.tools?.web?.search?.provider).toBe("brave");
328+expect(next.tools?.web?.search?.enabled).toBe(true);
329+const braveConfig = next.plugins?.entries?.brave?.config as
330+| { webSearch?: { apiKey?: string } }
331+| undefined;
332+expect(braveConfig?.webSearch?.apiKey).toBe("brave-test-key");
333+expect(next.plugins?.installs?.brave?.source).toBe("npm");
334+expect(next.plugins?.installs?.brave?.spec).toBe("@openclaw/brave-plugin");
325335});
326336327337it("installs an external catalog search provider when web search stays disabled", async () => {
@@ -347,30 +357,21 @@ describe("runSearchSetupFlow", () => {
347357prompter,
348358);
349359350-expect(ensureOnboardingPluginInstalled).toHaveBeenCalledWith(
351-expect.objectContaining({
352-entry: expect.objectContaining({
353-pluginId: "brave",
354-label: "Brave",
355-trustedSourceLinkedOfficialInstall: true,
356-install: expect.objectContaining({
357-npmSpec: "@openclaw/brave-plugin",
358-}),
359-}),
360-autoConfirmSingleSource: true,
361-}),
362-);
363-expect(next.tools?.web?.search).toMatchObject({
364-provider: "brave",
365-enabled: false,
366-});
367-expect(next.plugins?.entries?.brave?.config?.webSearch).toMatchObject({
368-apiKey: "brave-disabled-key",
369-});
360+expect(ensureOnboardingPluginInstalled).toHaveBeenCalledTimes(1);
361+const installRequest = latestPluginInstallRequest();
362+expect(installRequest.entry?.pluginId).toBe("brave");
363+expect(installRequest.entry?.label).toBe("Brave");
364+expect(installRequest.entry?.trustedSourceLinkedOfficialInstall).toBe(true);
365+expect(installRequest.entry?.install?.npmSpec).toBe("@openclaw/brave-plugin");
366+expect(installRequest.autoConfirmSingleSource).toBe(true);
367+expect(next.tools?.web?.search?.provider).toBe("brave");
368+expect(next.tools?.web?.search?.enabled).toBe(false);
369+const braveConfig = next.plugins?.entries?.brave?.config as
370+| { webSearch?: { apiKey?: string } }
371+| undefined;
372+expect(braveConfig?.webSearch?.apiKey).toBe("brave-disabled-key");
370373expect(next.plugins?.entries?.brave?.enabled).toBeUndefined();
371-expect(next.plugins?.installs?.brave).toMatchObject({
372-source: "npm",
373-spec: "@openclaw/brave-plugin",
374-});
374+expect(next.plugins?.installs?.brave?.source).toBe("npm");
375+expect(next.plugins?.installs?.brave?.spec).toBe("@openclaw/brave-plugin");
375376});
376377});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。