upskill-event-manager/wordpress-dev/tests/e2e/page-objects/login-page.ts
bengizmo d6211ee364 feat(testing): Implement HVAC_Test_User_Factory and update .gitignore
- Add HVAC_Test_User_Factory class with:
  * User creation with specific roles
  * Multiple role support
  * Persona management system
  * Account cleanup integration
- Create comprehensive test suite in HVAC_Test_User_Factory_Test.php
- Update testing improvement plan documentation
- Add implementation decisions to project memory bank
- Restructure .gitignore with:
  * Whitelist approach for better file management
  * Explicit backup exclusions
  * Specific bin directory inclusions

Part of the Account Management component from the testing framework improvement plan.
2025-04-14 17:41:36 -03:00

59 lines
No EOL
1.8 KiB
TypeScript

import { Page, expect } from '@playwright/test';
export class LoginPage {
readonly page: Page;
// Selectors
private readonly usernameInput = '#user_login';
private readonly passwordInput = '#user_pass';
private readonly loginButton = '#wp-submit';
private readonly rememberMeCheckbox = '#rememberme';
private readonly errorMessage = '.login-error';
private readonly resetPasswordLink = 'a[href*="lost-password"]';
private readonly logoutLink = 'a[href*="logout"]';
constructor(page: Page) {
this.page = page;
}
async goto() {
await this.page.goto('https://wordpress-974670-5399585.cloudwaysapps.com/wp-login.php');
}
async login(username: string, password: string, rememberMe = false) {
await this.page.fill(this.usernameInput, username);
await this.page.fill(this.passwordInput, password);
if (rememberMe) {
await this.page.check(this.rememberMeCheckbox);
}
await this.page.click(this.loginButton);
}
async logout() {
await this.page.click(this.logoutLink);
// Verify we're back at the login page
await expect(this.page).toHaveURL(/.*wp-login.php/);
}
async initiatePasswordReset(username: string) {
await this.page.click(this.resetPasswordLink);
await this.page.fill('#user_login', username);
await this.page.click('input[value="Get New Password"]');
}
async getErrorMessage() {
const error = await this.page.locator(this.errorMessage);
return error.textContent();
}
async isLoggedIn() {
return await this.page.locator('body.logged-in').isVisible();
}
async isRememberMeChecked() {
const checkbox = await this.page.locator(this.rememberMeCheckbox);
return await checkbox.isChecked();
}
}