import { Page, expect } from '@playwright/test'; import { LogParser } from '../utils/logParser'; export class EventSummaryPage { readonly page: Page; private readonly selectors = { // Navigation buttons editEventButton: '#edit-event-btn', returnToDashboardButton: '#return-dashboard-btn', // Event details sections eventTitle: '#event-title', eventDateTime: '#event-datetime', eventLocation: '#event-location', eventOrganizer: '#event-organizer', eventDescription: '#event-description', // Tickets section ticketPrice: '#ticket-price', ticketQuantity: '#ticket-quantity', ticketsRemaining: '#tickets-remaining', // Transactions table transactionsTable: '#transactions-table', purchaserNameLinks: '.purchaser-name-link', organizationCells: '.organization-cell', purchaseDateCells: '.purchase-date-cell', ticketCountCells: '.ticket-count-cell', revenueCells: '.revenue-cell', // Summary statistics totalTicketsSold: '#total-tickets-sold', totalRevenue: '#total-revenue' }; constructor(page: Page) { this.page = page; } async navigate(eventId: string) { await this.page.goto(`/wp-admin/admin.php?page=event-summary&event_id=${eventId}`); } // Navigation methods async clickEditEvent() { await this.page.click(this.selectors.editEventButton); } async returnToDashboard() { await this.page.click(this.selectors.returnToDashboardButton); } // Event details verification methods async verifyEventDetails(expectedDetails: { title: string; dateTime: string; location: string; organizer: string; description: string; }) { await expect(this.page.locator(this.selectors.eventTitle)).toHaveText(expectedDetails.title); await expect(this.page.locator(this.selectors.eventDateTime)).toHaveText(expectedDetails.dateTime); await expect(this.page.locator(this.selectors.eventLocation)).toHaveText(expectedDetails.location); await expect(this.page.locator(this.selectors.eventOrganizer)).toHaveText(expectedDetails.organizer); await expect(this.page.locator(this.selectors.eventDescription)).toHaveText(expectedDetails.description); } // Ticket information verification methods async verifyTicketInfo(expectedInfo: { price: string; quantity: string; remaining: string; }) { await expect(this.page.locator(this.selectors.ticketPrice)).toHaveText(expectedInfo.price); await expect(this.page.locator(this.selectors.ticketQuantity)).toHaveText(expectedInfo.quantity); await expect(this.page.locator(this.selectors.ticketsRemaining)).toHaveText(expectedInfo.remaining); } // Transaction table verification methods async verifyTransactionDetails(rowIndex: number, expectedTransaction: { purchaserName: string; organization: string; purchaseDate: string; ticketCount: string; revenue: string; }) { const row = { purchaserName: this.page.locator(this.selectors.purchaserNameLinks).nth(rowIndex), organization: this.page.locator(this.selectors.organizationCells).nth(rowIndex), purchaseDate: this.page.locator(this.selectors.purchaseDateCells).nth(rowIndex), ticketCount: this.page.locator(this.selectors.ticketCountCells).nth(rowIndex), revenue: this.page.locator(this.selectors.revenueCells).nth(rowIndex) }; await expect(row.purchaserName).toHaveText(expectedTransaction.purchaserName); await expect(row.organization).toHaveText(expectedTransaction.organization); await expect(row.purchaseDate).toHaveText(expectedTransaction.purchaseDate); await expect(row.ticketCount).toHaveText(expectedTransaction.ticketCount); await expect(row.revenue).toHaveText(expectedTransaction.revenue); } async verifyPurchaserNameLink(rowIndex: number, expectedUrl: string) { const link = this.page.locator(this.selectors.purchaserNameLinks).nth(rowIndex); await expect(link).toHaveAttribute('href', expect.stringContaining(expectedUrl)); } // Summary statistics verification methods async verifyTotalTicketsSold(expectedTotal: string) { await expect(this.page.locator(this.selectors.totalTicketsSold)).toHaveText(expectedTotal); } async verifyTotalRevenue(expectedRevenue: string) { await expect(this.page.locator(this.selectors.totalRevenue)).toHaveText(expectedRevenue); } // Table functionality methods async verifyTransactionTableExists() { await expect(this.page.locator(this.selectors.transactionsTable)).toBeVisible(); } async getTransactionCount(): Promise { const rows = await this.page.locator(`${this.selectors.transactionsTable} tr`).count(); return rows - 1; // Subtract header row } }