Skip to content

Commit 00d7a8d

Browse files
committed
test(cli): cover all auth agent leaves
1 parent f269cbb commit 00d7a8d

1 file changed

Lines changed: 57 additions & 3 deletions

File tree

‎src/cli/models-cli.test.ts‎

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const mocks = vi.hoisted(() => ({
1515
modelsAuthListCommand: vi.fn().mockResolvedValue(undefined),
1616
modelsAuthLoginCommand: vi.fn().mockResolvedValue(undefined),
1717
modelsAuthLogoutCommand: vi.fn().mockResolvedValue(undefined),
18+
modelsAuthOrderClearCommand: vi.fn().mockResolvedValue(undefined),
19+
modelsAuthOrderGetCommand: vi.fn().mockResolvedValue(undefined),
20+
modelsAuthOrderSetCommand: vi.fn().mockResolvedValue(undefined),
1821
modelsAuthPasteApiKeyCommand: vi.fn().mockResolvedValue(undefined),
1922
modelsAuthPasteTokenCommand: vi.fn().mockResolvedValue(undefined),
2023
modelsAuthSetupTokenCommand: vi.fn().mockResolvedValue(undefined),
@@ -25,6 +28,9 @@ const {
2528
modelsAuthListCommand,
2629
modelsAuthLoginCommand,
2730
modelsAuthLogoutCommand,
31+
modelsAuthOrderClearCommand,
32+
modelsAuthOrderGetCommand,
33+
modelsAuthOrderSetCommand,
2834
modelsAuthPasteApiKeyCommand,
2935
modelsAuthPasteTokenCommand,
3036
modelsAuthSetupTokenCommand,
@@ -53,9 +59,9 @@ vi.mock("../commands/models/auth-logout.js", () => ({
5359
modelsAuthLogoutCommand: mocks.modelsAuthLogoutCommand,
5460
}));
5561
vi.mock("../commands/models/auth-order.js", () => ({
56-
modelsAuthOrderClearCommand: mocks.noopAsync,
57-
modelsAuthOrderGetCommand: mocks.noopAsync,
58-
modelsAuthOrderSetCommand: mocks.noopAsync,
62+
modelsAuthOrderClearCommand: mocks.modelsAuthOrderClearCommand,
63+
modelsAuthOrderGetCommand: mocks.modelsAuthOrderGetCommand,
64+
modelsAuthOrderSetCommand: mocks.modelsAuthOrderSetCommand,
5965
}));
6066
vi.mock("../commands/models/aliases.js", () => ({
6167
modelsAliasesAddCommand: mocks.noopAsync,
@@ -91,6 +97,9 @@ describe("models cli", () => {
9197
modelsAuthListCommand.mockClear();
9298
modelsAuthLoginCommand.mockClear();
9399
modelsAuthLogoutCommand.mockClear();
100+
modelsAuthOrderClearCommand.mockClear();
101+
modelsAuthOrderGetCommand.mockClear();
102+
modelsAuthOrderSetCommand.mockClear();
94103
modelsAuthPasteApiKeyCommand.mockClear();
95104
modelsAuthPasteTokenCommand.mockClear();
96105
modelsAuthSetupTokenCommand.mockClear();
@@ -289,12 +298,24 @@ describe("models cli", () => {
289298
command: modelsAuthAddCommand,
290299
expected: { agent: "poe" },
291300
},
301+
{
302+
label: "list",
303+
args: ["models", "auth", "list", "--provider", "openai", "--agent", "poe"],
304+
command: modelsAuthListCommand,
305+
expected: { agent: "poe", provider: "openai" },
306+
},
292307
{
293308
label: "login",
294309
args: ["models", "auth", "login", "--provider", "openai", "--agent", "poe"],
295310
command: modelsAuthLoginCommand,
296311
expected: { agent: "poe", provider: "openai" },
297312
},
313+
{
314+
label: "logout",
315+
args: ["models", "auth", "logout", "openai:manual", "--yes", "--agent", "poe"],
316+
command: modelsAuthLogoutCommand,
317+
expected: { agent: "poe", profileId: "openai:manual", yes: true },
318+
},
298319
{
299320
label: "setup-token",
300321
args: ["models", "auth", "setup-token", "--provider", "anthropic", "--agent", "poe"],
@@ -319,6 +340,39 @@ describe("models cli", () => {
319340
command: modelsAuthLoginCommand,
320341
expected: { agent: "poe", provider: "github-copilot", method: "device", yes: true },
321342
},
343+
{
344+
label: "order get",
345+
args: ["models", "auth", "order", "get", "--provider", "anthropic", "--agent", "poe"],
346+
command: modelsAuthOrderGetCommand,
347+
expected: { agent: "poe", provider: "anthropic" },
348+
},
349+
{
350+
label: "order set",
351+
args: [
352+
"models",
353+
"auth",
354+
"order",
355+
"set",
356+
"--provider",
357+
"anthropic",
358+
"anthropic:first",
359+
"anthropic:second",
360+
"--agent",
361+
"poe",
362+
],
363+
command: modelsAuthOrderSetCommand,
364+
expected: {
365+
agent: "poe",
366+
provider: "anthropic",
367+
order: ["anthropic:first", "anthropic:second"],
368+
},
369+
},
370+
{
371+
label: "order clear",
372+
args: ["models", "auth", "order", "clear", "--provider", "anthropic", "--agent", "poe"],
373+
command: modelsAuthOrderClearCommand,
374+
expected: { agent: "poe", provider: "anthropic" },
375+
},
322376
])("passes leaf --agent to models auth $label", async ({ args, command, expected }) => {
323377
await runModelsCommand(args);
324378

0 commit comments

Comments
 (0)