@@ -15,7 +15,9 @@ const createRuleButtonName = /Create rule|Create policy rule/i
1515const saveRuleButtonName = / S a v e r u l e c h a n g e s | S a v e c h a n g e s | S a v e p o l i c y r u l e c h a n g e s / i
1616const createDefaultButtonName = / C r e a t e d e f a u l t r u l e | C r e a t e g l o b a l d e f a u l t r u l e / i
1717const editGlobalDefaultButtonName = / E d i t d e f a u l t | E d i t g l o b a l d e f a u l t / i
18- const resetGlobalDefaultButtonName = / R e s e t d e f a u l t | R e s e t g l o b a l d e f a u l t / i
18+ const resetGlobalDefaultButtonName = / R e s e t d e f a u l t | R e s e t g l o b a l d e f a u l t | R e s e t d e f a u l t r u l e / i
19+ const newGroupRuleButtonName = / N e w g r o u p r u l e | N e w g r o u p o v e r r i d e / i
20+ const newUserRuleButtonName = / N e w u s e r r u l e | N e w u s e r o v e r r i d e / i
1921const editGroupRuleButtonName = / E d i t g r o u p r u l e | E d i t g r o u p o v e r r i d e / i
2022const deleteGroupRuleButtonName = / D e l e t e g r o u p r u l e | D e l e t e g r o u p o v e r r i d e / i
2123const editUserRuleButtonName = / E d i t u s e r r u l e | E d i t u s e r o v e r r i d e / i
@@ -158,11 +160,11 @@ async function chooseTarget(dialog: Locator, ariaLabel: 'Target groups' | 'Targe
158160 }
159161}
160162
161- async function clickSectionAction ( section : Locator , actionLabel : string ) {
163+ async function clickSectionAction ( section : Locator , actionLabel : string | RegExp ) {
162164 await section . getByRole ( 'button' , { name : actionLabel } ) . first ( ) . click ( )
163165}
164166
165- async function removeRuleWithConfirmation ( page : Page , dialog : Locator , section : Locator , actionLabel : string ) {
167+ async function removeRuleWithConfirmation ( page : Page , dialog : Locator , section : Locator , actionLabel : string | RegExp ) {
166168 const confirmButton = page . getByRole ( 'button' , { name : 'Remove rule' } ) . first ( )
167169 if ( await confirmButton . isVisible ( ) . catch ( ( ) => false ) ) {
168170 await confirmButton . click ( )
@@ -182,7 +184,7 @@ async function removeAllRulesByAction(
182184 page : Page ,
183185 dialog : Locator ,
184186 section : Locator ,
185- actionLabel : 'Delete user rule' | 'Delete group rule' ,
187+ actionLabel : string | RegExp ,
186188) {
187189 for ( let attempt = 0 ; attempt < 8 ; attempt ++ ) {
188190 const currentCount = await section . getByRole ( 'button' , { name : actionLabel } ) . count ( )
@@ -202,8 +204,8 @@ async function ensureBaselineRulesForAdminTarget(page: Page, dialog: Locator) {
202204 const groupSection = dialog . getByRole ( 'region' , { name : groupSectionName } )
203205 const userSection = dialog . getByRole ( 'region' , { name : userSectionName } )
204206
205- await removeAllRulesByAction ( page , dialog , userSection , 'Delete user override' )
206- await removeAllRulesByAction ( page , dialog , groupSection , 'Delete group override' )
207+ await removeAllRulesByAction ( page , dialog , userSection , deleteUserRuleButtonName )
208+ await removeAllRulesByAction ( page , dialog , groupSection , deleteGroupRuleButtonName )
207209
208210 // Normalize global default into a known baseline where lower layers may override.
209211 if ( await globalSection . getByRole ( 'button' , { name : editGlobalDefaultButtonName } ) . count ( ) ) {
@@ -253,7 +255,7 @@ test('system default persists allow-override changes across edit cycles', async
253255 await expect ( signingOrderDialog . getByText ( inheritValueMessage ) ) . toBeVisible ( )
254256
255257 // Reset should restore inherited baseline behavior.
256- await removeRuleWithConfirmation ( page , signingOrderDialog , globalSection , 'Reset global default' )
258+ await removeRuleWithConfirmation ( page , signingOrderDialog , globalSection , resetGlobalDefaultButtonName )
257259 await expectGlobalBaselineState ( globalSection )
258260} )
259261
@@ -297,7 +299,7 @@ test('admin can create, edit, and delete global, group, and user rules from the
297299 await expect ( globalSection . getByRole ( 'button' , { name : editGlobalDefaultButtonName } ) ) . toBeVisible ( )
298300
299301 // Group rule: create
300- await dialog . getByRole ( 'button' , { name : 'New group override' } ) . first ( ) . click ( )
302+ await dialog . getByRole ( 'button' , { name : newGroupRuleButtonName } ) . first ( ) . click ( )
301303 await chooseTarget ( dialog , 'Target groups' , 'admin' )
302304 expect ( await setSigningFlow ( dialog , 'ordered_numeric' ) , 'Expected signing-flow radios in group editor' ) . toBe ( true )
303305 await setAllowOverride ( dialog , true )
@@ -311,27 +313,27 @@ test('admin can create, edit, and delete global, group, and user rules from the
311313 await expect ( groupSection . getByRole ( 'button' , { name : editGroupRuleButtonName } ) . first ( ) ) . toBeVisible ( )
312314
313315 // User rule: create
314- await dialog . getByRole ( 'button' , { name : 'New user override' } ) . first ( ) . click ( )
316+ await dialog . getByRole ( 'button' , { name : newUserRuleButtonName } ) . first ( ) . click ( )
315317 await chooseTarget ( dialog , 'Target users' , userTarget )
316318 expect ( await setSigningFlow ( dialog , 'ordered_numeric' ) , 'Expected signing-flow radios in user editor' ) . toBe ( true )
317319 await submitRule ( dialog )
318320 await expect ( userSection . getByRole ( 'button' , { name : editUserRuleButtonName } ) . first ( ) ) . toBeVisible ( )
319321
320322 // User rule: edit
321- await clickSectionAction ( userSection , 'Edit user override' )
323+ await clickSectionAction ( userSection , editUserRuleButtonName )
322324 expect ( await setSigningFlow ( dialog , 'parallel' ) , 'Expected signing-flow radios in user editor' ) . toBe ( true )
323325 await submitRule ( dialog )
324326 await expect ( userSection . getByRole ( 'button' , { name : editUserRuleButtonName } ) . first ( ) ) . toBeVisible ( )
325327
326328 // User rule: delete
327- await removeAllRulesByAction ( page , dialog , userSection , 'Delete user override' )
329+ await removeAllRulesByAction ( page , dialog , userSection , deleteUserRuleButtonName )
328330 await expect ( userSection . getByRole ( 'button' , { name : deleteUserRuleButtonName } ) ) . toHaveCount ( 0 )
329331
330332 // Group rule: delete
331- await removeAllRulesByAction ( page , dialog , groupSection , 'Delete group override' )
333+ await removeAllRulesByAction ( page , dialog , groupSection , deleteGroupRuleButtonName )
332334 await expect ( groupSection . getByRole ( 'button' , { name : deleteGroupRuleButtonName } ) ) . toHaveCount ( 0 )
333335
334336 // Global rule: reset to inherited baseline
335- await removeRuleWithConfirmation ( page , dialog , globalSection , 'Reset global default' )
337+ await removeRuleWithConfirmation ( page , dialog , globalSection , resetGlobalDefaultButtonName )
336338 await expectGlobalBaselineState ( globalSection )
337339} )
0 commit comments