@@ -171,6 +171,15 @@ async function check(name: string, run: () => Promise<void>) {
171171 }
172172}
173173
174+ function integrationRow ( name : string ) {
175+ return page
176+ . getByRole ( 'main' )
177+ . getByRole ( 'link' )
178+ . filter ( {
179+ has : page . getByText ( name , { exact : true } ) ,
180+ } )
181+ }
182+
174183async function capture ( name : string ) {
175184 await page . evaluate ( ( ) => document . fonts . ready )
176185 await page . addStyleTag ( { content : 'nextjs-portal { display: none; }' } )
@@ -566,11 +575,14 @@ try {
566575 waitUntil : 'domcontentloaded' ,
567576 timeout : 180_000 ,
568577 } )
569- await page . getByRole ( 'link' , { name : 'Open Salesforce integration' , exact : true } ) . click ( )
578+ await integrationRow ( ' Salesforce' ) . click ( )
570579 await expect ( page . getByRole ( 'button' , { name : 'Add account' , exact : true } ) ) . toHaveCount ( 0 )
571- await expect ( page . getByRole ( 'button' , { name : 'Reconnect' , exact : true } ) ) . toBeVisible ( )
580+ await page . getByRole ( 'button' , { name : / ^ M a n a g e / } ) . click ( )
581+ await expect (
582+ page . getByRole ( 'menuitem' , { name : 'Reconnect account' , exact : true } )
583+ ) . toBeVisible ( )
572584 await capture ( 'integration-account-actions' )
573- await page . getByRole ( 'button ' , { name : 'Disconnect' , exact : true } ) . click ( )
585+ await page . getByRole ( 'menuitem ' , { name : 'Disconnect account ' , exact : true } ) . click ( )
574586 await expect ( page . getByRole ( 'dialog' , { name : 'Disconnect Salesforce' } ) ) . toBeVisible ( )
575587 await capture ( 'integration-disconnect-confirmation' )
576588 await page . getByRole ( 'button' , { name : 'Cancel' , exact : true } ) . click ( )
@@ -589,9 +601,7 @@ try {
589601 const data = readAssistantToolPermissionsContract . response . schema . parse ( await response . json ( ) )
590602 assert . equal ( data . account . credentialId , account . credentialId )
591603 assert . equal ( data . tools . length > 0 , account . supported , account . name )
592- await page
593- . getByRole ( 'link' , { name : `Open ${ account . name } integration` , exact : true } )
594- . click ( )
604+ await integrationRow ( account . name ) . click ( )
595605 const permissions = page . getByRole ( 'textbox' , { name : 'Search tools' , exact : true } )
596606 if ( account . supported ) {
597607 await expect ( permissions ) . toBeVisible ( )
@@ -602,24 +612,19 @@ try {
602612 await capture ( `integration-detail-${ account . name . toLowerCase ( ) . replaceAll ( ' ' , '-' ) } ` )
603613 }
604614 await page . goto ( `${ baseUrl . origin } ${ root } /integrations` )
605- await expect (
606- page . getByRole ( 'link' , { name : 'Open Salesforce integration' , exact : true } )
607- ) . toBeVisible ( )
615+ await expect ( integrationRow ( 'Salesforce' ) ) . toBeVisible ( )
608616 await capture ( 'integrations-desktop' )
609617 } )
610618 await check (
611619 'A synthetic duplicate-provider fixture isolates permissions and disconnects only the selected account' ,
612620 async ( ) => {
613621 await page . goto ( `${ baseUrl . origin } ${ root } /integrations` )
614- await page . getByRole ( 'link' , { name : 'Open Jira integration' , exact : true } ) . click ( )
615- await expect ( page ) . toHaveURL ( ( url ) => url . searchParams . get ( 'integration' ) === 'source: jira' )
622+ await integrationRow ( ' Jira' ) . click ( )
623+ await expect ( page ) . toHaveURL ( ( url ) => url . pathname === ` ${ root } /integrations/ jira` )
616624 const accountsUrl = page . url ( )
617- const firstAccount = page . getByRole ( 'link' , {
618- name : 'Open taylor@acme.example account' ,
619- exact : true ,
620- } )
625+ const firstAccount = page . getByRole ( 'link' , { name : 'taylor@acme.example' , exact : true } )
621626 const secondAccount = page . getByRole ( 'link' , {
622- name : 'Open launch-team@acme.example account ' ,
627+ name : 'launch-team@acme.example' ,
623628 exact : true ,
624629 } )
625630 await expect ( firstAccount ) . toBeVisible ( )
@@ -664,10 +669,15 @@ try {
664669 await firstAccount . click ( )
665670 await expect ( policy . getByRole ( 'radio' , { name : 'Ask' , exact : true } ) ) . toBeChecked ( )
666671 await page . goto ( selectedUrl )
667- await expect ( page . getByRole ( 'button' , { name : 'Reconnect' , exact : true } ) ) . toBeVisible ( )
668672 await expect ( policy . getByRole ( 'radio' , { name : 'Block' , exact : true } ) ) . toBeChecked ( )
673+ await page
674+ . getByRole ( 'button' , { name : 'Manage launch-team@acme.example' , exact : true } )
675+ . click ( )
676+ await expect (
677+ page . getByRole ( 'menuitem' , { name : 'Reconnect account' , exact : true } )
678+ ) . toBeVisible ( )
669679 await capture ( 'integration-selected-account-actions' )
670- await page . getByRole ( 'button ' , { name : 'Disconnect' , exact : true } ) . click ( )
680+ await page . getByRole ( 'menuitem ' , { name : 'Disconnect account ' , exact : true } ) . click ( )
671681 const confirmation = page . getByRole ( 'dialog' , { name : 'Disconnect Jira' , exact : true } )
672682 await expect ( confirmation ) . toContainText ( 'launch-team@acme.example' )
673683 await expect ( confirmation ) . not . toContainText ( 'taylor@acme.example' )
@@ -715,12 +725,12 @@ try {
715725 )
716726 )
717727 await page . goto ( `${ baseUrl . origin } ${ root } /integrations` )
718- await page . getByRole ( 'link' , { name : 'Open Coda integration' , exact : true } ) . click ( )
719- await expect ( page ) . toHaveURL ( ( url ) => url . searchParams . get ( 'integration' ) === 'source: coda' )
728+ await integrationRow ( ' Coda' ) . click ( )
729+ await expect ( page ) . toHaveURL ( ( url ) => url . pathname === ` ${ root } /integrations/ coda` )
720730 const detailUrl = page . url ( )
721- const connect = page . getByRole ( 'button' , { name : 'Connect ' , exact : true } )
731+ const connect = page . getByRole ( 'button' , { name : 'Coda ' , exact : true } )
722732 await expect ( connect ) . toBeEnabled ( )
723- await expect ( page . getByText ( 'No account connected ' , { exact : true } ) ) . toBeVisible ( )
733+ await expect ( page . getByText ( 'Connect your Coda account ' , { exact : true } ) ) . toBeVisible ( )
724734 await expect ( page . getByText ( 'meetings@acme.example' , { exact : true } ) ) . toHaveCount ( 0 )
725735 await capture ( 'integration-enabled-empty' )
726736 const forgedUrl = new URL ( detailUrl )
@@ -729,16 +739,14 @@ try {
729739 await expect (
730740 page . getByText ( 'This account is no longer connected.' , { exact : true } )
731741 ) . toBeVisible ( )
732- await expect ( page . getByRole ( 'button' , { name : 'Disconnect' , exact : true } ) ) . toHaveCount ( 0 )
742+ await expect ( page . getByRole ( 'button' , { name : / ^ M a n a g e / } ) ) . toHaveCount ( 0 )
733743 await expect ( page . getByRole ( 'textbox' , { name : 'Search tools' , exact : true } ) ) . toHaveCount ( 0 )
734744 await sql `update organization_search_integration set approved = false where organization_id = ${ organizationId } and connector_type = 'coda'`
735745 try {
736746 await page . goto ( `${ baseUrl . origin } ${ root } /integrations` )
737- await expect (
738- page . getByRole ( 'link' , { name : 'Open Coda integration' , exact : true } )
739- ) . toBeVisible ( )
740- await page . getByRole ( 'link' , { name : 'Open Coda integration' , exact : true } ) . click ( )
741- await expect ( page ) . toHaveURL ( ( url ) => url . searchParams . get ( 'integration' ) === 'source:coda' )
747+ await expect ( integrationRow ( 'Coda' ) ) . toBeVisible ( )
748+ await integrationRow ( 'Coda' ) . click ( )
749+ await expect ( page ) . toHaveURL ( ( url ) => url . pathname === `${ root } /integrations/coda` )
742750 await expect ( page . getByText ( 'Disabled by your organization' , { exact : true } ) ) . toBeVisible ( )
743751 await expect ( connect ) . toBeDisabled ( )
744752 await capture ( 'integration-disabled-empty' )
@@ -760,18 +768,13 @@ try {
760768 await sql `update credential_group set options = (select jsonb_agg(case when value->>'id' = 'salesforce' then value || '{"status":"disabled"}'::jsonb else value end) from jsonb_array_elements(options)) where id = ${ groupId } `
761769 try {
762770 await page . goto ( `${ baseUrl . origin } ${ root } /integrations` )
763- const salesforce = page . getByRole ( 'link' , {
764- name : 'Open Salesforce integration' ,
765- exact : true ,
766- } )
771+ const salesforce = integrationRow ( 'Salesforce' )
767772 await expect ( salesforce ) . toBeVisible ( )
768773 await salesforce . click ( )
769- await expect ( page ) . toHaveURL (
770- ( url ) => url . searchParams . get ( 'integration' ) === 'app:salesforce'
771- )
772- await expect ( page . getByText ( 'No account connected' , { exact : true } ) ) . toBeVisible ( )
774+ await expect ( page ) . toHaveURL ( ( url ) => url . pathname === `${ root } /integrations/salesforce` )
773775 await expect ( page . getByText ( 'Connections unavailable' , { exact : true } ) ) . toBeVisible ( )
774- await expect ( connect ) . toHaveCount ( 0 )
776+ await expect ( page . getByRole ( 'region' , { name : 'Connected credential' } ) ) . toHaveCount ( 0 )
777+ await expect ( page . getByRole ( 'button' , { name : 'Salesforce' , exact : true } ) ) . toBeDisabled ( )
775778 await capture ( 'integration-disabled-app-empty' )
776779 } finally {
777780 await sql `update credential set managed_oauth_status = 'active' where id = ${ nativeCredentialId } `
0 commit comments