"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");
class OperateHomePage {
    page;
    operateHeader;
    processesTab;
    informationDialog;
    editVariableButton;
    variableValueInput;
    saveVariableButton;
    editVariableSpinner;
    operateBanner;
    closeButton;
    messageBanner;
    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.closeButton = page.getByRole('button', { name: 'Got it - Dismiss' });
        this.messageBanner = page.getByRole('button', { name: 'Close' });
    }
    async clickProcessesTab() {
        await (0, clickLocatorWithRetry_1.clickLocatorWithRetry)(this.page, this.processesTab, {
            preAction: async () => {
                await this.clickMessageBanner();
            },
        });
    }
    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();
    }
    async clickMessageBanner() {
        try {
            const button = this.messageBanner.or(this.closeButton).first();
            await (0, test_1.expect)(button).toBeVisible({ timeout: 15000 });
            await button.click();
        }
        catch {
            console.log('No banner or close button found to click');
        }
    }
}
exports.OperateHomePage = OperateHomePage;
