From ace6a42ea617bdbe3adabd6e4a3316d12eca3ff0 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 23 Jan 2026 18:31:56 +0000 Subject: [PATCH] test: dedupe CLI onboard auth cases --- src/cli/program.smoke.test.ts | 180 ++++++++++------------------------ 1 file changed, 50 insertions(+), 130 deletions(-) diff --git a/src/cli/program.smoke.test.ts b/src/cli/program.smoke.test.ts index 10ebc9188..3dc01fcb2 100644 --- a/src/cli/program.smoke.test.ts +++ b/src/cli/program.smoke.test.ts @@ -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 () => {