|
1 | 1 | import { Page, expect, Locator } from '@playwright/test'; |
2 | 2 | import { BasePage } from './base.page'; |
3 | 3 |
|
| 4 | +/** |
| 5 | + * Page object for the Program tab navigation. |
| 6 | + */ |
4 | 7 | export class ProgramPage extends BasePage { |
5 | 8 | readonly tabBar: Locator; |
6 | 9 | readonly stepsTab: Locator; |
@@ -56,6 +59,9 @@ export class ProgramPage extends BasePage { |
56 | 59 | } |
57 | 60 | } |
58 | 61 |
|
| 62 | +/** |
| 63 | + * Page object for Program placeholder screens. |
| 64 | + */ |
59 | 65 | export class PlaceholderPage extends BasePage { |
60 | 66 | readonly screen: Locator; |
61 | 67 | readonly title: Locator; |
@@ -85,7 +91,85 @@ export class PlaceholderPage extends BasePage { |
85 | 91 | } |
86 | 92 | } |
87 | 93 |
|
| 94 | +/** |
| 95 | + * Page object for the Program > Prayers tab. |
| 96 | + */ |
| 97 | +export class PrayersPage extends BasePage { |
| 98 | + readonly prayersList: Locator; |
| 99 | + readonly filterAll: Locator; |
| 100 | + readonly filterFavorites: Locator; |
| 101 | + readonly filterStep: Locator; |
| 102 | + readonly filterCommon: Locator; |
| 103 | + readonly prayerCards: Locator; |
| 104 | + |
| 105 | + constructor(page: Page) { |
| 106 | + super(page); |
| 107 | + this.prayersList = page.getByTestId('prayers-list'); |
| 108 | + this.filterAll = page.getByTestId('filter-all'); |
| 109 | + this.filterFavorites = page.getByTestId('filter-favorites'); |
| 110 | + this.filterStep = page.getByTestId('filter-step'); |
| 111 | + this.filterCommon = page.getByTestId('filter-common'); |
| 112 | + this.prayerCards = page.getByTestId(/^prayer-card-/); |
| 113 | + } |
| 114 | + |
| 115 | + async goto(): Promise<void> { |
| 116 | + await this.page.goto('/program/prayers'); |
| 117 | + await this.waitForPageLoad(); |
| 118 | + } |
| 119 | + |
| 120 | + async expectOnPrayersPage(): Promise<void> { |
| 121 | + await expect(this.prayersList).toBeVisible(); |
| 122 | + } |
| 123 | + |
| 124 | + async selectFilter(filter: 'all' | 'favorites' | 'step' | 'common'): Promise<void> { |
| 125 | + await this.page.getByTestId(`filter-${filter}`).click(); |
| 126 | + } |
| 127 | + |
| 128 | + getPrayerCard(prayerId: string): Locator { |
| 129 | + return this.page.getByTestId(`prayer-card-${prayerId}`); |
| 130 | + } |
| 131 | + |
| 132 | + getFavoriteButton(prayerId: string): Locator { |
| 133 | + return this.page.getByTestId(`prayer-favorite-${prayerId}`); |
| 134 | + } |
| 135 | +} |
| 136 | + |
| 137 | +/** |
| 138 | + * Page object for the Program > Meetings tab. |
| 139 | + */ |
| 140 | +export class MeetingsPage extends BasePage { |
| 141 | + readonly meetingItems: Locator; |
| 142 | + |
| 143 | + constructor(page: Page) { |
| 144 | + super(page); |
| 145 | + this.meetingItems = page.getByTestId(/^meeting-item-/); |
| 146 | + } |
| 147 | + |
| 148 | + async goto(): Promise<void> { |
| 149 | + await this.page.goto('/program/meetings'); |
| 150 | + await this.waitForPageLoad(); |
| 151 | + } |
| 152 | + |
| 153 | + async expectOnMeetingsPage(): Promise<void> { |
| 154 | + const today = new Date().getDate(); |
| 155 | + await expect(this.getCalendarDay(today)).toBeVisible(); |
| 156 | + } |
| 157 | + |
| 158 | + getCalendarDay(day: number): Locator { |
| 159 | + return this.page.getByTestId(`calendar-day-${day}`); |
| 160 | + } |
| 161 | + |
| 162 | + getMeetingItem(meetingId: string): Locator { |
| 163 | + return this.page.getByTestId(`meeting-item-${meetingId}`); |
| 164 | + } |
| 165 | +} |
| 166 | + |
| 167 | +/** |
| 168 | + * Factory for Daily Readings placeholder page object. |
| 169 | + */ |
88 | 170 | export const createDailyReadingsPage = (page: Page) => new PlaceholderPage(page, 'daily-readings'); |
89 | | -export const createPrayersPage = (page: Page) => new PlaceholderPage(page, 'prayers'); |
| 171 | + |
| 172 | +/** |
| 173 | + * Factory for Literature placeholder page object. |
| 174 | + */ |
90 | 175 | export const createLiteraturePage = (page: Page) => new PlaceholderPage(page, 'literature'); |
91 | | -export const createMeetingsPage = (page: Page) => new PlaceholderPage(page, 'meetings'); |
|
0 commit comments