(page, reportName, options = {})
| 446 | } |
| 447 | |
| 448 | async function saveAndReloadReport(page, reportName, options = {}) { |
| 449 | const { |
| 450 | clickSave = true, |
| 451 | reloadTimeout = 45000, |
| 452 | saveVisibleTimeout = 8000, |
| 453 | } = options; |
| 454 | |
| 455 | if (clickSave) { |
| 456 | const saveIcon = page.locator('#saveIcon').first(); |
| 457 | await saveIcon.waitFor({ state: 'visible', timeout: saveVisibleTimeout }).catch(() => {}); |
| 458 | const isVisible = await saveIcon.isVisible().catch(() => false); |
| 459 | if (isVisible) { |
| 460 | await saveIcon.click(); |
| 461 | await waitForSaveComplete(page); |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | await page.reload({ waitUntil: 'domcontentloaded', timeout: reloadTimeout }); |
| 466 | await waitForIdle(page, 20000); |
| 467 | await dismissAnalyticsOnboarding(page); |
| 468 | await waitForIdle(page, 10000); |
| 469 | |
| 470 | if (!reportName) { |
| 471 | return; |
| 472 | } |
| 473 | |
| 474 | const header = reportHeaderLocator(page); |
| 475 | const headerVisible = await header.isVisible().catch(() => false); |
| 476 | const headerText = headerVisible ? (await header.innerText()).trim() : ''; |
| 477 | if (!headerVisible || !headerText.includes(reportName)) { |
| 478 | await openExistingReport(page, reportName); |
| 479 | return; |
| 480 | } |
| 481 | await assertReportHeader(page, reportName); |
| 482 | } |
| 483 | |
| 484 | async function openExistingReport(page, reportName) { |
| 485 | await ensureNavigationSection(page, 'reports'); |
no test coverage detected