mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 14:20:44 +00:00
test: narrow web search contract runtime loads
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.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
import { resolveManifestContractOwnerPluginId } from "../../../src/plugins/manifest-registry.js";
|
||||
import { resolveBundledExplicitWebSearchProvidersFromPublicArtifacts } from "../../../src/plugins/web-provider-public-artifacts.explicit.js";
|
||||
import { resolvePluginWebSearchProviders } from "../../../src/plugins/web-search-providers.runtime.js";
|
||||
import {
|
||||
resolveBundledExplicitRuntimeWebSearchProvidersFromPublicArtifacts,
|
||||
resolveBundledExplicitWebSearchProvidersFromPublicArtifacts,
|
||||
} from "../../../src/plugins/web-provider-public-artifacts.explicit.js";
|
||||
|
||||
type ComparableProvider = {
|
||||
pluginId: string;
|
||||
@@ -94,19 +96,16 @@ export function describeBundledWebSearchFastPathContract(pluginId: string) {
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps fast-path provider metadata aligned with bundled public artifacts", async () => {
|
||||
const fastPathProviders = resolvePluginWebSearchProviders({
|
||||
origin: "bundled",
|
||||
onlyPluginIds: [pluginId],
|
||||
mode: "setup",
|
||||
}).filter((provider) => provider.pluginId === pluginId);
|
||||
const bundledProviderEntries =
|
||||
it("keeps fast-path provider metadata aligned with the bundled runtime artifact", async () => {
|
||||
const fastPathProviders =
|
||||
resolveBundledExplicitWebSearchProvidersFromPublicArtifacts({
|
||||
onlyPluginIds: [pluginId],
|
||||
})?.filter((provider) => provider.pluginId === pluginId) ?? [];
|
||||
const bundledProviderEntries =
|
||||
resolveBundledExplicitRuntimeWebSearchProvidersFromPublicArtifacts({
|
||||
onlyPluginIds: [pluginId],
|
||||
})?.filter((entry) => entry.pluginId === pluginId) ?? [];
|
||||
|
||||
expect(bundledProviderEntries.length).toBeGreaterThan(0);
|
||||
|
||||
expect(
|
||||
sortComparableEntries(
|
||||
fastPathProviders.map((provider) =>
|
||||
|
||||
@@ -41,6 +41,19 @@ describe("projects vitest config", () => {
|
||||
expect(normalizeConfigPath(config.test.runner)).toBe("test/non-isolated-runner.ts");
|
||||
});
|
||||
|
||||
it("narrows the contracts lane to targeted contract files", () => {
|
||||
const config = createContractsVitestConfig({}, [
|
||||
"node",
|
||||
"vitest",
|
||||
"run",
|
||||
"src/plugins/contracts/bundled-web-search.google.contract.test.ts",
|
||||
]);
|
||||
|
||||
expect(config.test.include).toEqual([
|
||||
"src/plugins/contracts/bundled-web-search.google.contract.test.ts",
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps the root ui lane aligned with the isolated jsdom setup", () => {
|
||||
const config = createUiVitestConfig();
|
||||
expect(config.test.environment).toBe("jsdom");
|
||||
|
||||
@@ -1,10 +1,25 @@
|
||||
import { defineConfig } from "vitest/config";
|
||||
import { loadPatternListFromEnv, narrowIncludePatternsForCli } from "./vitest.pattern-file.ts";
|
||||
import { nonIsolatedRunnerPath, sharedVitestConfig } from "./vitest.shared.config.ts";
|
||||
|
||||
const base = sharedVitestConfig as Record<string, unknown>;
|
||||
const baseTest = sharedVitestConfig.test ?? {};
|
||||
const contractIncludePatterns = [
|
||||
"src/channels/plugins/contracts/**/*.test.ts",
|
||||
"src/plugins/contracts/**/*.test.ts",
|
||||
];
|
||||
|
||||
export function createContractsVitestConfig() {
|
||||
export function loadContractsIncludePatternsFromEnv(
|
||||
env: Record<string, string | undefined> = process.env,
|
||||
): string[] | null {
|
||||
return loadPatternListFromEnv("OPENCLAW_VITEST_INCLUDE_FILE", env);
|
||||
}
|
||||
|
||||
export function createContractsVitestConfig(
|
||||
env: Record<string, string | undefined> = process.env,
|
||||
argv: string[] = process.argv,
|
||||
) {
|
||||
const cliIncludePatterns = narrowIncludePatternsForCli(contractIncludePatterns, argv);
|
||||
return defineConfig({
|
||||
...base,
|
||||
test: {
|
||||
@@ -16,10 +31,8 @@ export function createContractsVitestConfig() {
|
||||
pool: "forks",
|
||||
runner: nonIsolatedRunnerPath,
|
||||
setupFiles: baseTest.setupFiles ?? [],
|
||||
include: [
|
||||
"src/channels/plugins/contracts/**/*.test.ts",
|
||||
"src/plugins/contracts/**/*.test.ts",
|
||||
],
|
||||
include:
|
||||
loadContractsIncludePatternsFromEnv(env) ?? cliIncludePatterns ?? contractIncludePatterns,
|
||||
passWithNoTests: true,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user