test(reports): fix flaky report folder and schedule-later specs (#15841)

This commit is contained in:
ktx-akshay
2026-10-26 11:56:37 +00:00
committed by GitHub
parent 978c6c94d5
commit 20ff24a587
2 changed files with 21 additions and 8 deletions
@@ -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/
@@ -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) {