test: dedupe CLI onboard auth cases
This commit is contained in:
@@ -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",
|
||||||
);
|
},
|
||||||
});
|
{
|
||||||
|
|
||||||
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,
|
|
||||||
authChoice: "zai-api-key",
|
authChoice: "zai-api-key",
|
||||||
zaiApiKey: "sk-zai-test",
|
flag: "--zai-api-key",
|
||||||
}),
|
key: "sk-zai-test",
|
||||||
runtime,
|
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 () => {
|
it("runs channels login", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user