(page, reportName, options = {})
| 460 | } |
| 461 | |
| 462 | async function saveAndReloadReport(page, reportName, options = {}) { |
| 463 | const { |
| 464 | clickSave = true, |
| 465 | reloadTimeout = 45000, |
| 466 | saveVisibleTimeout = 8000, |
| 467 | } = options; |
| 468 | |
| 469 | if (clickSave) { |
| 470 | const saveIcon = page.locator('#saveIcon').first(); |
| 471 | await saveIcon.waitFor({ state: 'visible', timeout: saveVisibleTimeout }).catch(() => {}); |
| 472 | const isVisible = await saveIcon.isVisible().catch(() => false); |
| 473 | if (isVisible) { |
| 474 | await saveIcon.click(); |
| 475 | await waitForSaveComplete(page); |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | await page.reload({ waitUntil: 'domcontentloaded', timeout: reloadTimeout }); |
| 480 | await waitForIdle(page, 20000); |
| 481 | await dismissAnalyticsOnboarding(page); |
| 482 | await waitForIdle(page, 10000); |
| 483 | |
| 484 | if (!reportName) { |
| 485 | return; |
| 486 | } |
| 487 | |
| 488 | const header = reportHeaderLocator(page); |
| 489 | const headerVisible = await header.isVisible().catch(() => false); |
| 490 | const headerText = headerVisible ? (await header.innerText()).trim() : ''; |
| 491 | if (!headerVisible || !headerText.includes(reportName)) { |
| 492 | await openExistingReport(page, reportName); |
| 493 | return; |
| 494 | } |
| 495 | await assertReportHeader(page, reportName); |
| 496 | } |
| 497 | |
| 498 | async function openExistingReport(page, reportName) { |
| 499 | await ensureNavigationSection(page, 'reports'); |
no test coverage detected