|
1 | | -import { Page } from "playwright/test"; |
2 | | -import { SettingsPage } from "../SettingsPage"; |
| 1 | +import { Page, Locator, expect } from '@playwright/test'; |
| 2 | +import { SettingsPage } from '../SettingsPage'; |
| 3 | +import { generateDescription, generateFullName, generateRandomDateTime } from '../../../utils/faker'; |
| 4 | + |
| 5 | +type EventData={ |
| 6 | + name:string, |
| 7 | + description:string, |
| 8 | + date:string |
| 9 | +} |
| 10 | +export const eventdata:EventData={ |
| 11 | + name:generateFullName(), |
| 12 | + description:generateDescription(), |
| 13 | + date:"2025-11-18", |
| 14 | +} |
3 | 15 |
|
4 | 16 | export class EventsPage extends SettingsPage { |
5 | 17 | readonly page: Page; |
| 18 | + readonly createEventButton: Locator; |
| 19 | + readonly nameInput: Locator; |
| 20 | + readonly descriptionTextarea: Locator; |
| 21 | + readonly dateInput: Locator; |
| 22 | + readonly saveEventButton: Locator; |
| 23 | + readonly editFirstEventButton: Locator; |
| 24 | + readonly deleteFirstEventButton: Locator; |
| 25 | + readonly confirmDeleteButton: Locator; |
| 26 | + readonly successMessage: Locator; |
6 | 27 |
|
7 | 28 | constructor(page: Page) { |
8 | 29 | super(page); |
9 | 30 | this.page = page; |
| 31 | + this.createEventButton = page.getByRole('button', { name: 'Create Event' }); |
| 32 | + this.nameInput = page.locator('input[name="name"]'); |
| 33 | + this.descriptionTextarea = page.locator('textarea[name="description"]'); |
| 34 | + this.dateInput = page.locator('input[name="date"]'); |
| 35 | + this.saveEventButton = page.getByRole('button', { name: 'Save Event' }); |
| 36 | + this.editFirstEventButton = page.locator('.row > div:nth-child(6) > a').first(); |
| 37 | + this.deleteFirstEventButton = page.locator('div:nth-child(6) > a:nth-child(2)').first(); |
| 38 | + this.confirmDeleteButton = page.getByRole('button', { name: 'Agree', exact: true }); |
| 39 | + this.successMessage = page.getByText(/Event (created|updated|deleted) successfully./); |
| 40 | + } |
| 41 | + |
| 42 | + async gotoEventsPage() { |
| 43 | + await this.page.goto('admin/settings/marketing/events'); |
| 44 | + } |
| 45 | + |
| 46 | + async openCreateEventModal() { |
| 47 | + await this.createEventButton.click(); |
| 48 | + } |
| 49 | + |
| 50 | + async createEvent(eventdata:EventData) { |
| 51 | + await this.nameInput.fill(eventdata.name); |
| 52 | + await this.descriptionTextarea.fill(eventdata.name); |
| 53 | + await this.dateInput.fill(eventdata.date); |
| 54 | + await this.saveEventButton.click(); |
| 55 | + await expect(this.successMessage).toBeVisible(); |
| 56 | + (await this.getElementByTypeAndName('textbox','Search')).fill(eventdata.name); |
| 57 | + await this.page.keyboard.press('Enter'); |
| 58 | + await this.page. |
| 59 | + |
| 60 | + |
10 | 61 | } |
11 | 62 |
|
12 | | - |
| 63 | + |
13 | 64 | } |
0 commit comments