fix: stabilize session tools and tests

This commit is contained in:
Peter Steinberger
2026-01-12 18:17:17 +00:00
parent 3ffb9a3b5e
commit 77b20377cc
4 changed files with 77 additions and 67 deletions

View File

@@ -14,35 +14,39 @@ vi.mock("../commands/models.js", async () => {
});
describe("models cli", () => {
it("registers github-copilot login command", async () => {
const { Command } = await import("commander");
const { registerModelsCli } = await import("./models-cli.js");
it(
"registers github-copilot login command",
{ timeout: 15_000 },
async () => {
const { Command } = await import("commander");
const { registerModelsCli } = await import("./models-cli.js");
const program = new Command();
registerModelsCli(program);
const program = new Command();
registerModelsCli(program);
const models = program.commands.find((cmd) => cmd.name() === "models");
expect(models).toBeTruthy();
const models = program.commands.find((cmd) => cmd.name() === "models");
expect(models).toBeTruthy();
const auth = models?.commands.find((cmd) => cmd.name() === "auth");
expect(auth).toBeTruthy();
const auth = models?.commands.find((cmd) => cmd.name() === "auth");
expect(auth).toBeTruthy();
const login = auth?.commands.find(
(cmd) => cmd.name() === "login-github-copilot",
);
expect(login).toBeTruthy();
const login = auth?.commands.find(
(cmd) => cmd.name() === "login-github-copilot",
);
expect(login).toBeTruthy();
await program.parseAsync(
["models", "auth", "login-github-copilot", "--yes"],
{
from: "user",
},
);
await program.parseAsync(
["models", "auth", "login-github-copilot", "--yes"],
{
from: "user",
},
);
expect(githubCopilotLoginCommand).toHaveBeenCalledTimes(1);
expect(githubCopilotLoginCommand).toHaveBeenCalledWith(
expect.objectContaining({ yes: true }),
expect.any(Object),
);
}, 15_000);
expect(githubCopilotLoginCommand).toHaveBeenCalledTimes(1);
expect(githubCopilotLoginCommand).toHaveBeenCalledWith(
expect.objectContaining({ yes: true }),
expect.any(Object),
);
},
);
});