@@ -5,7 +5,7 @@ import * as path from "path";
55import { afterEach , beforeEach , describe , expect , test , vi } from "vitest" ;
66
77import type { AuthConfig } from "./auth/workos.js" ;
8- import { runNormalFlow } from "./onboarding.js" ;
8+ import { initializeWithOnboarding } from "./onboarding.js" ;
99
1010describe ( "onboarding config flag handling" , ( ) => {
1111 let tempDir : string ;
@@ -40,7 +40,9 @@ describe("onboarding config flag handling", () => {
4040 expect ( fs . existsSync ( configPath ) ) . toBe ( false ) ;
4141
4242 // Should throw an error that mentions both the path and the failure
43- await expect ( runNormalFlow ( mockAuthConfig , configPath ) ) . rejects . toThrow (
43+ await expect (
44+ initializeWithOnboarding ( mockAuthConfig , configPath ) ,
45+ ) . rejects . toThrow (
4446 / F a i l e d t o l o a d c o n f i g f r o m " .* n o n - e x i s t e n t \. y a m l " : .* E N O E N T / ,
4547 ) ;
4648 } ) ;
@@ -64,9 +66,9 @@ models:
6466 expect ( fs . existsSync ( configPath ) ) . toBe ( true ) ;
6567
6668 // Should throw an error mentioning the path and failure to load
67- await expect ( runNormalFlow ( mockAuthConfig , configPath ) ) . rejects . toThrow (
68- / F a i l e d t o l o a d c o n f i g f r o m " . * m a l f o r m e d \. y a m l " : . + / ,
69- ) ;
69+ await expect (
70+ initializeWithOnboarding ( mockAuthConfig , configPath ) ,
71+ ) . rejects . toThrow ( / F a i l e d t o l o a d c o n f i g f r o m " . * m a l f o r m e d \. y a m l " : . + / ) ;
7072 } ) ;
7173
7274 test ( "should fail loudly when --config points to file with missing required fields" , async ( ) => {
@@ -85,9 +87,9 @@ name: "Incomplete Config"
8587 expect ( fs . existsSync ( configPath ) ) . toBe ( true ) ;
8688
8789 // Should throw with our specific error format and include path
88- await expect ( runNormalFlow ( mockAuthConfig , configPath ) ) . rejects . toThrow (
89- / ^ F a i l e d t o l o a d c o n f i g f r o m " . * " : . + / ,
90- ) ;
90+ await expect (
91+ initializeWithOnboarding ( mockAuthConfig , configPath ) ,
92+ ) . rejects . toThrow ( / ^ F a i l e d t o l o a d c o n f i g f r o m " . * " : . + / ) ;
9193 } ) ;
9294
9395 test ( "should handle different config path formats with proper error messages" , async ( ) => {
@@ -99,16 +101,18 @@ name: "Incomplete Config"
99101 ] ;
100102
101103 for ( const configPath of testPaths ) {
102- await expect ( runNormalFlow ( mockAuthConfig , configPath ) ) . rejects . toThrow (
103- / F a i l e d t o l o a d c o n f i g f r o m " . * " : . + / ,
104- ) ;
104+ await expect (
105+ initializeWithOnboarding ( mockAuthConfig , configPath ) ,
106+ ) . rejects . toThrow ( / F a i l e d t o l o a d c o n f i g f r o m " . * " : . + / ) ;
105107 }
106108 } ) ;
107109
108110 test ( "should handle empty string config path" , async ( ) => {
109111 // Empty string should be treated differently from undefined
110112 // Note: empty string triggers onboarding flow, but should still fail in our error format
111- await expect ( runNormalFlow ( mockAuthConfig , "" ) ) . rejects . toThrow ( ) ;
113+ await expect (
114+ initializeWithOnboarding ( mockAuthConfig , "" ) ,
115+ ) . rejects . toThrow ( ) ;
112116 } ) ;
113117
114118 test ( "should not fall back to default config when explicit config fails" , async ( ) => {
@@ -117,7 +121,7 @@ name: "Incomplete Config"
117121 // Create a bad config file
118122 fs . writeFileSync ( configPath , "invalid: yaml: content: [" ) ;
119123
120- const promise = runNormalFlow ( mockAuthConfig , configPath ) ;
124+ const promise = initializeWithOnboarding ( mockAuthConfig , configPath ) ;
121125
122126 await expect ( promise ) . rejects . toThrow ( ) ;
123127
@@ -144,13 +148,13 @@ name: "Incomplete Config"
144148 fs . writeFileSync ( badConfigPath , "invalid yaml [" ) ;
145149
146150 // Case 1: Explicit --config that fails should throw our specific error
147- await expect ( runNormalFlow ( mockAuthConfig , badConfigPath ) ) . rejects . toThrow (
148- / ^ F a i l e d t o l o a d c o n f i g f r o m " / ,
149- ) ;
151+ await expect (
152+ initializeWithOnboarding ( mockAuthConfig , badConfigPath ) ,
153+ ) . rejects . toThrow ( / ^ F a i l e d t o l o a d c o n f i g f r o m " / ) ;
150154
151155 // Case 2: No explicit config should follow different logic
152156 try {
153- await runNormalFlow ( mockAuthConfig , undefined ) ;
157+ await initializeWithOnboarding ( mockAuthConfig , undefined ) ;
154158 // If it succeeds, that's fine - the point is it's different behavior
155159 } catch ( error ) {
156160 const errorMessage =
@@ -213,9 +217,9 @@ describe("CONTINUE_USE_BEDROCK environment variable", () => {
213217 vi . resetModules ( ) ;
214218 const { runOnboardingFlow } = await import ( "./onboarding.js" ) ;
215219
216- const result = await runOnboardingFlow ( undefined , mockAuthConfig ) ;
220+ const result = await runOnboardingFlow ( undefined ) ;
217221
218- expect ( result . wasOnboarded ) . toBe ( true ) ;
222+ expect ( result ) . toBe ( true ) ;
219223 expect ( mockConsoleLog ) . toHaveBeenCalledWith (
220224 expect . stringContaining (
221225 "✓ Using AWS Bedrock (CONTINUE_USE_BEDROCK detected)" ,
@@ -235,7 +239,7 @@ describe("CONTINUE_USE_BEDROCK environment variable", () => {
235239 process . stdin . isTTY = false ;
236240
237241 try {
238- await runOnboardingFlow ( undefined , mockAuthConfig ) ;
242+ await runOnboardingFlow ( undefined ) ;
239243
240244 // Verify the Bedrock message was NOT called by checking all calls
241245 const allCalls = mockConsoleLog . mock . calls . flat ( ) ;
0 commit comments