@@ -58,6 +58,7 @@ test('source authorization returns to its desktop screen and refreshes live', as
5858 let canceledSlackRequests = 0
5959 const personalAttempts = new Map < string , { session : string ; completed : boolean } > ( )
6060 let personalInventoryFailed = false
61+ let personalInventoryFailures = 0
6162 let javascript = ''
6263 let stylesheet = ''
6364 let origin = ''
@@ -196,6 +197,7 @@ test('source authorization returns to its desktop screen and refreshes live', as
196197 data : { url : `${ origin } /personal-provider?completionId=${ oauthCompletionId } ` } ,
197198 } )
198199 } else if ( personalInventoryFailed ) {
200+ personalInventoryFailures ++
199201 json ( { error : 'Inventory temporarily unavailable' } , 503 )
200202 } else {
201203 const attempt = personalAttempts . get ( url . searchParams . get ( 'completionId' ) ?? '' )
@@ -661,7 +663,7 @@ test('source authorization returns to its desktop screen and refreshes live', as
661663 await expect . poll ( ( ) => startSessions . length ) . toBe ( starts + 1 )
662664 await web . getByRole ( 'button' , { name : 'Cancel Slack request' , exact : true } ) . click ( )
663665 await expect . poll ( ( ) => canceledSlackRequests ) . toBe ( 1 )
664- await expect ( web . getByLabel ( 'Connection ', { exact : true } ) ) . toHaveText ( 'error' )
666+ await expect ( web . getByRole ( 'button ', { name : 'Connect Slack' , exact : true } ) ) . toBeEnabled ( )
665667 } finally {
666668 holdSlackStart = false
667669 }
@@ -677,9 +679,7 @@ test('source authorization returns to its desktop screen and refreshes live', as
677679 personalInventoryFailed = true
678680 await external . getByRole ( 'link' , { name : 'Authorize personal Search' } ) . click ( )
679681 await expect ( external ) . toHaveURL ( `${ origin } /desktop/done?kind=connect` )
680- await expect ( page . getByLabel ( 'Personal Search inventory error' ) ) . toHaveText (
681- 'Inventory temporarily unavailable'
682- )
682+ await expect . poll ( ( ) => personalInventoryFailures ) . toBeGreaterThan ( 0 )
683683 await expect (
684684 page . getByRole ( 'button' , { name : 'Connect personal Search' , exact : true } )
685685 ) . toBeEnabled ( )
@@ -688,24 +688,33 @@ test('source authorization returns to its desktop screen and refreshes live', as
688688 const entry = Object . entries ( localStorage ) . find ( ( [ key ] ) =>
689689 key . startsWith ( 'sim.search-connection.' )
690690 )
691- return entry ? ( JSON . parse ( entry [ 1 ] ) . completionId as string ) : null
691+ if ( ! entry ) return null
692+ const attempt : { completionId : string ; status : string ; credentialId ?: string } =
693+ JSON . parse ( entry [ 1 ] )
694+ return attempt
692695 } )
693696 const pendingReceipt = await receipt ( )
694- expect ( pendingReceipt ) . toBeTruthy ( )
697+ expect ( pendingReceipt ) . toMatchObject ( { status : 'pending' } )
695698 await page . getByRole ( 'button' , { name : 'Connect personal Search' , exact : true } ) . click ( )
696- expect ( await receipt ( ) ) . toBe ( pendingReceipt )
697- await expect ( page . getByLabel ( 'Personal Search pending' ) ) . toHaveText ( 'true' )
699+ expect ( await receipt ( ) ) . toEqual ( pendingReceipt )
698700 await page . getByRole ( 'button' , { name : 'Cancel personal Search' , exact : true } ) . click ( )
699- await expect ( page . getByLabel ( 'Personal Search pending' ) ) . toHaveText ( 'false' )
701+ await expect
702+ . poll ( receipt )
703+ . toMatchObject ( { completionId : pendingReceipt ?. completionId , status : 'failed' } )
700704 personalInventoryFailed = false
701705 await page . getByRole ( 'button' , { name : 'Retry personal inventory' , exact : true } ) . click ( )
702706 await page . getByRole ( 'button' , { name : 'Connect personal Search' , exact : true } ) . click ( )
703707 await expect . poll ( async ( ) => ( await opened ( ) ) . length ) . toBe ( previousOpens + 2 )
704- expect ( await receipt ( ) ) . not . toBe ( pendingReceipt )
708+ const retryReceipt = await receipt ( )
709+ expect ( retryReceipt ) . toMatchObject ( { status : 'pending' } )
710+ expect ( retryReceipt ?. completionId ) . not . toBe ( pendingReceipt ?. completionId )
705711 await external . goto ( ( await opened ( ) ) [ previousOpens + 1 ] )
706712 await external . getByRole ( 'link' , { name : 'Authorize personal Search' } ) . click ( )
707- await expect ( page . getByLabel ( 'Personal Search connected' ) ) . toHaveText ( 'true' )
708- await expect ( page . getByLabel ( 'Personal Search pending' ) ) . toHaveText ( 'false' )
713+ await expect . poll ( receipt ) . toMatchObject ( {
714+ completionId : retryReceipt ?. completionId ,
715+ status : 'connected' ,
716+ credentialId : 'fixture-personal-account' ,
717+ } )
709718 }
710719 )
711720 await page . screenshot ( { path : test . info ( ) . outputPath ( 'source-connect-desktop.png' ) } )
0 commit comments