@@ -387,6 +387,57 @@ suite("cloud/auth", () => {
387387 await provider . dispose ( )
388388 } )
389389
390+ test ( "shows notification after device code sign-in" , async ( ) => {
391+ fsStub . fake . readFile . rejects ( new Error ( "File not found" ) )
392+
393+ const token = validToken ( )
394+ const fetchStub = sinon . stub ( globalThis , "fetch" )
395+ fetchStub . onFirstCall ( ) . resolves (
396+ mockResponse ( {
397+ device_code : "dev123" ,
398+ user_code : "USER-CODE" ,
399+ verification_uri : "https://auth.example.com/device" ,
400+ verification_uri_complete :
401+ "https://auth.example.com/device?code=USER-CODE" ,
402+ interval : 1 ,
403+ } ) ,
404+ )
405+ fetchStub . onSecondCall ( ) . resolves ( mockResponse ( { access_token : token } ) )
406+ fetchStub
407+ . onThirdCall ( )
408+ . resolves (
409+ mockResponse ( { email : "new@example.com" , full_name : "New" } ) ,
410+ )
411+
412+ sinon . stub ( vscode . env , "openExternal" )
413+ sinon
414+ . stub ( vscode . window , "withProgress" )
415+ . callsFake ( async ( _opts , task ) => {
416+ const cancellationToken = {
417+ isCancellationRequested : false ,
418+ onCancellationRequested : sinon . stub ( ) ,
419+ }
420+ return task ( { report : sinon . stub ( ) } , cancellationToken as any )
421+ } )
422+ const infoStub = sinon . stub ( vscode . window , "showInformationMessage" )
423+
424+ fsStub . fake . createDirectory . resolves ( )
425+ fsStub . fake . writeFile . callsFake ( async ( ) => {
426+ fsStub . fake . readFile . resolves (
427+ Buffer . from ( JSON . stringify ( { access_token : token } ) ) ,
428+ )
429+ } )
430+
431+ const { provider } = createProvider ( )
432+ await provider . createSession ( )
433+
434+ assert . ok (
435+ infoStub . calledWith ( "Signed in to FastAPI Cloud as new@example.com" ) ,
436+ )
437+
438+ await provider . dispose ( )
439+ } )
440+
390441 test ( "wraps network error with friendly message" , async ( ) => {
391442 fsStub . fake . readFile . rejects ( new Error ( "File not found" ) )
392443
0 commit comments