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

96 lines
No EOL
3.4 KiB
TypeScript

import { Page, expect } from '@playwright/test';
import { LogParser } from '../utils/logParser';
export class CreateEventPage {
readonly page: Page;
private readonly selectors = {
// Instructions section
instructionsSection: '#event-creation-instructions',
// Form fields
eventNameInput: '#event-name',
eventDescriptionInput: '#event-description',
eventDateInput: '#event-date',
eventTimeInput: '#event-time',
eventLocationInput: '#event-location',
eventOrganizerInput: '#event-organizer',
ticketPriceInput: '#ticket-price',
ticketQuantityInput: '#ticket-quantity',
// Validation messages
validationError: '.validation-error',
// Navigation buttons
submitButton: '#submit-event-btn',
returnToDashboardButton: '#return-dashboard-btn'
};
constructor(page: Page) {
this.page = page;
}
async navigate() {
await this.page.goto('/wp-admin/admin.php?page=community-events-create');
}
async verifyInstructionsVisibility() {
const instructions = await this.page.locator(this.selectors.instructionsSection);
await expect(instructions).toBeVisible();
}
async fillEventDetails(eventDetails: {
name: string;
description: string;
date: string;
time: string;
location: string;
organizer: string;
ticketPrice: string;
ticketQuantity: string;
}) {
await this.page.fill(this.selectors.eventNameInput, eventDetails.name);
await this.page.fill(this.selectors.eventDescriptionInput, eventDetails.description);
await this.page.fill(this.selectors.eventDateInput, eventDetails.date);
await this.page.fill(this.selectors.eventTimeInput, eventDetails.time);
await this.page.fill(this.selectors.eventLocationInput, eventDetails.location);
await this.page.fill(this.selectors.eventOrganizerInput, eventDetails.organizer);
await this.page.fill(this.selectors.ticketPriceInput, eventDetails.ticketPrice);
await this.page.fill(this.selectors.ticketQuantityInput, eventDetails.ticketQuantity);
}
async submitEvent() {
await this.page.click(this.selectors.submitButton);
}
async returnToDashboard() {
await this.page.click(this.selectors.returnToDashboardButton);
}
async verifyValidationError(field: string, expectedMessage: string) {
const errorMessage = await this.page.locator(`${this.selectors.validationError}[data-field="${field}"]`);
await expect(errorMessage).toHaveText(expectedMessage);
}
async verifyRequiredFieldValidation() {
await this.submitEvent();
const requiredFields = [
'event-name',
'event-date',
'event-time',
'event-location',
'ticket-price',
'ticket-quantity'
];
for (const field of requiredFields) {
const errorMessage = await this.page.locator(`${this.selectors.validationError}[data-field="${field}"]`);
await expect(errorMessage).toBeVisible();
}
}
async verifyPluginIntegration() {
// Verify The Events Calendar Community Events plugin elements
await expect(this.page.locator('.tribe-community-events')).toBeVisible();
await expect(this.page.locator('.tribe-community-events-content')).toBeVisible();
}
}