upskill-event-manager/wordpress-dev/tests/e2e/pages/EventSummaryPage.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

88 lines
No EOL
3.2 KiB
TypeScript

import { Page } from '@playwright/test';
import { BasePage } from './BasePage';
export class EventSummaryPage extends BasePage {
private readonly editEventButton = 'a:has-text("Edit Event")';
private readonly emailAttendeesButton = 'a:has-text("Email Attendees")';
private readonly returnToDashboardButton = 'a:has-text("Return to Dashboard")';
private readonly eventDetails = '.event-details';
private readonly transactionsTable = '.transactions-table';
private readonly eventTitle = '.event-title';
private readonly eventDate = '.event-date';
private readonly eventLocation = '.event-location';
private readonly eventOrganizer = '.event-organizer';
private readonly ticketInfo = '.ticket-info';
private readonly eventDescription = '.event-description';
constructor(page: Page) {
super(page);
}
async navigateToEventSummary(eventId: string): Promise<void> {
await this.navigate(`/event-summary/?event_id=${eventId}`);
}
async clickEditEvent(): Promise<void> {
await this.click(this.editEventButton);
await this.waitForNavigation();
}
async clickEmailAttendees(): Promise<void> {
await this.click(this.emailAttendeesButton);
await this.waitForNavigation();
}
async returnToDashboard(): Promise<void> {
await this.click(this.returnToDashboardButton);
await this.waitForNavigation();
}
async getEventDetails(): Promise<{
title: string;
date: string;
location: string;
organizer: string;
ticketInfo: string;
description: string;
}> {
return {
title: await this.getText(this.eventTitle),
date: await this.getText(this.eventDate),
location: await this.getText(this.eventLocation),
organizer: await this.getText(this.eventOrganizer),
ticketInfo: await this.getText(this.ticketInfo),
description: await this.getText(this.eventDescription)
};
}
async isTransactionsTableVisible(): Promise<boolean> {
return await this.isVisible(this.transactionsTable);
}
async getTransactionData(index: number): Promise<{
purchaserName: string;
organization: string;
purchaseDate: string;
ticketCount: string;
revenue: string;
}> {
const row = await this.page.locator(`${this.transactionsTable} tbody tr`).nth(index);
return {
purchaserName: await row.locator('td:nth-child(1)').textContent() || '',
organization: await row.locator('td:nth-child(2)').textContent() || '',
purchaseDate: await row.locator('td:nth-child(3)').textContent() || '',
ticketCount: await row.locator('td:nth-child(4)').textContent() || '',
revenue: await row.locator('td:nth-child(5)').textContent() || ''
};
}
async getTransactionCount(): Promise<number> {
return await this.page.locator(`${this.transactionsTable} tbody tr`).count();
}
async clickPurchaserName(name: string): Promise<void> {
await this.page.click(`${this.transactionsTable} a:has-text("${name}")`);
await this.waitForNavigation();
}
}