From 991da294814a3837d52f15b30533eb9ac34a27ea Mon Sep 17 00:00:00 2001 From: Ayaan Zaidi Date: Wed, 29 Apr 2026 17:33:01 +0530 Subject: [PATCH] test(configure): cover provider-scoped catalog prompts --- ...re.gateway-auth.prompt-auth-config.test.ts | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/commands/configure.gateway-auth.prompt-auth-config.test.ts b/src/commands/configure.gateway-auth.prompt-auth-config.test.ts index 41cca5989ef..8502ded08dc 100644 --- a/src/commands/configure.gateway-auth.prompt-auth-config.test.ts +++ b/src/commands/configure.gateway-auth.prompt-auth-config.test.ts @@ -288,6 +288,78 @@ describe("promptAuthConfig", () => { ); }); + it("keeps the selected provider scope when existing config has another provider", async () => { + vi.clearAllMocks(); + mocks.promptAuthChoiceGrouped.mockResolvedValue("github-copilot"); + mocks.resolvePreferredProviderForAuthChoice.mockResolvedValue("github-copilot"); + const existingConfig = { + agents: { + defaults: { + model: { primary: "ollama/deepseek-v4-pro" }, + }, + }, + models: { + providers: { + ollama: { + baseUrl: "https://ollama.com", + api: "ollama", + models: [{ id: "deepseek-v4-pro", name: "deepseek-v4-pro" }], + }, + }, + }, + }; + mocks.applyAuthChoice.mockResolvedValue({ config: existingConfig }); + mocks.promptModelAllowlist.mockResolvedValue({ models: undefined }); + mocks.resolveProviderPluginChoice.mockReturnValue(null); + + await promptAuthConfig(existingConfig, makeRuntime(), noopPrompter); + + expect(mocks.promptModelAllowlist).toHaveBeenCalledWith( + expect.objectContaining({ + preferredProvider: "github-copilot", + }), + ); + }); + + it("loads the selected provider catalog after auth enables that plugin", async () => { + vi.clearAllMocks(); + mocks.promptAuthChoiceGrouped.mockResolvedValue("github-copilot"); + mocks.resolvePreferredProviderForAuthChoice.mockResolvedValue("github-copilot"); + const existingConfig = { + agents: { defaults: { model: { primary: "ollama/deepseek-v4-pro" } } }, + models: { + providers: { + ollama: { + baseUrl: "https://ollama.com", + api: "ollama", + models: [{ id: "deepseek-v4-pro", name: "deepseek-v4-pro" }], + }, + }, + }, + }; + mocks.applyAuthChoice.mockResolvedValue({ + config: { + ...existingConfig, + plugins: { entries: { "github-copilot": { enabled: true } } }, + }, + }); + mocks.loadStaticManifestCatalogRowsForList.mockReturnValueOnce([ + { + ref: "github-copilot/claude-opus-4.7", + provider: "github-copilot", + id: "claude-opus-4.7", + name: "Claude Opus 4.7", + }, + ]); + mocks.promptModelAllowlist.mockResolvedValue({ models: undefined }); + mocks.resolveProviderPluginChoice.mockReturnValue(null); + + await promptAuthConfig(existingConfig, makeRuntime(), noopPrompter); + + expect(mocks.promptModelAllowlist.mock.calls[0]?.[0]?.preferredProvider).toBe("github-copilot"); + expect(mocks.promptModelAllowlist.mock.calls[0]?.[0]?.loadCatalog).toBe(true); + }); + it("loads configured provider models after Ollama Cloud + Local and Cloud only setup", async () => { vi.clearAllMocks(); mocks.promptAuthChoiceGrouped.mockResolvedValue("ollama");