"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SettingsPage = void 0;
class SettingsPage {
    page;
    openSettingsButton;
    logoutButton;
    constructor(page) {
        this.page = page;
        this.openSettingsButton = page.getByLabel('Open Settings');
        this.logoutButton = page.getByRole('button', { name: 'Log out' });
    }
    async clickOpenSettingsButton(retries = 3) {
        for (let i = 0; i < retries; i++) {
            try {
                await this.openSettingsButton.click({ timeout: 180000 });
                return; // If successful, exit the function
            }
            catch (error) {
                const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
                await sleep(10000);
            }
        }
        throw new Error(`Failed to click button after ${retries} retries`);
    }
    async clickLogoutButton(retries = 3) {
        for (let i = 0; i < retries; i++) {
            try {
                await this.logoutButton.click({ timeout: 120000 });
                return; // Click succeeded, exit the loop
            }
            catch (error) {
                console.error(`Attempt ${i + 1} to click deploy button failed: ${error}`);
                // Wait for 10 seconds
                const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
                await sleep(10000);
                await this.clickOpenSettingsButton();
            }
        }
        throw new Error(`Failed to click deploy button after ${retries} retries`);
    }
}
exports.SettingsPage = SettingsPage;
