"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OptimizeCollectionsPage = void 0;
const test_1 = require("@playwright/test");
class OptimizeCollectionsPage {
    page;
    collectionsPageHeader;
    createNewButton;
    reportOption;
    modalCloseButton;
    processReport;
    collectionsLink;
    constructor(page) {
        this.page = page;
        this.collectionsPageHeader = page.getByRole('heading', {
            name: 'Collections, Dashboards, and Reports',
        });
        this.createNewButton = page.getByRole('button', {
            name: 'Create new',
            exact: true,
        });
        this.reportOption = page.getByText('Report', { exact: true });
        this.modalCloseButton = page.getByText('Close', { exact: true });
        this.processReport = page.getByText('Process Report').first();
        this.collectionsLink = page.getByRole('link', { name: 'Collections' });
    }
    async closeModal() {
        await this.modalCloseButton.click({ timeout: 60000 });
    }
    async clickCreateNewButton() {
        await this.collectionsLink.click({ timeout: 60000 });
        await this.createNewButton.click({ timeout: 90000 });
    }
    async clickReportOption() {
        await this.reportOption.click();
    }
    async clickMostRecentProcessReport(reportName) {
        let retries = 120;
        while (retries > 0) {
            try {
                await this.page.getByText(reportName).first().click({ timeout: 500 });
                break;
            }
            catch (error) {
                retries--;
                (0, test_1.expect)(retries).toBeGreaterThan(0);
            }
        }
    }
}
exports.OptimizeCollectionsPage = OptimizeCollectionsPage;
