-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(demo-playwright):
CalendarSheet
add
- Loading branch information
Showing
6 changed files
with
49 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
projects/demo-playwright/utils/page-objects/calendar-sheet.po.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type {Locator} from '@playwright/test'; | ||
|
||
export class TuiCalendarSheetPO { | ||
constructor(private readonly host: Locator) {} | ||
|
||
async getDays(): Promise<Locator[]> { | ||
return this.host | ||
.locator( | ||
'[automation-id="tui-primitive-calendar__cell"], [automation-id="tui-primitive-calendar-mobile__cell"]', | ||
) | ||
.all(); | ||
} | ||
|
||
async clickOnDay(day: number): Promise<void> { | ||
const cells = await this.getDays(); | ||
|
||
for (const cell of cells) { | ||
if ((await cell.textContent())?.trim() === day.toString()) { | ||
await cell.click(); | ||
|
||
break; | ||
} | ||
} | ||
} | ||
} |
23 changes: 12 additions & 11 deletions
23
projects/demo-playwright/utils/page-objects/calendar.po.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import {Locator} from '@playwright/test'; | ||
|
||
import {TuiCalendarSheetPO} from './calendar-sheet.po'; | ||
|
||
export class TuiCalendarPO { | ||
constructor(private readonly host: Locator) {} | ||
readonly itemButton: Locator = this.host | ||
.page() | ||
.locator('tui-dropdown tui-calendar ~ * button'); | ||
|
||
async getDays(): Promise<Locator[]> { | ||
return this.host.locator('[automation-id="tui-primitive-calendar__cell"]').all(); | ||
} | ||
constructor(private readonly host: Locator) {} | ||
|
||
async clickOnCalendarDay(day: number): Promise<void> { | ||
const cells = await this.getDays(); | ||
async getCalendarSheets(): Promise<TuiCalendarSheetPO[]> { | ||
const locators = await this.host | ||
.page() | ||
.locator('tui-primitive-calendar, tui-primitive-calendar-mobile') | ||
.all(); | ||
|
||
for (const cell of cells) { | ||
if ((await cell.textContent())?.trim() === day.toString()) { | ||
return cell.click(); | ||
} | ||
} | ||
return locators.map(x => new TuiCalendarSheetPO(x)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters