@@ -551,6 +551,8 @@ describe('Slack member access selection', () => {
551551 { enabled : true , needsValidation : true , sharedAppAvailable : true } ,
552552 { enabled : true , needsValidation : false , sharedAppAvailable : false } ,
553553 ] ) ( 'keeps incomplete shared app setup actionable: %j' , async ( status ) => {
554+ const accounts = mocks . accounts ( )
555+ accounts . data . credentialGroup . options [ 0 ] . configurationStatus = 'needs_update'
554556 mocks . apps . mockReturnValue ( {
555557 isSuccess : true ,
556558 isPending : false ,
@@ -575,11 +577,12 @@ describe('Slack member access selection', () => {
575577 await render ( undefined , [ ] , 'org-1' )
576578 expect ( document . body . textContent ) . toContain ( 'Manage Sim Search app' )
577579 expect ( document . body . textContent ) . not . toContain ( 'Verify and add' )
580+ expect ( document . body . textContent ) . not . toContain ( 'Update member access' )
578581 expect ( mocks . onOpenChange ) . not . toHaveBeenCalled ( )
579582 expect ( mocks . start ) . not . toHaveBeenCalled ( )
580583 } )
581584
582- it . each ( [ 'removed' , 'needs_update' , 'pending' , 'error' , 'refreshing' ] ) (
585+ it . each ( [ 'removed' , 'needs_update' , 'needs_update_failed' , ' pending', 'error' , 'refreshing' ] ) (
583586 'does not skip shared setup when member configuration is %s' ,
584587 async ( state ) => {
585588 mocks . apps . mockReturnValue ( {
@@ -623,8 +626,7 @@ describe('Slack member access selection', () => {
623626 {
624627 provider : 'slack' ,
625628 status : 'active' ,
626- configurationStatus :
627- state === 'needs_update' ? 'needs_update' : 'ready' ,
629+ configurationStatus : 'needs_update' ,
628630 } ,
629631 ] ,
630632 } ,
@@ -635,12 +637,39 @@ describe('Slack member access selection', () => {
635637 expect ( mocks . start ) . not . toHaveBeenCalled ( )
636638 if ( state === 'error' ) {
637639 expect ( document . body . textContent ) . toContain ( 'Could not load member setup' )
640+ expect ( document . body . textContent ) . not . toContain ( 'Update member access' )
638641 await clickButton ( 'Retry' )
639642 expect ( mocks . refetchAccounts ) . toHaveBeenCalledOnce ( )
640643 } else if ( state === 'pending' || state === 'refreshing' ) {
641644 expect ( document . body . textContent ) . toContain ( 'Checking the installed Slack app' )
645+ expect ( document . body . textContent ) . not . toContain ( 'Update member access' )
646+ } else if ( state === 'needs_update' || state === 'needs_update_failed' ) {
647+ expect ( document . body . textContent ) . toContain ( 'Member access is outdated' )
648+ if ( state === 'needs_update_failed' )
649+ mocks . start . mockRejectedValueOnce ( new Error ( 'Try again' ) )
650+ await clickButton ( 'Update member access' )
651+ expect ( mocks . start ) . toHaveBeenCalledExactlyOnceWith ( {
652+ organizationId : 'org-1' ,
653+ credentialGroupId : 'group-1' ,
654+ body : {
655+ appId : 'A_SHARED' ,
656+ teamId : 'T_TEAM' ,
657+ requiredScopes : [ ...SLACK_SEARCH_USER_SCOPES ] ,
658+ } ,
659+ } )
660+ expect ( mocks . install ) . not . toHaveBeenCalled ( )
661+ if ( state === 'needs_update_failed' ) {
662+ expect ( toast . error ) . toHaveBeenCalledWith ( 'Try again' )
663+ expect ( popup . close ) . toHaveBeenCalledOnce ( )
664+ expect ( mocks . onOpenChange ) . not . toHaveBeenCalled ( )
665+ await clickButton ( 'Update member access' )
666+ }
667+ await completeAuthorization ( )
668+ expect ( toast . success ) . toHaveBeenCalledWith ( 'Slack configured' )
669+ expect ( mocks . onOpenChange ) . toHaveBeenCalledWith ( false )
642670 } else {
643671 expect ( document . body . textContent ) . toContain ( 'Manage Sim Search app' )
672+ expect ( document . body . textContent ) . not . toContain ( 'Update member access' )
644673 }
645674 }
646675 )
0 commit comments