test: dedupe CLI onboard auth cases

This commit is contained in:
Peter Steinberger
2026-01-23 18:31:56 +00:00
parent 6d2a1ce217
commit ace6a42ea6

View File

@@ -122,142 +122,62 @@ describe("cli program (smoke)", () => {
expect(setupCommand).not.toHaveBeenCalled();
});
it("passes opencode-zen api key to onboard", async () => {
const program = buildProgram();
await program.parseAsync(
[
"onboard",
"--non-interactive",
"--auth-choice",
"opencode-zen",
"--opencode-zen-api-key",
"sk-opencode-zen-test",
],
{ from: "user" },
);
expect(onboardCommand).toHaveBeenCalledWith(
expect.objectContaining({
nonInteractive: true,
it("passes auth api keys to onboard", async () => {
const cases = [
{
authChoice: "opencode-zen",
opencodeZenApiKey: "sk-opencode-zen-test",
}),
runtime,
);
});
it("passes openrouter api key to onboard", async () => {
const program = buildProgram();
await program.parseAsync(
[
"onboard",
"--non-interactive",
"--auth-choice",
"openrouter-api-key",
"--openrouter-api-key",
"sk-openrouter-test",
],
{ from: "user" },
);
expect(onboardCommand).toHaveBeenCalledWith(
expect.objectContaining({
nonInteractive: true,
flag: "--opencode-zen-api-key",
key: "sk-opencode-zen-test",
field: "opencodeZenApiKey",
},
{
authChoice: "openrouter-api-key",
openrouterApiKey: "sk-openrouter-test",
}),
runtime,
);
});
it("passes moonshot api key to onboard", async () => {
const program = buildProgram();
await program.parseAsync(
[
"onboard",
"--non-interactive",
"--auth-choice",
"moonshot-api-key",
"--moonshot-api-key",
"sk-moonshot-test",
],
{ from: "user" },
);
expect(onboardCommand).toHaveBeenCalledWith(
expect.objectContaining({
nonInteractive: true,
flag: "--openrouter-api-key",
key: "sk-openrouter-test",
field: "openrouterApiKey",
},
{
authChoice: "moonshot-api-key",
moonshotApiKey: "sk-moonshot-test",
}),
runtime,
);
});
it("passes kimi code api key to onboard", async () => {
const program = buildProgram();
await program.parseAsync(
[
"onboard",
"--non-interactive",
"--auth-choice",
"kimi-code-api-key",
"--kimi-code-api-key",
"sk-kimi-code-test",
],
{ from: "user" },
);
expect(onboardCommand).toHaveBeenCalledWith(
expect.objectContaining({
nonInteractive: true,
flag: "--moonshot-api-key",
key: "sk-moonshot-test",
field: "moonshotApiKey",
},
{
authChoice: "kimi-code-api-key",
kimiCodeApiKey: "sk-kimi-code-test",
}),
runtime,
);
});
it("passes synthetic api key to onboard", async () => {
const program = buildProgram();
await program.parseAsync(
[
"onboard",
"--non-interactive",
"--auth-choice",
"synthetic-api-key",
"--synthetic-api-key",
"sk-synthetic-test",
],
{ from: "user" },
);
expect(onboardCommand).toHaveBeenCalledWith(
expect.objectContaining({
nonInteractive: true,
flag: "--kimi-code-api-key",
key: "sk-kimi-code-test",
field: "kimiCodeApiKey",
},
{
authChoice: "synthetic-api-key",
syntheticApiKey: "sk-synthetic-test",
}),
runtime,
);
});
it("passes zai api key to onboard", async () => {
const program = buildProgram();
await program.parseAsync(
[
"onboard",
"--non-interactive",
"--auth-choice",
"zai-api-key",
"--zai-api-key",
"sk-zai-test",
],
{ from: "user" },
);
expect(onboardCommand).toHaveBeenCalledWith(
expect.objectContaining({
nonInteractive: true,
flag: "--synthetic-api-key",
key: "sk-synthetic-test",
field: "syntheticApiKey",
},
{
authChoice: "zai-api-key",
zaiApiKey: "sk-zai-test",
}),
runtime,
);
flag: "--zai-api-key",
key: "sk-zai-test",
field: "zaiApiKey",
},
] as const;
for (const entry of cases) {
const program = buildProgram();
await program.parseAsync(
["onboard", "--non-interactive", "--auth-choice", entry.authChoice, entry.flag, entry.key],
{ from: "user" },
);
expect(onboardCommand).toHaveBeenCalledWith(
expect.objectContaining({
nonInteractive: true,
authChoice: entry.authChoice,
[entry.field]: entry.key,
}),
runtime,
);
onboardCommand.mockClear();
}
});
it("runs channels login", async () => {