refactor(plugins): simplify provider auth choice metadata

This commit is contained in:
Peter Steinberger
2026-03-15 23:00:16 -07:00
parent c4b18ab3c9
commit ddd34b6cc3
19 changed files with 415 additions and 98 deletions

View File

@@ -2,18 +2,17 @@ import { Command } from "commander";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { runRegisteredCli } from "../test-utils/command-runner.js";
const githubCopilotLoginCommand = vi.fn();
const modelsStatusCommand = vi.fn().mockResolvedValue(undefined);
const noopAsync = vi.fn(async () => undefined);
const modelsAuthLoginCommand = vi.fn().mockResolvedValue(undefined);
vi.mock("../commands/models.js", () => ({
githubCopilotLoginCommand,
modelsStatusCommand,
modelsAliasesAddCommand: noopAsync,
modelsAliasesListCommand: noopAsync,
modelsAliasesRemoveCommand: noopAsync,
modelsAuthAddCommand: noopAsync,
modelsAuthLoginCommand: noopAsync,
modelsAuthLoginCommand,
modelsAuthOrderClearCommand: noopAsync,
modelsAuthOrderGetCommand: noopAsync,
modelsAuthOrderSetCommand: noopAsync,
@@ -42,7 +41,7 @@ describe("models cli", () => {
});
beforeEach(() => {
githubCopilotLoginCommand.mockClear();
modelsAuthLoginCommand.mockClear();
modelsStatusCommand.mockClear();
});
@@ -74,9 +73,13 @@ describe("models cli", () => {
from: "user",
});
expect(githubCopilotLoginCommand).toHaveBeenCalledTimes(1);
expect(githubCopilotLoginCommand).toHaveBeenCalledWith(
expect.objectContaining({ yes: true }),
expect(modelsAuthLoginCommand).toHaveBeenCalledTimes(1);
expect(modelsAuthLoginCommand).toHaveBeenCalledWith(
expect.objectContaining({
provider: "github-copilot",
method: "device",
yes: true,
}),
expect.any(Object),
);
});