@@ -550,94 +550,6 @@ describe('Passport', () => {
550550 expect ( getUserMock ) . toBeCalledTimes ( 1 ) ;
551551 expect ( authLoginMock ) . toBeCalledTimes ( 1 ) ;
552552 } ) ;
553-
554- it ( 'should debounce concurrent login calls and return the same result' , async ( ) => {
555- getUserMock . mockReturnValue ( null ) ;
556- authLoginMock . mockReturnValue ( mockUserImx ) ;
557-
558- // Make multiple concurrent login calls
559- const loginPromise1 = passport . login ( ) ;
560- const loginPromise2 = passport . login ( ) ;
561- const loginPromise3 = passport . login ( ) ;
562-
563- // All promises should be the same reference
564- expect ( loginPromise1 ) . toEqual ( loginPromise2 ) ;
565- expect ( loginPromise2 ) . toEqual ( loginPromise3 ) ;
566-
567- // Wait for all to complete
568- const [ result1 , result2 , result3 ] = await Promise . all ( [
569- loginPromise1 ,
570- loginPromise2 ,
571- loginPromise3 ,
572- ] ) ;
573-
574- // All results should be the same
575- expect ( result1 ) . toEqual ( mockUserImx . profile ) ;
576- expect ( result2 ) . toEqual ( mockUserImx . profile ) ;
577- expect ( result3 ) . toEqual ( mockUserImx . profile ) ;
578-
579- // AuthManager.login should only be called once despite multiple login calls
580- expect ( authLoginMock ) . toBeCalledTimes ( 1 ) ;
581- } ) ;
582-
583- it ( 'should reset login promise after successful completion and allow new login calls' , async ( ) => {
584- getUserMock . mockReturnValue ( null ) ;
585- authLoginMock . mockReturnValue ( mockUserImx ) ;
586-
587- // First login call
588- const firstLoginResult = await passport . login ( ) ;
589- expect ( firstLoginResult ) . toEqual ( mockUserImx . profile ) ;
590-
591- // Second login call after first completes should create a new login process
592- const secondLoginResult = await passport . login ( ) ;
593- expect ( secondLoginResult ) . toEqual ( mockUserImx . profile ) ;
594-
595- // AuthManager.login should be called twice (once for each login)
596- expect ( authLoginMock ) . toBeCalledTimes ( 2 ) ;
597- } ) ;
598-
599- it ( 'should reset login promise after failed completion and allow new login calls' , async ( ) => {
600- const error = new Error ( 'Login failed' ) ;
601- getUserMock . mockReturnValue ( null ) ;
602- authLoginMock . mockRejectedValue ( error ) ;
603-
604- // First login call should fail
605- await expect ( passport . login ( ) ) . rejects . toThrow ( error ) ;
606-
607- // Second login call after first fails should create a new login process
608- authLoginMock . mockReturnValue ( mockUserImx ) ;
609- const secondLoginResult = await passport . login ( ) ;
610- expect ( secondLoginResult ) . toEqual ( mockUserImx . profile ) ;
611-
612- // AuthManager.login should be called twice (once for failed, once for successful)
613- expect ( authLoginMock ) . toBeCalledTimes ( 2 ) ;
614- } ) ;
615-
616- it ( 'should debounce concurrent login calls even when they fail' , async ( ) => {
617- const error = new Error ( 'Login failed' ) ;
618- getUserMock . mockReturnValue ( null ) ;
619- authLoginMock . mockRejectedValue ( error ) ;
620-
621- // Make multiple concurrent login calls that will fail
622- const [ loginPromise1 , loginPromise2 , loginPromise3 ] = [
623- passport . login ( ) ,
624- passport . login ( ) ,
625- passport . login ( ) ,
626- ] ;
627-
628- // All promises should be the same reference
629- expect ( loginPromise1 ) . toEqual ( loginPromise2 ) ;
630- expect ( loginPromise2 ) . toEqual ( loginPromise3 ) ;
631-
632- // All should reject with the same error
633- try {
634- await Promise . all ( [ loginPromise1 , loginPromise2 , loginPromise3 ] ) ;
635- } catch ( e : unknown ) {
636- expect ( e ) . toEqual ( error ) ;
637- // AuthManager.login should only be called once despite multiple login calls
638- expect ( authLoginMock ) . toBeCalledTimes ( 1 ) ;
639- }
640- } ) ;
641553 } ) ;
642554
643555 describe ( 'linkExternalWallet' , ( ) => {
0 commit comments