@@ -13,7 +13,6 @@ test.describe.configure({ mode: 'serial', retries: 0, timeout: 45000 })
1313const openPolicyButtonName = / M a n a g e t h i s s e t t i n g | O p e n p o l i c y | O p e n s e t t i n g p o l i c y / i
1414const changeDefaultButtonName = / ^ C h a n g e $ / i
1515const removeExceptionButtonName = / R e m o v e e x c e p t i o n | R e m o v e r u l e / i
16- const groupRuleTargetLabel = 'admin'
1716const userRuleTargetLabel = 'policy-e2e-user'
1817const instanceWideTargetLabel = 'Default (instance-wide)'
1918const ruleDialogName = / C r e a t e r u l e | E d i t r u l e | W h a t d o y o u w a n t t o c r e a t e \? / i
@@ -120,6 +119,17 @@ async function openSystemDefaultEditor(dialog: Locator) {
120119 await getActiveRuleDialog ( dialog . page ( ) )
121120}
122121
122+ async function getCreateScopeDialog ( page : Page ) : Promise < Locator > {
123+ const dialog = await getActiveRuleDialog ( page )
124+ await expect ( dialog . getByRole ( 'heading' , { name : / W h a t d o y o u w a n t t o c r e a t e \? / i } ) ) . toBeVisible ( )
125+ return dialog
126+ }
127+
128+ async function getCreateScopeOption ( page : Page , scopeLabel : 'User' | 'Group' | 'Instance' ) {
129+ const dialog = await getCreateScopeDialog ( page )
130+ return dialog . getByRole ( 'option' , { name : new RegExp ( `^${ scopeLabel } \\b` , 'i' ) } ) . first ( )
131+ }
132+
123133async function openRuleActions ( dialog : Locator , scope : 'Instance' | 'Group' | 'User' , targetLabel : string ) {
124134 const row = getRuleRow ( dialog , scope , targetLabel )
125135 await expect ( row ) . toBeVisible ( { timeout : 8000 } )
@@ -250,7 +260,11 @@ async function clearExistingRules(dialog: Locator) {
250260 break
251261 }
252262
253- await firstAction . click ( { timeout : 1500 } )
263+ const clickedAction = await firstAction . click ( { timeout : 1500 } ) . then ( ( ) => true ) . catch ( ( ) => false )
264+ if ( ! clickedAction ) {
265+ await page . waitForTimeout ( 150 )
266+ continue
267+ }
254268 const hasRemoveAction = await clickRuleMenuAction ( dialog , 'Remove' )
255269 if ( ! hasRemoveAction ) {
256270 break
@@ -324,7 +338,7 @@ test('system default persists across edit cycles and can be reset to the system
324338 await expect ( reloadedDialog . getByText ( / D e f a u l t : \s * L e t u s e r s c h o o s e / i) ) . toBeVisible ( )
325339} )
326340
327- test ( 'admin can create, edit, and delete global, group, and user rules from the policy workbench ' , async ( { page } ) => {
341+ test ( 'admin can manage instance and user rules while signature-flow group rules stay blocked ' , async ( { page } ) => {
328342 const userTarget = userRuleTargetLabel
329343
330344 await ensureUserExists ( page . request , userTarget )
@@ -351,49 +365,38 @@ test('admin can create, edit, and delete global, group, and user rules from the
351365 await submitSystemRuleAndWait ( stableDialog )
352366 await expect ( getRuleRow ( stableDialog , 'Instance' , instanceWideTargetLabel ) ) . toContainText ( 'Sequential' )
353367
354- // Group rule: create
368+ // Signature-flow group rules are intentionally blocked once the instance rule is fixed.
355369 await stableDialog . getByRole ( 'button' , { name : 'Create rule' } ) . first ( ) . click ( )
356- await stableDialog . page ( ) . getByText ( / ^ G r o u p $ / i) . first ( ) . click ( )
357- await chooseTarget ( stableDialog , 'Target groups' , 'admin' )
358- expect ( await setSigningFlow ( stableDialog , 'ordered_numeric' ) , 'Expected signing-flow radios in group editor' ) . toBe ( true )
359- await submitRule ( stableDialog )
360- await expect ( getRuleRow ( stableDialog , 'Group' , groupRuleTargetLabel ) ) . toContainText ( 'Sequential' )
361-
362- // Group rule: edit
363- await editRule ( stableDialog , 'Group' , groupRuleTargetLabel )
364- expect ( await setSigningFlow ( stableDialog , 'parallel' ) , 'Expected signing-flow radios in group editor' ) . toBe ( true )
365- await submitRule ( stableDialog )
366- await expect ( getRuleRow ( stableDialog , 'Group' , groupRuleTargetLabel ) ) . toContainText ( 'Simultaneous (Parallel)' )
370+ const groupScopeOption = await getCreateScopeOption ( stableDialog . page ( ) , 'Group' )
371+ await expect ( groupScopeOption ) . toBeDisabled ( )
372+ const createScopeDialog = await getCreateScopeDialog ( stableDialog . page ( ) )
373+ await expect ( createScopeDialog . getByText ( / ^ G r o u p : \s + B l o c k e d b y t h e g l o b a l d e f a u l t \. $ / i) ) . toBeVisible ( )
367374
368375 // User rule: create
369- await stableDialog . getByRole ( 'button' , { name : 'Create rule' } ) . first ( ) . click ( )
370- await stableDialog . page ( ) . getByText ( / ^ U s e r $ / i) . first ( ) . click ( )
376+ const userScopeOption = await getCreateScopeOption ( stableDialog . page ( ) , 'User' )
377+ await expect ( userScopeOption ) . toBeEnabled ( )
378+ await userScopeOption . click ( )
371379 await chooseTarget ( stableDialog , 'Target users' , userTarget )
372- expect ( await setSigningFlow ( stableDialog , 'ordered_numeric ' ) , 'Expected signing-flow radios in user editor' ) . toBe ( true )
380+ expect ( await setSigningFlow ( stableDialog , 'parallel ' ) , 'Expected signing-flow radios in user editor' ) . toBe ( true )
373381 await submitRule ( stableDialog )
374- await expect ( getRuleRow ( stableDialog , 'User' , userTarget ) ) . toContainText ( 'Sequential ' )
382+ await expect ( getRuleRow ( stableDialog , 'User' , userTarget ) ) . toContainText ( 'Simultaneous (Parallel) ' )
375383
376384 // User rule: edit
377385 await editRule ( stableDialog , 'User' , userTarget )
378- expect ( await setSigningFlow ( stableDialog , 'parallel ' ) , 'Expected signing-flow radios in user editor' ) . toBe ( true )
386+ expect ( await setSigningFlow ( stableDialog , 'ordered_numeric ' ) , 'Expected signing-flow radios in user editor' ) . toBe ( true )
379387 await submitRule ( stableDialog )
380- await expect ( getRuleRow ( stableDialog , 'User' , userTarget ) ) . toContainText ( 'Simultaneous (Parallel) ' )
388+ await expect ( getRuleRow ( stableDialog , 'User' , userTarget ) ) . toContainText ( 'Sequential ' )
381389
382390 await page . reload ( )
383391 await openSigningOrderDialog ( page )
384392 const reloadedDialog = await getSigningOrderDialog ( page )
385393 await expect ( getRuleRow ( reloadedDialog , 'Instance' , instanceWideTargetLabel ) ) . toContainText ( 'Sequential' )
386- await expect ( getRuleRow ( reloadedDialog , 'Group' , groupRuleTargetLabel ) ) . toContainText ( 'Simultaneous (Parallel)' )
387- await expect ( getRuleRow ( reloadedDialog , 'User' , userTarget ) ) . toContainText ( 'Simultaneous (Parallel)' )
394+ await expect ( getRuleRow ( reloadedDialog , 'User' , userTarget ) ) . toContainText ( 'Sequential' )
388395
389396 // User rule: delete
390397 await removeRule ( reloadedDialog , 'User' , userTarget )
391398 await expect ( getRuleRow ( reloadedDialog , 'User' , userTarget ) ) . toHaveCount ( 0 )
392399
393- // Group rule: delete
394- await removeRule ( reloadedDialog , 'Group' , groupRuleTargetLabel )
395- await expect ( getRuleRow ( reloadedDialog , 'Group' , groupRuleTargetLabel ) ) . toHaveCount ( 0 )
396-
397400 // Global rule: reset to explicit "let users choose" baseline
398401 await resetSystemRuleToBaseline ( reloadedDialog )
399402 await expect ( getRuleRow ( reloadedDialog , 'Instance' , instanceWideTargetLabel ) ) . toContainText ( 'Let users choose' )
0 commit comments