mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:20:43 +00:00
test: trim hot test runtime imports
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user