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