Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

1.3 KB
Raw Blame
import { type Locator, type Page } from '@playwright/test';

export class PublicEventPage {
  constructor(private readonly page: Page) {}

  async goto(eventId: number, slug: string): Promise<void> {
    await this.page.goto(`/event/${eventId}/${slug}`);
    await this.page.waitForLoadState('networkidle');
  }

  ticketsRegion(): Locator {
    return this.page.getByRole('region', { name: 'Tickets' });
  }

  sectionBar(): Locator {
    return this.page.getByRole('navigation', { name: 'Sections' });
  }

  moreEventsSection(): Locator {
    return this.page.locator('section#more-events');
  }

  joinWaitlistButton(): Locator {
    return this.page.getByTestId('join-waitlist-button');
  }

  async joinWaitlist(details: { firstName: string; email: string }): Promise<void> {
    await this.joinWaitlistButton().click();
    const dialog = this.page.getByRole('dialog');
    await dialog.getByLabel(/^First Name/).fill(details.firstName);
    await dialog.getByLabel(/^Email/).fill(details.email);
    await dialog.getByLabel(/agree to receive email notifications/).check();
    await dialog.getByRole('button', { name: 'Join Waitlist' }).click();
  }

  async closeWaitlistSuccessModal(): Promise<void> {
    await this.page.getByRole('dialog').getByRole('button', { name: 'Close' }).click();
  }
}