


























@@ -8,6 +8,8 @@ type WebSearchProvidersSharedModule = typeof import("./web-search-providers.shar
88type PluginManifestRegistry = import("./manifest-registry.js").PluginManifestRegistry;
99type LoadPluginManifestRegistryForPluginRegistry =
1010typeof import("./plugin-registry.js").loadPluginManifestRegistryForPluginRegistry;
11+type LoadPluginManifestRegistryForInstalledIndex =
12+typeof import("./manifest-registry-installed.js").loadPluginManifestRegistryForInstalledIndex;
11131214const BUNDLED_WEB_SEARCH_PROVIDERS = [
1315{ pluginId: "brave", id: "brave", order: 10 },
@@ -25,6 +27,9 @@ let createEmptyPluginRegistry: RegistryModule["createEmptyPluginRegistry"];
2527let loadPluginManifestRegistryMock: ReturnType<
2628typeof vi.fn<LoadPluginManifestRegistryForPluginRegistry>
2729>;
30+let loadInstalledPluginManifestRegistryMock: ReturnType<
31+typeof vi.fn<LoadPluginManifestRegistryForInstalledIndex>
32+>;
2833let setActivePluginRegistry: RuntimeModule["setActivePluginRegistry"];
2934let resolvePluginWebSearchProviders: WebSearchProvidersRuntimeModule["resolvePluginWebSearchProviders"];
3035let resolveRuntimeWebSearchProviders: WebSearchProvidersRuntimeModule["resolveRuntimeWebSearchProviders"];
@@ -181,7 +186,7 @@ function expectLoaderCallCount(count: number) {
181186}
182187183188function expectScopedWebSearchCandidates(pluginIds: readonly string[]) {
184-expect(loadPluginManifestRegistryMock).toHaveBeenCalled();
189+expect(loadInstalledPluginManifestRegistryMock).toHaveBeenCalled();
185190expect(loadOpenClawPluginsMock).toHaveBeenCalledWith(
186191expect.objectContaining({
187192onlyPluginIds: [...pluginIds],
@@ -320,16 +325,41 @@ function expectRuntimeProviderResolution(
320325describe("resolvePluginWebSearchProviders", () => {
321326beforeAll(async () => {
322327loadPluginManifestRegistryMock = vi.fn<LoadPluginManifestRegistryForPluginRegistry>();
328+loadInstalledPluginManifestRegistryMock = vi.fn<LoadPluginManifestRegistryForInstalledIndex>();
323329vi.doMock("./plugin-registry.js", async () => {
324330const actual =
325331await vi.importActual<typeof import("./plugin-registry.js")>("./plugin-registry.js");
326332return {
327333 ...actual,
334+loadPluginRegistrySnapshotWithMetadata: () => ({
335+source: "derived",
336+snapshot: {
337+plugins: [
338+{
339+pluginId: "__test_manifest_registry_fixture__",
340+origin: "bundled",
341+enabled: true,
342+},
343+],
344+},
345+diagnostics: [],
346+}),
328347loadPluginManifestRegistryForPluginRegistry: (
329348 ...args: Parameters<LoadPluginManifestRegistryForPluginRegistry>
330349) => loadPluginManifestRegistryMock(...args),
331350};
332351});
352+vi.doMock("./manifest-registry-installed.js", async () => {
353+const actual = await vi.importActual<typeof import("./manifest-registry-installed.js")>(
354+"./manifest-registry-installed.js",
355+);
356+return {
357+ ...actual,
358+loadPluginManifestRegistryForInstalledIndex: (
359+ ...args: Parameters<LoadPluginManifestRegistryForInstalledIndex>
360+) => loadInstalledPluginManifestRegistryMock(...args),
361+};
362+});
333363334364({ createEmptyPluginRegistry } = await import("./registry-empty.js"));
335365loaderModule = await import("./loader.js");
@@ -354,6 +384,8 @@ describe("resolvePluginWebSearchProviders", () => {
354384);
355385loadPluginManifestRegistryMock.mockReset();
356386loadPluginManifestRegistryMock.mockReturnValue(createManifestRegistryFixture());
387+loadInstalledPluginManifestRegistryMock.mockReset();
388+loadInstalledPluginManifestRegistryMock.mockReturnValue(createManifestRegistryFixture());
357389loadOpenClawPluginsMock = vi
358390.spyOn(loaderModule, "loadOpenClawPlugins")
359391.mockImplementation((params) => {
@@ -435,7 +467,7 @@ describe("resolvePluginWebSearchProviders", () => {
435467 env,
436468});
437469438-expect(loadPluginManifestRegistryMock).toHaveBeenCalledWith(
470+expect(loadInstalledPluginManifestRegistryMock).toHaveBeenCalledWith(
439471expect.objectContaining({
440472workspaceDir: "/tmp/runtime-workspace",
441473}),
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。