@@ -233,33 +233,40 @@ describe('connection method selection', () => {
233233} )
234234
235235describe ( 'Slack setup continuity' , ( ) => {
236- it ( 'keeps the setup link and draft callback when the method selector is hidden' , async ( ) => {
237- const onNavigate = vi . fn ( )
238- await render ( {
239- connectorConfig : slackConnectorMeta ,
240- allowAdmin : false ,
241- searchSetupSource : 'slack' ,
242- slackSetupOnly : true ,
243- onSetupNavigate : onNavigate ,
244- footer : < button type = 'button' > Apply changes</ button > ,
245- } )
246- expect ( container . querySelector ( '[role="radiogroup"]' ) ) . toBeNull ( )
247- expect ( container . textContent ) . toContain ( 'Slack app' )
248- expect ( container . textContent ) . not . toContain ( 'Member accounts' )
249- const link = container . querySelector ( 'a' )
250- const target = new URL ( link ?. getAttribute ( 'href' ) ?? '' , 'http://localhost' )
251- expect ( target . pathname ) . toBe ( '/workspace/workspace-1/settings/credential-groups' )
252- expect ( target . searchParams . get ( 'search-setup' ) ) . toBe ( 'slack' )
253- expect ( target . searchParams . get ( 'credential-group-provider' ) ) . toBe ( 'slack' )
254- link ?. addEventListener ( 'click' , ( event ) => event . preventDefault ( ) )
255- await act ( async ( ) => link ?. click ( ) )
256- expect ( onNavigate ) . toHaveBeenCalledOnce ( )
257- expect ( container . textContent ) . toContain ( 'Apply changes' )
258- expect ( mocks . accounts ) . toHaveBeenLastCalledWith ( {
259- kind : 'workspace' ,
260- workspaceId : 'workspace-1' ,
261- } )
262- } )
236+ it . each ( [
237+ {
238+ scope : { kind : 'workspace' , workspaceId : 'workspace-1' } ,
239+ href : '/workspace/workspace-1/settings/credential-groups' ,
240+ } ,
241+ {
242+ scope : { kind : 'organization' , organizationId : 'org-1' } ,
243+ href : '/o/org-1/settings/integrations?search-setup=slack&connectedAccounts=slack' ,
244+ } ,
245+ ] as const ) (
246+ 'keeps the $scope.kind setup link and draft callback when the method selector is hidden' ,
247+ async ( { scope, href } ) => {
248+ const onNavigate = vi . fn ( )
249+ await render ( {
250+ scope,
251+ connectorConfig : slackConnectorMeta ,
252+ allowAdmin : false ,
253+ searchSetupSource : 'slack' ,
254+ slackSetupOnly : true ,
255+ onSetupNavigate : onNavigate ,
256+ footer : < button type = 'button' > Apply changes</ button > ,
257+ } )
258+ expect ( container . querySelector ( '[role="radiogroup"]' ) ) . toBeNull ( )
259+ expect ( container . textContent ) . toContain ( 'Slack app' )
260+ expect ( container . textContent ) . not . toContain ( 'Member accounts' )
261+ const link = container . querySelector ( 'a' )
262+ expect ( link ) . toHaveAttribute ( 'href' , href )
263+ link ?. addEventListener ( 'click' , ( event ) => event . preventDefault ( ) )
264+ await act ( async ( ) => link ?. click ( ) )
265+ expect ( onNavigate ) . toHaveBeenCalledOnce ( )
266+ expect ( container . textContent ) . toContain ( 'Apply changes' )
267+ expect ( mocks . accounts ) . toHaveBeenLastCalledWith ( scope )
268+ }
269+ )
263270
264271 it . each ( [ 'loading' , 'configured' ] as const ) ( 'hides the Slack detour while %s' , async ( state ) => {
265272 mocks . loading = state === 'loading'
0 commit comments