1- import type { EnterpriseConnectionResource } from '@clerk/shared/types' ;
21import { describe , expect , it , vi } from 'vitest' ;
32
3+ import { localizationKeys } from '@/customizables' ;
44import { bindCreateFixtures } from '@/test/create-fixtures' ;
55import { render , screen , waitFor } from '@/test/utils' ;
66import { CardStateProvider } from '@/ui/elements/contexts' ;
77
8- // The dialog no longer touches the wizard. On confirm it calls the
9- // reverification-wrapped `mutations.deleteConnection(id)` directly — a pure
10- // delete, no navigation — and the wizard self-corrects to the
11- // furthest-reachable step once the active step's guard breaks. That lets the
12- // dialog be triggered from ANY footer (including nested SAML configure footers)
13- // without binding to a nested wizard.
14- const deleteConnection = vi . fn ( ) ;
15-
16- const connectionMockState = vi . hoisted ( ( ) => ( {
17- current : { id : 'idn_connection_1' } as Partial < EnterpriseConnectionResource > | null ,
18- } ) ) ;
19-
20- vi . mock ( '../ConfigureSSOContext' , ( ) => ( {
21- useConfigureSSO : ( ) => ( {
22- enterpriseConnection : connectionMockState . current ,
23- contentRef : { current : null } ,
24- // The dialog's confirm calls the reverification-wrapped `deleteConnection`
25- // mutation directly. No navigation — the wizard self-corrects.
26- mutations : { deleteConnection } ,
27- } ) ,
28- } ) ) ;
29-
308import { ResetConnectionDialog } from '../ResetConnectionDialog' ;
319
10+ const deleteConnection = vi . fn ( ) ;
11+
3212const { createFixtures } = bindCreateFixtures ( 'ConfigureSSO' ) ;
3313
3414const renderDialog = (
3515 wrapper : React . ComponentType < { children ?: React . ReactNode } > ,
36- props : { isOpen ?: boolean ; onClose ?: ( ) => void ; confirmationValue ?: string } = { } ,
16+ props : {
17+ isOpen ?: boolean ;
18+ onClose ?: ( ) => void ;
19+ confirmationValue ?: string ;
20+ title ?: ReturnType < typeof localizationKeys > ;
21+ subtitle ?: ReturnType < typeof localizationKeys > ;
22+ confirmButtonLabel ?: ReturnType < typeof localizationKeys > ;
23+ } = { } ,
3724) => {
3825 const onClose = props . onClose ?? vi . fn ( ) ;
3926 const utils = render (
@@ -42,6 +29,11 @@ const renderDialog = (
4229 isOpen = { props . isOpen ?? true }
4330 onClose = { onClose }
4431 confirmationValue = { props . confirmationValue ?? 'Acme Inc' }
32+ onDelete = { ( ) => deleteConnection ( 'idn_connection_1' ) }
33+ contentRef = { { current : null } }
34+ title = { props . title }
35+ subtitle = { props . subtitle }
36+ confirmButtonLabel = { props . confirmButtonLabel }
4537 />
4638 </ CardStateProvider > ,
4739 { wrapper } ,
@@ -52,7 +44,6 @@ const renderDialog = (
5244const resetMocks = ( ) => {
5345 deleteConnection . mockReset ( ) ;
5446 deleteConnection . mockResolvedValue ( undefined ) ;
55- connectionMockState . current = { id : 'idn_connection_1' } ;
5647} ;
5748
5849describe ( 'ResetConnectionDialog' , ( ) => {
@@ -81,6 +72,25 @@ describe('ResetConnectionDialog', () => {
8172 expect ( screen . getByRole ( 'button' , { name : 'Cancel' } ) ) . toBeInTheDocument ( ) ;
8273 } ) ;
8374
75+ it ( 'renders override copy when title, subtitle, and confirm label props are supplied' , async ( ) => {
76+ resetMocks ( ) ;
77+ const { wrapper } = await createFixtures ( ) ;
78+ renderDialog ( wrapper , {
79+ confirmationValue : 'Acme Inc' ,
80+ title : localizationKeys ( 'organizationProfile.securityPage.removeDialog.title' ) ,
81+ subtitle : localizationKeys ( 'organizationProfile.securityPage.removeDialog.subtitle' ) ,
82+ confirmButtonLabel : localizationKeys ( 'organizationProfile.securityPage.removeDialog.confirmButton' ) ,
83+ } ) ;
84+
85+ expect ( screen . getByRole ( 'heading' , { name : 'Remove SSO connection' } ) ) . toBeInTheDocument ( ) ;
86+ expect ( screen . queryByRole ( 'heading' , { name : 'Reset connection' } ) ) . not . toBeInTheDocument ( ) ;
87+ expect ( screen . getByText ( / A r e y o u s u r e y o u w a n t t o r e m o v e t h e c o n n e c t i o n \? / i) ) . toBeInTheDocument ( ) ;
88+ expect ( screen . getByRole ( 'button' , { name : 'Remove connection' } ) ) . toBeInTheDocument ( ) ;
89+ expect ( screen . queryByRole ( 'button' , { name : 'Reset connection' } ) ) . not . toBeInTheDocument ( ) ;
90+ // Type-to-confirm is unchanged by the override.
91+ expect ( screen . getByRole ( 'button' , { name : 'Cancel' } ) ) . toBeInTheDocument ( ) ;
92+ } ) ;
93+
8494 it ( 'keeps Reset disabled while the input is empty' , async ( ) => {
8595 resetMocks ( ) ;
8696 const { wrapper } = await createFixtures ( ) ;
0 commit comments