mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-22 23:21:17 +00:00
test: speed doctor plugin install tests (#108022)
This commit is contained in:
committed by
GitHub
parent
1967e4c04d
commit
fbe033214d
@@ -11,6 +11,7 @@ import {
|
||||
resolveClawHubInstallSpecsForUpdateChannel,
|
||||
resolveNpmInstallSpecsForUpdateChannel,
|
||||
} from "../../../plugins/install-channel-specs.js";
|
||||
import type { BundledProviderPolicySurface } from "../../../plugins/provider-policy-surface.js";
|
||||
import { VERSION } from "../../../version.js";
|
||||
import { applyLegacyDoctorMigrations } from "./legacy-config-compat.js";
|
||||
|
||||
@@ -74,6 +75,27 @@ const mocks = vi.hoisted(() => ({
|
||||
resolveOfficialExternalProviderPluginIds: vi.fn(),
|
||||
resolveOfficialExternalProviderPluginIdsForEnv: vi.fn(),
|
||||
resolveOfficialExternalWebProviderContractPluginIdsForEnv: vi.fn(),
|
||||
resolveDirectBundledProviderPolicySurface: vi.fn(
|
||||
(pluginId: string): BundledProviderPolicySurface | null =>
|
||||
pluginId === "openai"
|
||||
? {
|
||||
normalizeModelCatalogId: ({ modelId }) => modelId,
|
||||
resolveModelRoutes: ({ requestTransportOverrides }) => ({
|
||||
kind: "routes",
|
||||
routes: [
|
||||
{
|
||||
api: "openai-responses",
|
||||
baseUrl: "https://api.openai.com/v1",
|
||||
authRequirement: "api-key",
|
||||
requestTransportOverrides: requestTransportOverrides ?? "none",
|
||||
runtimePolicy: { compatibleIds: ["openclaw", "codex"] },
|
||||
},
|
||||
],
|
||||
defaultRuntimeId: "codex",
|
||||
}),
|
||||
}
|
||||
: null,
|
||||
),
|
||||
resolveDefaultPluginExtensionsDir: vi.fn(() => "/tmp/openclaw-plugins"),
|
||||
resolveDefaultPluginNpmDir: vi.fn(() => "/tmp/openclaw-npm"),
|
||||
resolvePluginNpmProjectsDir: vi.fn((npmDir = "/tmp/openclaw-npm") =>
|
||||
@@ -203,6 +225,13 @@ vi.mock("../../../plugins/provider-install-catalog.js", () => ({
|
||||
resolveProviderInstallCatalogEntries: mocks.resolveProviderInstallCatalogEntries,
|
||||
}));
|
||||
|
||||
vi.mock("../../../plugins/provider-policy-surface.js", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("../../../plugins/provider-policy-surface.js")>()),
|
||||
// This suite owns install repair. Provider artifact loading and route policy
|
||||
// have dedicated tests, so keep the OpenAI runtime-selection seam in memory.
|
||||
resolveDirectBundledProviderPolicySurface: mocks.resolveDirectBundledProviderPolicySurface,
|
||||
}));
|
||||
|
||||
vi.mock("../../../plugins/doctor-contract-registry.js", async (importOriginal) => {
|
||||
const actual =
|
||||
await importOriginal<typeof import("../../../plugins/doctor-contract-registry.js")>();
|
||||
@@ -2524,6 +2553,7 @@ describe("repairMissingConfiguredPluginInstalls", () => {
|
||||
env: {},
|
||||
});
|
||||
|
||||
expect(mocks.resolveDirectBundledProviderPolicySurface).toHaveBeenCalledWith("openai");
|
||||
expect(mocks.updateNpmInstalledPlugins).not.toHaveBeenCalled();
|
||||
expectRecordFields(mockCallArg(mocks.installPluginFromNpmSpec), {
|
||||
spec: expectedNpmInstallSpec("@openclaw/codex"),
|
||||
|
||||
Reference in New Issue
Block a user