"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OperateHomePage = void 0;
const test_1 = require("@playwright/test");
const clickLocatorWithRetry_1 = require("../../utils/assertionHelpers/clickLocatorWithRetry");
const expectLocatorWithRetry_1 = require("../../utils/assertionHelpers/expectLocatorWithRetry");
class OperateHomePage {
    page;
    operateHeader;
    processesTab;
    informationDialog;
    editVariableButton;
    variableValueInput;
    saveVariableButton;
    editVariableSpinner;
    operateBanner;
    noPermissionsMessage;
    processPageHeading;
    constructor(page) {
        this.page = page;
        this.operateHeader = page.getByRole('link', { name: 'Camunda Operate' });
        this.processesTab = page.getByRole('link', {
            name: 'Processes',
            exact: true,
        });
        this.informationDialog = page.getByRole('button', {
            name: 'Close this dialog',
        });
        this.editVariableButton = page.getByTestId('edit-variable-button');
        this.variableValueInput = page.getByTestId('edit-variable-value');
        this.saveVariableButton = page.getByLabel('Save variable');
        this.editVariableSpinner = page
            .getByTestId('variable-operation-spinner')
            .locator('circle')
            .nth(1);
        this.operateBanner = page.getByRole('link', { name: 'Camunda logo Operate' });
        this.noPermissionsMessage = page
            .getByText('You don’t have access to this component')
            .first();
        this.processPageHeading = page
            .getByTestId('expanded-panel')
            .getByText('Process', { exact: true });
    }
    async clickProcessesTab() {
        await (0, clickLocatorWithRetry_1.clickLocatorWithRetry)(this.page, this.processesTab);
        await (0, expectLocatorWithRetry_1.expectLocatorWithRetry)(this.page, this.processPageHeading, {
            preAction: async () => {
                await (0, test_1.expect)(this.processesTab).toBeVisible({ timeout: 30000 });
                await this.processesTab.click({ timeout: 30000 });
            },
        });
    }
    async closeInformationDialog() {
        await this.informationDialog.click();
    }
    async clickEditVariableButton(variableName) {
        const editVariableButton = 'Edit variable ' + variableName;
        await this.page.getByLabel(editVariableButton).click();
    }
    async clickVariableValueInput() {
        await this.variableValueInput.click();
    }
    async clearVariableValueInput() {
        await this.variableValueInput.clear();
    }
    async fillVariableValueInput(value) {
        await this.variableValueInput.fill(value);
    }
    async clickSaveVariableButton() {
        await this.saveVariableButton.click();
    }
}
exports.OperateHomePage = OperateHomePage;
