fix(regression): align provider flow docs with bundled compat

This commit is contained in:
Tak Hoffman 2026-03-27 19:18:05 -05:00
parent 27decb9649
commit 803f60105b
No known key found for this signature in database
2 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,82 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import {
resolveManifestProviderSetupFlowContributions,
resolveProviderModelPickerFlowContributions,
} from "./provider-flow.js";
const resolveManifestProviderAuthChoices = vi.hoisted(() => vi.fn(() => []));
const resolveProviderWizardOptions = vi.hoisted(() => vi.fn(() => []));
const resolveProviderModelPickerEntries = vi.hoisted(() => vi.fn(() => []));
const resolvePluginProviders = vi.hoisted(() => vi.fn(() => []));
vi.mock("../plugins/provider-auth-choices.js", () => ({
resolveManifestProviderAuthChoices,
}));
vi.mock("../plugins/provider-wizard.js", () => ({
resolveProviderWizardOptions,
resolveProviderModelPickerEntries,
}));
vi.mock("../plugins/providers.runtime.js", () => ({
resolvePluginProviders,
}));
describe("provider flow", () => {
beforeEach(() => {
vi.clearAllMocks();
});
it("uses bundled compat when resolving docs for manifest-backed setup contributions", () => {
resolveManifestProviderAuthChoices.mockReturnValue([
{
pluginId: "sglang",
providerId: "sglang",
methodId: "custom",
choiceId: "provider-plugin:sglang:custom",
choiceLabel: "SGLang",
},
]);
resolvePluginProviders.mockReturnValue([{ id: "sglang", docsPath: "/providers/sglang" }]);
const contributions = resolveManifestProviderSetupFlowContributions({
config: {},
workspaceDir: "/tmp/workspace",
env: process.env,
});
expect(resolvePluginProviders).toHaveBeenCalledWith({
config: {},
workspaceDir: "/tmp/workspace",
env: process.env,
bundledProviderAllowlistCompat: true,
bundledProviderVitestCompat: true,
});
expect(contributions[0]?.option.docs).toEqual({ path: "/providers/sglang" });
});
it("uses bundled compat when resolving docs for runtime model-picker contributions", () => {
resolveProviderModelPickerEntries.mockReturnValue([
{
value: "provider-plugin:vllm:custom",
label: "vLLM",
},
]);
resolvePluginProviders.mockReturnValue([{ id: "vllm", docsPath: "/providers/vllm" }]);
const contributions = resolveProviderModelPickerFlowContributions({
config: {},
workspaceDir: "/tmp/workspace",
env: process.env,
});
expect(resolvePluginProviders).toHaveBeenCalledWith({
config: {},
workspaceDir: "/tmp/workspace",
env: process.env,
bundledProviderAllowlistCompat: true,
bundledProviderVitestCompat: true,
});
expect(contributions[0]?.option.docs).toEqual({ path: "/providers/vllm" });
});
});

View File

@ -54,6 +54,8 @@ function resolveProviderDocsById(params?: {
config: params?.config,
workspaceDir: params?.workspaceDir,
env: params?.env,
bundledProviderAllowlistCompat: true,
bundledProviderVitestCompat: true,
})
.filter((provider): provider is ProviderPlugin & { docsPath: string } =>
Boolean(provider.docsPath?.trim()),