"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeycloakLoginPage = void 0;
const test_1 = require("@playwright/test");
const sleep_1 = require("../../utils/sleep");
class KeycloakLoginPage {
    page;
    keycloakBanner;
    constructor(page) {
        this.page = page;
        this.keycloakBanner = page.locator('#keycloak-bg');
    }
    async toBeVisible() {
        await (0, test_1.expect)(this.keycloakBanner).toBeVisible();
    }
    async fillUsername(username) {
        await this.page.fill('#username', username);
    }
    async fillPassword(password, maxRetries = 3) {
        for (let attempt = 1; attempt <= maxRetries; attempt++) {
            try {
                await this.page.fill('#password', password);
                return;
            }
            catch (error) {
                if (attempt === maxRetries) {
                    throw new Error(`fillPassword failed after ${maxRetries} attempts: ${error}`);
                }
                console.warn(`fillPassword attempt ${attempt} failed: ${error}. Retrying...`);
                await (0, sleep_1.sleep)(3000);
            }
        }
    }
    async clickLogin() {
        await this.page.click('button[type="submit"]');
    }
}
exports.KeycloakLoginPage = KeycloakLoginPage;
