@@ -153,18 +153,15 @@ describe("LoginCoordinator", () => {
153153 createTestContext ( ) ;
154154 const user = createMockUser ( ) ;
155155
156- // First call fails (no token), second succeeds after user enters token
157- mockAdapter
158- . mockRejectedValueOnce ( {
159- response : { status : 401 , data : { message : "Unauthorized" } } ,
160- } )
161- . mockResolvedValueOnce ( {
162- data : user ,
163- status : 200 ,
164- statusText : "OK" ,
165- headers : { } ,
166- config : { } ,
167- } ) ;
156+ // No stored token, so goes directly to input box flow
157+ // Mock succeeds when validateInput calls getAuthenticatedUser
158+ mockAdapter . mockResolvedValueOnce ( {
159+ data : user ,
160+ status : 200 ,
161+ statusText : "OK" ,
162+ headers : { } ,
163+ config : { } ,
164+ } ) ;
168165
169166 // User enters a new token in the input box
170167 userInteraction . setInputBoxValue ( "new-token" ) ;
@@ -198,9 +195,12 @@ describe("LoginCoordinator", () => {
198195
199196 describe ( "same-window guard" , ( ) => {
200197 it ( "prevents duplicate login calls for same hostname" , async ( ) => {
201- const { mockAdapter, coordinator } = createTestContext ( ) ;
198+ const { mockAdapter, userInteraction , coordinator } = createTestContext ( ) ;
202199 const user = createMockUser ( ) ;
203200
201+ // User enters a token in the input box
202+ userInteraction . setInputBoxValue ( "new-token" ) ;
203+
204204 let resolveAuth : ( value : unknown ) => void ;
205205 mockAdapter . mockReturnValue (
206206 new Promise ( ( resolve ) => {
@@ -220,7 +220,7 @@ describe("LoginCoordinator", () => {
220220 safeHostname : TEST_HOSTNAME ,
221221 } ) ;
222222
223- // Resolve the auth
223+ // Resolve the auth (this validates the token from input box)
224224 resolveAuth ! ( {
225225 data : user ,
226226 status : 200 ,
@@ -234,8 +234,8 @@ describe("LoginCoordinator", () => {
234234 expect ( result1 . success ) . toBe ( true ) ;
235235 expect ( result1 ) . toEqual ( result2 ) ;
236236
237- // Adapter should only be called once (guard prevents duplicate requests )
238- expect ( mockAdapter ) . toHaveBeenCalledTimes ( 1 ) ;
237+ // Input box should only be shown once (guard prevents duplicate prompts )
238+ expect ( vscode . window . showInputBox ) . toHaveBeenCalledTimes ( 1 ) ;
239239 } ) ;
240240 } ) ;
241241
0 commit comments