mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 06:50:46 +00:00
Honor targeted includes in the contracts Vitest lane and compare bundled web-search fast-path artifacts against plugin-owned runtime artifacts instead of loading whole plugin entries. Split Google and Firecrawl runtime-only work behind lazy seams so provider registration stays metadata-light. Also keep Perplexity contract metadata aligned by sharing its runtime transport resolution with the contract artifact.
60 lines
2.2 KiB
TypeScript
60 lines
2.2 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
const { loadPluginManifestRegistryMock } = vi.hoisted(() => ({
|
|
loadPluginManifestRegistryMock: vi.fn(() => {
|
|
throw new Error("manifest registry should stay off the explicit bundled fast path");
|
|
}),
|
|
}));
|
|
|
|
vi.mock("./manifest-registry.js", async (importOriginal) => {
|
|
const actual = await importOriginal<typeof import("./manifest-registry.js")>();
|
|
return {
|
|
...actual,
|
|
loadPluginManifestRegistry: loadPluginManifestRegistryMock,
|
|
};
|
|
});
|
|
|
|
import { resolveBundledExplicitRuntimeWebSearchProvidersFromPublicArtifacts as resolveExplicitRuntimeWebSearchProviders } from "./web-provider-public-artifacts.explicit.js";
|
|
import {
|
|
resolveBundledWebFetchProvidersFromPublicArtifacts,
|
|
resolveBundledWebSearchProvidersFromPublicArtifacts,
|
|
} from "./web-provider-public-artifacts.js";
|
|
|
|
describe("web provider public artifacts explicit fast path", () => {
|
|
beforeEach(() => {
|
|
loadPluginManifestRegistryMock.mockClear();
|
|
});
|
|
|
|
it("resolves bundled web search providers by explicit plugin id without manifest scans", () => {
|
|
const provider = resolveBundledWebSearchProvidersFromPublicArtifacts({
|
|
bundledAllowlistCompat: true,
|
|
onlyPluginIds: ["brave"],
|
|
})?.[0];
|
|
|
|
expect(provider?.pluginId).toBe("brave");
|
|
expect(provider?.createTool({ config: {} as never })).toBeNull();
|
|
expect(loadPluginManifestRegistryMock).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("resolves bundled runtime web search providers by explicit plugin id", () => {
|
|
const provider = resolveExplicitRuntimeWebSearchProviders({
|
|
onlyPluginIds: ["google"],
|
|
})?.[0];
|
|
|
|
expect(provider?.pluginId).toBe("google");
|
|
expect(provider?.createTool({ config: {} as never })).not.toBeNull();
|
|
expect(loadPluginManifestRegistryMock).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("resolves bundled web fetch providers by explicit plugin id without manifest scans", () => {
|
|
const provider = resolveBundledWebFetchProvidersFromPublicArtifacts({
|
|
bundledAllowlistCompat: true,
|
|
onlyPluginIds: ["firecrawl"],
|
|
})?.[0];
|
|
|
|
expect(provider?.pluginId).toBe("firecrawl");
|
|
expect(provider?.createTool({ config: {} as never })).toBeNull();
|
|
expect(loadPluginManifestRegistryMock).not.toHaveBeenCalled();
|
|
});
|
|
});
|