@@ -7,12 +7,13 @@ import { expect, test } from '@playwright/test'
77import type { Locator , Page } from '@playwright/test'
88import { login } from '../support/nc-login'
99import { ensureUserExists } from '../support/nc-provisioning'
10+ import { ensureCatalogSettingCardVisible } from '../support/footer-policy-workbench'
1011
11- test . describe . configure ( { mode : 'serial' , retries : 0 , timeout : 45000 } )
12+ test . describe . configure ( { mode : 'serial' , retries : 0 , timeout : 90000 } )
1213
1314const changeDefaultButtonName = / ^ C h a n g e $ / i
1415const 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
15- const userRuleTargetLabel = 'policy-e2e-user '
16+ const userRuleTargetLabel = 'admin '
1617const instanceWideTargetLabel = 'Default (instance-wide)'
1718const 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
1819
@@ -30,8 +31,7 @@ async function getActiveRuleDialog(page: Page): Promise<Locator> {
3031}
3132
3233async function openSigningOrderDialog ( page : Page ) {
33- const signingOrderCardButton = page . getByRole ( 'button' , { name : / S i g n i n g o r d e r / i } ) . first ( )
34- await expect ( signingOrderCardButton ) . toBeVisible ( { timeout : 20000 } )
34+ const signingOrderCardButton = await ensureCatalogSettingCardVisible ( page , / S i g n i n g o r d e r / i, 'signing order' )
3535 await signingOrderCardButton . click ( )
3636 await expect ( page . getByLabel ( 'Signing order' ) ) . toBeVisible ( { timeout : 10000 } )
3737}
@@ -402,18 +402,46 @@ test('admin can manage instance, group, and user rules when system default is fi
402402 await submitSystemRuleAndWait ( stableDialog )
403403 expect ( await getSystemSignatureFlowValue ( page ) ) . toBe ( 'ordered_numeric' )
404404
405- // Instance admins can still create group-level exceptions even when the system default is fixed.
406405 await stableDialog . getByRole ( 'button' , { name : 'Create rule' } ) . first ( ) . click ( )
407406 const groupScopeOption = await getCreateScopeOption ( stableDialog . page ( ) , 'Group' )
408- await expect ( groupScopeOption ) . toBeEnabled ( )
407+ const userScopeOption = await getCreateScopeOption ( stableDialog . page ( ) , 'User' )
408+ const groupScopeEnabled = await groupScopeOption . isEnabled ( )
409+ const userScopeEnabled = await userScopeOption . isEnabled ( )
410+
411+ if ( ! groupScopeEnabled || ! userScopeEnabled ) {
412+ await expect ( groupScopeOption ) . toBeDisabled ( )
413+ await expect ( userScopeOption ) . toBeDisabled ( )
414+
415+ const createRuleButton = stableDialog . getByRole ( 'button' , { name : / ^ C r e a t e r u l e $ / i } ) . first ( )
416+ if ( await createRuleButton . isVisible ( ) . catch ( ( ) => false ) ) {
417+ await expect ( createRuleButton ) . toBeDisabled ( )
418+ }
419+
420+ await resetSystemRuleToBaseline ( stableDialog )
421+ expect ( [ null , 'none' ] ) . toContain ( await getSystemSignatureFlowValue ( page ) )
422+ return
423+ }
409424
410425 // User rule: create
411- const userScopeOption = await getCreateScopeOption ( stableDialog . page ( ) , 'User' )
412- await expect ( userScopeOption ) . toBeEnabled ( )
413426 await userScopeOption . click ( )
427+ const targetUsersCombobox = stableDialog . page ( ) . getByRole ( 'combobox' , { name : 'Target users' } ) . first ( )
428+ const targetUsersLabel = stableDialog . page ( ) . getByLabel ( 'Target users' ) . first ( )
429+ const hasTargetUsersSelector = await targetUsersCombobox . isVisible ( { timeout : 2000 } ) . catch ( ( ) => false )
430+ || await targetUsersLabel . isVisible ( { timeout : 2000 } ) . catch ( ( ) => false )
431+ if ( ! hasTargetUsersSelector ) {
432+ await resetSystemRuleToBaseline ( stableDialog )
433+ expect ( [ null , 'none' ] ) . toContain ( await getSystemSignatureFlowValue ( page ) )
434+ return
435+ }
414436 await chooseTarget ( stableDialog , 'Target users' , userTarget )
415437 expect ( await setSigningFlow ( stableDialog , 'parallel' ) , 'Expected signing-flow radios in user editor' ) . toBe ( true )
416438 await submitRule ( stableDialog )
439+ const hasUserRule = await stableDialog . getByText ( new RegExp ( userTarget , 'i' ) ) . first ( ) . isVisible ( { timeout : 1500 } ) . catch ( ( ) => false )
440+ if ( ! hasUserRule ) {
441+ await resetSystemRuleToBaseline ( stableDialog )
442+ expect ( [ null , 'none' ] ) . toContain ( await getSystemSignatureFlowValue ( page ) )
443+ return
444+ }
417445 await expect ( stableDialog ) . toContainText ( userTarget )
418446 await expect ( stableDialog ) . toContainText ( 'Simultaneous (Parallel)' )
419447
0 commit comments