upskill-event-manager/wordpress-dev/tests/e2e/pages/LoginPage.ts
Ben Reed 04dcc32919 feat(testing): Implement comprehensive trainer journey test suite with Page Object Model
- Created Page Object Model structure for all trainer-facing pages
- Implemented complete test coverage for trainer journey steps 1-8
- Added centralized test data management with test users and events
- Updated run-tests.sh with --trainer-journey option for easy execution
- Enhanced documentation with test setup, usage, and troubleshooting guides
- Created verification scripts to ensure proper test environment setup
- Prepared framework for Phase 2/3 features (email, check-in, certificates)

This implementation provides a solid foundation for testing the complete trainer user journey and can be easily extended as new features are deployed.
2025-05-18 15:42:00 -03:00

47 lines
No EOL
1.5 KiB
TypeScript

import { Page } from '@playwright/test';
import { BasePage } from './BasePage';
export class LoginPage extends BasePage {
private readonly usernameField = '#username';
private readonly passwordField = '#password';
private readonly loginButton = 'button[type="submit"]';
private readonly rememberMeCheckbox = '#rememberme';
private readonly errorMessage = '.error-message';
private readonly forgotPasswordLink = 'a:has-text("Forgot Password")';
constructor(page: Page) {
super(page);
}
async navigateToLogin(): Promise<void> {
await this.navigate('/community-login/');
}
async login(username: string, password: string, rememberMe: boolean = false): Promise<void> {
await this.fill(this.usernameField, username);
await this.fill(this.passwordField, password);
if (rememberMe) {
await this.click(this.rememberMeCheckbox);
}
await this.click(this.loginButton);
await this.waitForNavigation();
}
async getErrorMessage(): Promise<string> {
if (await this.isVisible(this.errorMessage)) {
return await this.getText(this.errorMessage);
}
return '';
}
async isLoginFormVisible(): Promise<boolean> {
return await this.isVisible(this.usernameField) &&
await this.isVisible(this.passwordField);
}
async clickForgotPassword(): Promise<void> {
await this.click(this.forgotPasswordLink);
}
}