Skip to content

Commit f56b28c

Browse files
committed
test(policy): stabilize workbench persistence e2e
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 4207f47 commit f56b28c

1 file changed

Lines changed: 30 additions & 27 deletions

File tree

playwright/e2e/policy-workbench-system-default-persistence.spec.ts

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ test.describe.configure({ mode: 'serial', retries: 0, timeout: 45000 })
1313
const openPolicyButtonName = /Manage this setting|Open policy|Open setting policy/i
1414
const changeDefaultButtonName = /^Change$/i
1515
const removeExceptionButtonName = /Remove exception|Remove rule/i
16-
const groupRuleTargetLabel = 'admin'
1716
const userRuleTargetLabel = 'policy-e2e-user'
1817
const instanceWideTargetLabel = 'Default (instance-wide)'
1918
const ruleDialogName = /Create rule|Edit rule|What do you want to create\?/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: /What do you want to create\?/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+
123133
async 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(/Default:\s*Let users choose/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(/^Group$/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(/^Group:\s+Blocked by the global default\.$/i)).toBeVisible()
367374

368375
// User rule: create
369-
await stableDialog.getByRole('button', { name: 'Create rule' }).first().click()
370-
await stableDialog.page().getByText(/^User$/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

Comments
 (0)