From 20ff24a587672c2b0bdcb53a717dc4f01e2fbd37 Mon Sep 17 00:00:00 2001 From: ktx-akshay Date: Mon, 26 Oct 2026 11:56:37 +0000 Subject: [PATCH] test(reports): fix flaky report folder and schedule-later specs (#15841) --- .../pages/dashboardPages/dashboardPage.js | 13 +++++++++---- .../pages/reportsPages/reportFoldersPage.js | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/tests/ui-testing/pages/dashboardPages/dashboardPage.js b/tests/ui-testing/pages/dashboardPages/dashboardPage.js index e7a80bb0e9..a26da27125 100644 --- a/tests/ui-testing/pages/dashboardPages/dashboardPage.js +++ b/tests/ui-testing/pages/dashboardPages/dashboardPage.js @@ -265,11 +265,16 @@ export class DashboardPage { // Use Playwright's built-in expect to wait for button to be enabled await expect(this.dashboardSubmitButton).toBeEnabled({ timeout: 15000 }); - // Click submit button + // The toast only shows after a list refetch; the POST can queue ~30s behind a server DB-pool stall. + const createResponse = this.page.waitForResponse( + (res) => res.request().method() === 'POST' && /\/api\/[^/]+\/dashboards$/.test(new URL(res.url()).pathname), + { timeout: 45000 } + ); await this.dashboardSubmitButton.click(); - - // Wait for the success notification to confirm dashboard was created - await this.toastMessage.first().waitFor({ state: 'visible', timeout: 15000 }); + const res = await createResponse; + if (!res.ok()) { + throw new Error(`Dashboard creation failed: HTTP ${res.status()} ${await res.text().catch(() => '')}`); + } // Wait for navigation to the new dashboard view page. // Some environments (e.g. pentest) may not navigate to /dashboards/view/ diff --git a/tests/ui-testing/pages/reportsPages/reportFoldersPage.js b/tests/ui-testing/pages/reportsPages/reportFoldersPage.js index 9a2380ec1b..d0e188ffeb 100644 --- a/tests/ui-testing/pages/reportsPages/reportFoldersPage.js +++ b/tests/ui-testing/pages/reportsPages/reportFoldersPage.js @@ -172,9 +172,17 @@ export class ReportFoldersPage { if (description) { await this.fillFolderDescription(description); } + // The POST can queue ~30s behind a server DB-pool stall while Save stays disabled, so wait on it rather than the dialog. + const createResponse = this.page.waitForResponse( + (res) => res.request().method() === 'POST' && /\/api\/v2\/[^/]+\/folders\/reports$/.test(new URL(res.url()).pathname), + { timeout: 45000 } + ); await this.clickSaveFolder(); - // Wait for the dialog to close after save - await this.folderDialog.waitFor({ state: 'hidden', timeout: 5000 }).catch(() => {}); + const res = await createResponse; + if (!res.ok()) { + throw new Error(`Create folder "${name}" failed: HTTP ${res.status()} ${await res.text().catch(() => '')}`); + } + await this.folderDialog.waitFor({ state: 'hidden', timeout: 15000 }).catch(() => {}); } async expectFolderTabVisible(folderName) { @@ -183,9 +191,9 @@ export class ReportFoldersPage { await expect.poll(async () => { const id = await this.resolveFolderIdByName(folderName); return id ? 'ready' : 'pending'; - }, { timeout: 10000 }).toBe('ready'); + }, { timeout: 30000 }).toBe('ready'); const tab = await this.getTabByName(folderName); - await expect(tab).toBeVisible({ timeout: 10000 }); + await expect(tab).toBeVisible({ timeout: 15000 }); } async expectFolderTabNotVisible(folderName) {