test: trim hot test runtime imports

This commit is contained in:
Peter Steinberger
2026-04-28 02:25:51 +01:00
parent fe15268e5f
commit b6a90188e7
2 changed files with 42 additions and 2 deletions

View File

@@ -1,7 +1,42 @@
import { describe, expect, it } from "vitest";
import { describe, expect, it, vi } from "vitest";
import { normalizeProviderSpecificConfig } from "./models-config.providers.policy.js";
import type { ProviderConfig } from "./models-config.providers.secrets.js";
vi.mock("../plugins/provider-runtime.js", () => {
function normalizeGoogleModelIdForProvider(provider: string, modelId: string): string {
if (provider === "google-antigravity") {
return /^(gemini-3(?:[.-]1)?-pro)$/.test(modelId) ? `${modelId}-low` : modelId;
}
if (provider === "google-vertex" && modelId === "gemini-3.1-flash-lite") {
return "gemini-3.1-flash-lite-preview";
}
return modelId;
}
return {
applyProviderNativeStreamingUsageCompatWithPlugin: () => undefined,
normalizeProviderConfigWithPlugin: (params: {
context: { provider: string; providerConfig?: ProviderConfig };
}) => {
const providerConfig = params.context.providerConfig;
if (!providerConfig?.models) {
return undefined;
}
let changed = false;
const models = providerConfig.models.map((model) => {
const normalizedId = normalizeGoogleModelIdForProvider(params.context.provider, model.id);
if (normalizedId === model.id) {
return model;
}
changed = true;
return { ...model, id: normalizedId, name: normalizedId };
});
return changed ? { ...providerConfig, models } : undefined;
},
resolveProviderConfigApiKeyWithPlugin: () => undefined,
};
});
function buildModel(id: string): NonNullable<ProviderConfig["models"]>[number] {
return {
id,

View File

@@ -1,10 +1,15 @@
import { describe, expect, it } from "vitest";
import { describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "../config/types.js";
import { withTempDir } from "../test-helpers/temp-dir.js";
import { withEnvAsync } from "../test-utils/env.js";
import { runCapability } from "./runner.js";
import { withVideoFixture } from "./runner.test-utils.js";
vi.mock("../plugins/capability-provider-runtime.js", async () => {
const { createEmptyCapabilityProviderMockModule } = await import("./runner.test-mocks.js");
return createEmptyCapabilityProviderMockModule();
});
describe("runCapability video provider wiring", () => {
it("merges video baseUrl and headers with entry precedence", async () => {
let seenBaseUrl: string | undefined;