"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConsoleHomePage = void 0;
const test_1 = require("@playwright/test");
class ConsoleHomePage {
    page;
    consoleBanner;
    clusterTab;
    licenseKeyTagNonProduction;
    licenseKeyTagProduction;
    constructor(page) {
        this.page = page;
        this.consoleBanner = page.getByRole('link', {
            name: 'Camunda logo Console',
        });
        this.clusterTab = page
            .getByRole('banner')
            .getByRole('link', { name: 'Clusters' });
        this.licenseKeyTagNonProduction = page.getByText('Non-production license', {
            exact: true,
        });
        this.licenseKeyTagProduction = page.getByText('Production license', {
            exact: true,
        });
    }
    async clickClusters() {
        // Console banner re-renders during initial load, which can detach the
        // Clusters link mid-click. Retry on transient detach errors.
        const maxAttempts = 3;
        for (let attempt = 1; attempt <= maxAttempts; attempt++) {
            try {
                await (0, test_1.expect)(this.clusterTab).toBeVisible({ timeout: 60000 });
                await this.clusterTab.click({ timeout: 30000 });
                return;
            }
            catch (err) {
                if (attempt === maxAttempts)
                    throw err;
                await this.page.waitForTimeout(2000);
            }
        }
    }
}
exports.ConsoleHomePage = ConsoleHomePage;
