From 507bfb9c0f8bf7f1fec75c3e9274424dfef0a4b3 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 25 Oct 2026 23:04:56 +1100 Subject: [PATCH] test(e2e): wait for audit dialogs to close --- e2e/checks/audit.cjs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/e2e/checks/audit.cjs b/e2e/checks/audit.cjs index 5322f5e3e..2ded45406 100644 --- a/e2e/checks/audit.cjs +++ b/e2e/checks/audit.cjs @@ -239,8 +239,8 @@ module.exports = async ({ page, go, shot, fail }) => { assert.match(await dialog.innerText(), /Revert this change\?/); assert.match(await dialog.innerText(), /previous version opens for review/i); await dialog.getByRole('button', { name: 'Cancel', exact: true }).click(); - await page.waitForTimeout(300); - assert.equal(await page.getByRole('alertdialog').count(), 0, 'Cancel left the revert dialog open'); + await dialog.waitFor({ state: 'hidden', timeout: 5000 }).catch(() => {}); + assert.ok(!(await dialog.isVisible().catch(() => false)), 'Cancel left the revert dialog open'); assert.equal( await page.getByRole('region', { name: 'Unsaved changes' }).count(), 0, @@ -393,8 +393,8 @@ module.exports = async ({ page, go, shot, fail }) => { 'retention dialog did not read the stored resource', ); await retentionDialog.getByRole('button', { name: 'Cancel', exact: true }).click(); - await page.waitForTimeout(300); - assert.equal(await page.getByRole('dialog').count(), 0, 'Cancel left the retention dialog open'); + await retentionDialog.waitFor({ state: 'hidden', timeout: 5000 }).catch(() => {}); + assert.ok(!(await retentionDialog.isVisible().catch(() => false)), 'Cancel left the retention dialog open'); // ---- live tail ----------------------------------------------------------- await go('/settings/audit'); @@ -488,8 +488,8 @@ module.exports = async ({ page, go, shot, fail }) => { const wanted = beforeHours === 2160 ? 2161 : 2160; await hoursField.fill(String(wanted)); await retentionDialog.getByRole('button', { name: 'Save', exact: true }).click(); - await page.waitForTimeout(1500); - const stillOpen = (await page.getByRole('dialog').count()) > 0; + await retentionDialog.waitFor({ state: 'hidden', timeout: 5000 }).catch(() => {}); + const stillOpen = await retentionDialog.isVisible().catch(() => false); const afterSave = await (await page.request.get(`${new URL(page.url()).origin}/api/control-plane/resources/audit-retention`)).json(); const afterHours = retentionHours(afterSave.resource.value.runtime_event_retention); if (stillOpen || afterHours !== wanted) {