"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OptimizeDashboardPage = void 0;
const test_1 = require("@playwright/test");
class OptimizeDashboardPage {
    page;
    filterTable;
    constructor(page) {
        this.page = page;
        this.filterTable = page.getByPlaceholder('Filter table');
    }
    async clickFilterTable() {
        await this.filterTable.click({ timeout: 180000 });
    }
    async fillFilterTable(processName) {
        await this.filterTable.fill(processName, { timeout: 60000 });
        await this.filterTable.press('Enter');
    }
    async processOwnerNameAssertion(processName) {
        try {
            await this.page.reload();
            await (0, test_1.expect)(this.page.getByRole('row', {
                name: processName + ' Process QA Camunda',
            })).toBeVisible({ timeout: 180000 });
        }
        catch {
            await this.page.reload();
            await (0, test_1.expect)(this.page.getByRole('row', {
                name: processName + ' Process QA Camunda',
            })).toBeVisible({ timeout: 180000 });
        }
    }
    async processAssertion(processName, { timeout = 210000, not = false } = {}) {
        const interval = 45000;
        const start = Date.now();
        while (Date.now() - start < timeout) {
            const locator = this.page.getByTitle(processName).first();
            try {
                if (not) {
                    await (0, test_1.expect)(locator).not.toBeVisible({ timeout: interval });
                }
                else {
                    await (0, test_1.expect)(locator).toBeVisible({ timeout: interval });
                }
                return;
            }
            catch (e) {
                if (Date.now() - start + interval >= timeout) {
                    throw e;
                }
                await this.page.reload();
            }
        }
    }
}
exports.OptimizeDashboardPage = OptimizeDashboardPage;
