mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 10:30:43 +00:00
test: tighten web provider fast path assertions
This commit is contained in:
@@ -77,6 +77,15 @@ import {
|
||||
resolveBundledWebSearchProvidersFromPublicArtifacts,
|
||||
} from "./web-provider-public-artifacts.js";
|
||||
|
||||
function expectSingleProvider<T>(providers: T[] | undefined): T {
|
||||
expect(providers).toHaveLength(1);
|
||||
const provider = providers?.[0];
|
||||
if (provider === undefined) {
|
||||
throw new Error("Expected one web provider");
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
|
||||
describe("web provider public artifacts explicit fast path", () => {
|
||||
beforeEach(() => {
|
||||
loadPluginManifestRegistryMock.mockClear();
|
||||
@@ -84,13 +93,15 @@ describe("web provider public artifacts explicit fast path", () => {
|
||||
});
|
||||
|
||||
it("resolves bundled web search providers by explicit plugin id without manifest scans", () => {
|
||||
const provider = resolveBundledWebSearchProvidersFromPublicArtifacts({
|
||||
bundledAllowlistCompat: true,
|
||||
onlyPluginIds: ["brave"],
|
||||
})?.[0];
|
||||
const provider = expectSingleProvider(
|
||||
resolveBundledWebSearchProvidersFromPublicArtifacts({
|
||||
bundledAllowlistCompat: true,
|
||||
onlyPluginIds: ["brave"],
|
||||
}),
|
||||
);
|
||||
|
||||
expect(provider?.pluginId).toBe("brave");
|
||||
expect(provider?.createTool({ config: {} as never })).toBeNull();
|
||||
expect(provider.pluginId).toBe("brave");
|
||||
expect(provider.createTool({ config: {} as never })).toBeNull();
|
||||
expect(loadBundledPluginPublicArtifactModuleSyncMock).toHaveBeenCalledWith({
|
||||
dirName: "brave",
|
||||
artifactBasename: "web-search-contract-api.js",
|
||||
@@ -99,12 +110,14 @@ describe("web provider public artifacts explicit fast path", () => {
|
||||
});
|
||||
|
||||
it("resolves bundled runtime web search providers by explicit plugin id", () => {
|
||||
const provider = resolveExplicitRuntimeWebSearchProviders({
|
||||
onlyPluginIds: ["google"],
|
||||
})?.[0];
|
||||
const provider = expectSingleProvider(
|
||||
resolveExplicitRuntimeWebSearchProviders({
|
||||
onlyPluginIds: ["google"],
|
||||
}),
|
||||
);
|
||||
|
||||
expect(provider?.pluginId).toBe("google");
|
||||
expect(provider?.createTool({ config: {} as never })).not.toBeNull();
|
||||
expect(provider.pluginId).toBe("google");
|
||||
expect(provider.createTool({ config: {} as never })).toEqual(expect.any(Object));
|
||||
expect(loadBundledPluginPublicArtifactModuleSyncMock).toHaveBeenCalledWith({
|
||||
dirName: "google",
|
||||
artifactBasename: "web-search-provider.js",
|
||||
@@ -113,13 +126,15 @@ describe("web provider public artifacts explicit fast path", () => {
|
||||
});
|
||||
|
||||
it("resolves bundled web fetch providers by explicit plugin id without manifest scans", () => {
|
||||
const provider = resolveBundledWebFetchProvidersFromPublicArtifacts({
|
||||
bundledAllowlistCompat: true,
|
||||
onlyPluginIds: ["firecrawl"],
|
||||
})?.[0];
|
||||
const provider = expectSingleProvider(
|
||||
resolveBundledWebFetchProvidersFromPublicArtifacts({
|
||||
bundledAllowlistCompat: true,
|
||||
onlyPluginIds: ["firecrawl"],
|
||||
}),
|
||||
);
|
||||
|
||||
expect(provider?.pluginId).toBe("firecrawl");
|
||||
expect(provider?.createTool({ config: {} as never })).toBeNull();
|
||||
expect(provider.pluginId).toBe("firecrawl");
|
||||
expect(provider.createTool({ config: {} as never })).toBeNull();
|
||||
expect(loadBundledPluginPublicArtifactModuleSyncMock).toHaveBeenCalledWith({
|
||||
dirName: "firecrawl",
|
||||
artifactBasename: "web-fetch-contract-api.js",
|
||||
|
||||
Reference in New Issue
Block a user