"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskListLoginPage = void 0;
const test_1 = require("@playwright/test");
class TaskListLoginPage {
    page;
    usernameInput;
    passwordInput;
    loginButton;
    constructor(page) {
        this.page = page;
        this.usernameInput = page.getByLabel('Username');
        this.passwordInput = page.getByRole('textbox', { name: 'password' });
        this.loginButton = page.getByRole('button', { name: /log.?in|sign.?in/i });
    }
    async fillUsername(username) {
        await this.usernameInput.fill(username);
    }
    async clickUsername() {
        await this.usernameInput.click({ timeout: 60000 });
    }
    async fillPassword(password) {
        await this.passwordInput.fill(password);
    }
    async clickLoginButton() {
        await this.loginButton.click({ timeout: 60000 });
    }
    async login(username, password) {
        try {
            await (0, test_1.expect)(this.usernameInput).toBeVisible();
            await (0, test_1.expect)(this.passwordInput).toBeVisible();
            await this.clickUsername();
            await this.fillUsername(username);
            await this.fillPassword(password);
            await this.clickLoginButton();
        }
        catch {
            await (0, test_1.expect)(this.page.getByRole('link', { name: 'Camunda logo Tasklist' })).toBeVisible();
        }
    }
}
exports.TaskListLoginPage = TaskListLoginPage;
