"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskPanelPage = void 0;
const test_1 = require("@playwright/test");
const sleep_1 = require("../../utils/sleep");
class TaskPanelPage {
    page;
    availableTasks;
    filterPanel;
    taskListPageBanner;
    processesPageTab;
    tasksTab;
    constructor(page) {
        this.page = page;
        this.availableTasks = page.getByTitle('Available tasks');
        this.filterPanel = page.locator('[aria-controls="task-nav-bar"]');
        this.taskListPageBanner = page.getByRole('link', {
            name: 'Camunda logo Tasklist',
        });
        this.processesPageTab = page.getByRole('link', { name: 'Processes' });
        this.tasksTab = page.getByRole('link', { name: 'Tasks', exact: true });
    }
    async openTask(name) {
        await this.availableTasks
            .getByText(name, { exact: true })
            .nth(0)
            .click({ timeout: 180000 });
    }
    async taskCount(name) {
        await (0, sleep_1.sleep)(20000);
        return this.availableTasks.getByText(name, { exact: true }).count();
    }
    async clickTasksTab() {
        await this.tasksTab.click();
    }
    async filterBy(option) {
        await this.filterPanel.click({ timeout: 120000 });
        await (0, test_1.expect)(this.page.getByRole('link', { name: option }).getByText(option)).toBeVisible({ timeout: 120000 });
        await this.page
            .getByRole('link', { name: option })
            .getByText(option)
            .click({ timeout: 120000 });
    }
    async scrollToLastTask(name) {
        await this.page.getByText(name).last().scrollIntoViewIfNeeded();
    }
    async scrollToFirstTask(name) {
        await this.page.getByText(name).first().scrollIntoViewIfNeeded();
    }
    async clickProcessesTab() {
        await this.processesPageTab.click();
    }
}
exports.TaskPanelPage = TaskPanelPage;
