"use strict";
/*
 * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
 * one or more contributor license agreements. See the NOTICE file distributed
 * with this work for additional information regarding copyright ownership.
 * Licensed under the Camunda License 1.0. You may not use this file
 * except in compliance with the Camunda License 1.0.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskPanelPage = void 0;
const test_1 = require("@playwright/test");
class TaskPanelPage {
    assignmentTag;
    assignToMeButton;
    availableTasks;
    completeTaskButton;
    collapseSidePanelButton;
    emptyTaskMessage;
    expandSidePanelButton;
    page;
    taskListPageBanner;
    collapseFilter;
    constructor(page) {
        this.page = page;
        this.assignmentTag = page.locator(' header > div').nth(2);
        this.assignToMeButton = page.getByRole('button', { name: 'Assign to me' });
        this.availableTasks = page.getByTitle('Available tasks');
        this.completeTaskButton = page.getByRole('button', { name: 'Complete Task' });
        this.collapseSidePanelButton = page.locator('button[aria-controls="task-nav-bar"][aria-expanded="true"]');
        this.emptyTaskMessage = this.emptyTaskMessage = page.getByRole('heading', {
            name: /Task has no variables/i,
        });
        this.expandSidePanelButton = page
            .locator('[aria-label="Filter controls"] li')
            .filter({ hasText: 'Expand to show filters' });
        this.taskListPageBanner = page.getByRole('link', {
            name: 'Camunda logo Tasklist',
        });
        this.collapseFilter = page.locator('button[aria-controls="task-nav-bar"][aria-expanded="false"]');
    }
    async assertAssigmentStatus(status) {
        await (0, test_1.expect)(this.assignmentTag).toContainText(status);
    }
    async assignTaskToMe() {
        await this.filterBy('Unassigned');
        await this.openTask('usertask_to_be_assigned');
        await this.assignToMeButton.click();
    }
    async completeATask() {
        await this.filterBy('Unassigned');
        await this.openTask('usertask_to_be_assigned');
        await this.assignToMeButton.click();
        await this.completeTaskButton.click();
    }
    async openTask(name) {
        await this.availableTasks
            .getByText(name, { exact: true })
            .nth(0)
            .click({ timeout: 20000 });
    }
    async taskListBannerIsVisible() {
        await (0, test_1.expect)(this.taskListPageBanner).toBeVisible();
    }
    async asssertUnnassignedTaskEmptyMessage() {
        await (0, test_1.expect)(this.emptyTaskMessage).toBeVisible();
    }
    async filterBy(option) {
        await this.expandSidePanelButton.click();
        await this.page.getByRole('link', { name: option, exact: true }).click();
        await this.collapseSidePanelButton.click();
    }
    async clickCollapseFilter() {
        await this.collapseFilter.click({ timeout: 45000 });
    }
}
exports.TaskPanelPage = TaskPanelPage;
