"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;
    filterOptions;
    tasklistBanner;
    collapseFilter;
    processesPageTab;
    tasksTab;
    licenseKeyTagNonProduction;
    licenseKeyTagProduction;
    constructor(page) {
        this.page = page;
        this.availableTasks = page.getByTitle('Available tasks');
        this.filterOptions = page
            .locator('[aria-label="Filter controls"] li')
            .filter({ hasText: 'Expand to show filters' });
        this.tasklistBanner = page.getByRole('link', {
            name: 'Camunda logo Tasklist',
        });
        this.collapseFilter = page.locator('button[aria-controls="task-nav-bar"][aria-expanded="true"]');
        this.processesPageTab = page.getByRole('link', { name: 'Processes' });
        this.tasksTab = page.getByRole('link', { name: 'Tasks', exact: true });
        this.licenseKeyTagNonProduction = page.getByText('Non-production license', {
            exact: true,
        });
        this.licenseKeyTagProduction = page.getByText('Production license', {
            exact: true,
        });
    }
    async openTask(name) {
        await this.availableTasks
            .getByText(name, { exact: true })
            .nth(0)
            .click({ timeout: 180000 });
    }
    async filterBy(option) {
        await this.filterOptions.click({ timeout: 45000 });
        await (0, test_1.expect)(this.page.getByRole('link', { name: option })).toBeVisible({
            timeout: 120000,
        });
        await this.page.getByRole('link', { name: 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 clickCollapseFilter() {
        await this.collapseFilter.click({ timeout: 45000 });
    }
    async clickProcessesTab() {
        await this.processesPageTab.click();
    }
    async taskCount(name) {
        await (0, sleep_1.sleep)(20000);
        return this.availableTasks.getByText(name, { exact: true }).count();
    }
    async clickTasksTab() {
        await this.tasksTab.click();
    }
}
exports.TaskPanelPage = TaskPanelPage;
