"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskProcessesPage = void 0;
const test_1 = require("@playwright/test");
const UtilitiesPage_1 = require("./UtilitiesPage");
class TaskProcessesPage {
    page;
    popupContinueButton;
    popup;
    processes;
    constructor(page) {
        this.page = page;
        this.popupContinueButton = page.getByRole('button', { name: 'Continue' });
        this.popup = page.getByLabel('Start your process on demand');
        this.processes = page.locator('[data-testid="process-tile"]');
    }
    async clickpopupContinueButton() {
        try {
            await (0, test_1.expect)(this.popupContinueButton).toBeVisible({ timeout: 15000 });
            await this.popupContinueButton.click({ timeout: 15000 });
            await (0, test_1.expect)(this.popupContinueButton).not.toBeVisible({ timeout: 60000 });
        }
        catch (error) {
            console.log('Popup not present');
        }
    }
    async startProcess(name) {
        const found = await (0, UtilitiesPage_1.findTextWithPagination)(this.page, name, 60000, async () => {
            await this.page
                .locator('[data-testid="process-tile"]')
                .filter({ hasText: name })
                .getByRole('button', { name: 'Start process' })
                .click({ timeout: 60000 });
        });
        if (!found) {
            throw new Error(`Process "${name}" not found in pagination`);
        }
        await (0, test_1.expect)(this.page.getByText('Waiting for tasks...')).not.toBeVisible({
            timeout: 60000,
        });
    }
}
exports.TaskProcessesPage = TaskProcessesPage;
