diff --git a/e2e/checks/catalogue-preview-modal.cjs b/e2e/checks/catalogue-preview-modal.cjs
new file mode 100644
index 000000000..ca488b415
--- /dev/null
+++ b/e2e/checks/catalogue-preview-modal.cjs
@@ -0,0 +1,49 @@
+const assert = require('node:assert/strict');
+
+module.exports = async ({ page, go, shot }) => {
+ // An isolated catalogue entry keeps the check independent of the live source.
+ await page.route('**/api/extensions/catalogue', route => route.fulfill({ json: [{
+ name: 'preview-extension', display_name: 'Preview extension', description: 'An extension to preview.',
+ contract: 'workflow', group: 'platform', latest: '1.0.0', default_version: '1.0.0',
+ versions: [{ version: '1.0.0', digest: 'preview-digest', registered: true, settings: [] }],
+ }] }));
+ await page.setViewportSize({ width: 390, height: 600 });
+ await go('/settings/extensions?tab=marketplace');
+ const opener = page.getByRole('button', { name: 'Details for Preview extension' });
+ const preview = page.getByRole('dialog', { name: 'Preview extension' });
+ const version = preview.getByRole('combobox', { name: 'Version' });
+ const close = preview.getByRole('button', { name: 'Close' });
+
+ await opener.click();
+ await page.keyboard.press('Tab');
+ await page.keyboard.press('Shift+Tab');
+ assert.ok(await version.evaluate(el => el === document.activeElement));
+ await shot('version-focus');
+ const { clearance, ring } = await version.evaluate(el => {
+ let scroll = el.parentElement;
+ while (getComputedStyle(scroll).overflowY !== 'auto') scroll = scroll.parentElement;
+ const bounds = scroll.getBoundingClientRect();
+ const field = el.getBoundingClientRect();
+ const css = getComputedStyle(el);
+ return {
+ clearance: Math.min(field.left - bounds.left, bounds.left + scroll.clientWidth - field.right),
+ ring: Math.max(3, parseFloat(css.outlineWidth) + parseFloat(css.outlineOffset)),
+ };
+ });
+ assert.ok(clearance + 0.1 >= ring, `Version focus ring: ${clearance}px clearance for ${ring}px ring`);
+
+ await page.keyboard.press('Space');
+ const options = page.getByRole('listbox');
+ await options.waitFor();
+ await page.keyboard.press('Escape');
+ await options.waitFor({ state: 'hidden' });
+ await preview.waitFor();
+ await page.keyboard.press('Escape');
+ await preview.waitFor({ state: 'detached' });
+ assert.ok(await opener.evaluate(el => el === document.activeElement));
+
+ await opener.click();
+ await close.click();
+ await preview.waitFor({ state: 'detached' });
+ assert.ok(await opener.evaluate(el => el === document.activeElement));
+};
diff --git a/e2e/checks/policy-editor-modal.cjs b/e2e/checks/policy-editor-modal.cjs
new file mode 100644
index 000000000..29e9b12ca
--- /dev/null
+++ b/e2e/checks/policy-editor-modal.cjs
@@ -0,0 +1,80 @@
+const assert = require('node:assert/strict');
+
+module.exports = async ({ page, go, fail, shot }) => {
+ const opener = page.getByRole('button', { name: 'New policy', exact: true });
+ const editor = page.getByRole('dialog', { name: /New policy|draft-policy/ });
+ const confirm = page.getByRole('alertdialog', { name: 'Discard unsaved changes?' });
+ const id = editor.getByRole('textbox', { name: 'Policy id' });
+ const cedar = editor.getByRole('textbox', { name: 'Cedar policy' });
+ const dismissals = {
+ Close: () => editor.getByRole('button', { name: 'Close', exact: true }).click({ timeout: 2000 }),
+ Cancel: () => editor.getByRole('button', { name: 'Cancel', exact: true }).click({ timeout: 2000 }),
+ Escape: () => page.keyboard.press('Escape'),
+ Backdrop: () => page.mouse.click(8, 8),
+ };
+ const focused = (field) => field.evaluate(el => el === document.activeElement);
+ const closed = async () => {
+ await page.locator('[role="alertdialog"]').waitFor({ state: 'detached', timeout: 2000 });
+ await page.locator('[role="dialog"]').waitFor({ state: 'detached', timeout: 2000 });
+ assert.ok(await focused(opener), 'focus did not return to New policy');
+ };
+ const cases = async (scenario, rows, run) => {
+ for (const row of rows) {
+ // A failed modal must not block the next independently tested path.
+ await go('/org/policies');
+ try { await run(row); } catch (error) { fail(`${scenario} ${row}: ${error.message}`); }
+ }
+ };
+
+ await cases('Mobile', ['focus clearance'], async () => {
+ await page.setViewportSize({ width: 390, height: 600 });
+ await opener.click();
+ for (const field of [id, cedar]) {
+ // Opening focuses the ID; Tab past the level selector to reach Cedar.
+ if (field === cedar) {
+ await page.keyboard.press('Tab');
+ await page.keyboard.press('Tab');
+ }
+ assert.ok(await focused(field), 'keyboard focus did not reach the policy field');
+ const { name, clearance, ring } = await field.evaluate(el => {
+ const form = el.closest('form');
+ const bounds = form.getBoundingClientRect();
+ const field = el.getBoundingClientRect();
+ const css = getComputedStyle(el);
+ return {
+ name: el.getAttribute('aria-label'),
+ clearance: Math.min(field.left - bounds.left, field.top - bounds.top,
+ bounds.left + form.clientWidth - field.right, bounds.top + form.clientHeight - field.bottom),
+ ring: Math.max(3, parseFloat(css.outlineWidth) + parseFloat(css.outlineOffset)),
+ };
+ });
+ if (clearance + 0.1 < ring) fail(`${name} focus ring: ${clearance}px clearance for ${ring}px ring`);
+ await shot(name);
+ }
+ });
+ await page.setViewportSize({ width: 1440, height: 900 });
+
+ await cases('Clean', Object.keys(dismissals), async (action) => {
+ await opener.click();
+ await dismissals[action]();
+ await closed();
+ });
+
+ await cases('Dirty', Object.keys(dismissals), async (action) => {
+ await opener.click();
+ await id.pressSequentially('draft-policy');
+ await dismissals[action]();
+ const keep = confirm.getByRole('button', { name: 'Keep editing' });
+ await keep.waitFor({ timeout: 2000 });
+ if (action === 'Escape') await page.keyboard.press('Escape');
+ else await keep.click({ timeout: 2000 });
+ await page.locator('[role="alertdialog"]').waitFor({ state: 'detached', timeout: 2000 });
+ assert.equal(await id.inputValue(), 'draft-policy');
+ assert.ok(await editor.evaluate(el => el.contains(document.activeElement)), 'focus did not return to the editor');
+ await dismissals[action]();
+ await confirm.getByRole('button', { name: 'Discard changes' }).click({ timeout: 2000 });
+ await closed();
+ await opener.click();
+ assert.equal(await id.inputValue(), '', 'discarded policy reappeared on reopen');
+ });
+};
diff --git a/ui/src/org/OrgAccessPage.vue b/ui/src/org/OrgAccessPage.vue
index b54e03bb9..c6e3da49c 100644
--- a/ui/src/org/OrgAccessPage.vue
+++ b/ui/src/org/OrgAccessPage.vue
@@ -209,7 +209,7 @@ onMounted(load);