
























@@ -1,4 +1,4 @@
1-import { describe, expect, it, vi } from "vitest";
1+import { beforeEach, describe, expect, it, vi } from "vitest";
22import type { RuntimeEnv } from "../runtime.js";
33import type { WizardPrompter } from "../wizard/prompts.js";
44@@ -10,6 +10,7 @@ const mocks = vi.hoisted(() => ({
1010promptCustomApiConfig: vi.fn(),
1111resolvePluginProviders: vi.fn(() => []),
1212resolveProviderPluginChoice: vi.fn<() => unknown>(() => null),
13+loadStaticManifestCatalogRowsForList: vi.fn(() => []),
1314resolvePreferredProviderForAuthChoice: vi.fn<() => Promise<string | undefined>>(
1415async () => undefined,
1516),
@@ -52,8 +53,16 @@ vi.mock("../plugins/provider-wizard.js", () => ({
5253resolveProviderPluginChoice: mocks.resolveProviderPluginChoice,
5354}));
545556+vi.mock("./models/list.manifest-catalog.js", () => ({
57+loadStaticManifestCatalogRowsForList: mocks.loadStaticManifestCatalogRowsForList,
58+}));
59+5560import { promptAuthConfig } from "./configure.gateway-auth.js";
566162+beforeEach(() => {
63+mocks.loadStaticManifestCatalogRowsForList.mockReturnValue([]);
64+});
65+5766function makeRuntime(): RuntimeEnv {
5867return {
5968log: vi.fn(),
@@ -311,6 +320,88 @@ describe("promptAuthConfig", () => {
311320);
312321});
313322323+it("loads plugin catalog when the selected provider allowlist requires it", async () => {
324+vi.clearAllMocks();
325+mocks.promptAuthChoiceGrouped.mockResolvedValue("github-copilot");
326+mocks.resolvePreferredProviderForAuthChoice.mockResolvedValue("github-copilot");
327+mocks.applyAuthChoice.mockResolvedValue({
328+config: {
329+agents: {
330+defaults: {
331+model: { primary: "anthropic/claude-opus-4-7" },
332+models: {
333+"github-copilot/claude-opus-4.7": {},
334+},
335+},
336+},
337+},
338+});
339+mocks.promptModelAllowlist.mockResolvedValue({ models: undefined });
340+mocks.resolveProviderPluginChoice.mockReturnValue({
341+provider: {
342+id: "github-copilot",
343+label: "GitHub Copilot",
344+auth: [],
345+wizard: {
346+setup: {
347+modelAllowlist: {
348+loadCatalog: true,
349+},
350+},
351+},
352+},
353+method: { id: "device", label: "GitHub device login", kind: "device_code" },
354+});
355+356+await promptAuthConfig({}, makeRuntime(), noopPrompter);
357+358+expect(mocks.promptModelAllowlist).toHaveBeenCalledWith(
359+expect.objectContaining({
360+preferredProvider: "github-copilot",
361+loadCatalog: true,
362+}),
363+);
364+});
365+366+it("loads catalog when the selected provider has manifest catalog rows", async () => {
367+vi.clearAllMocks();
368+mocks.promptAuthChoiceGrouped.mockResolvedValue("github-copilot");
369+mocks.resolvePreferredProviderForAuthChoice.mockResolvedValue("github-copilot");
370+mocks.applyAuthChoice.mockResolvedValue({
371+config: {
372+agents: {
373+defaults: {
374+models: {
375+"github-copilot/claude-opus-4.7": {},
376+},
377+},
378+},
379+},
380+});
381+mocks.promptModelAllowlist.mockResolvedValue({ models: undefined });
382+mocks.resolvePluginProviders.mockReturnValue([]);
383+mocks.resolveProviderPluginChoice.mockReturnValue(null);
384+mocks.loadStaticManifestCatalogRowsForList.mockReturnValue([
385+{
386+provider: "github-copilot",
387+id: "claude-opus-4.7",
388+name: "Claude Opus 4.7",
389+ref: "github-copilot/claude-opus-4.7",
390+mergeKey: "github-copilot:claude-opus-4.7",
391+source: "manifest",
392+input: ["text"],
393+reasoning: false,
394+status: "available",
395+},
396+]);
397+398+await promptAuthConfig({}, makeRuntime(), noopPrompter);
399+400+const call = mocks.promptModelAllowlist.mock.calls[0]?.[0];
401+expect(call?.preferredProvider).toBe("github-copilot");
402+expect(call?.loadCatalog).toBe(true);
403+});
404+314405it("returns to auth selection when plugin install onboarding asks for a retry", async () => {
315406vi.clearAllMocks();
316407mocks.promptAuthChoiceGrouped
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。