-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
TuiCalendarRange
with range changer
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import {DemoRoute} from '@demo/routes'; | ||
import { | ||
TuiCalendarRangePO, | ||
TuiDocumentationPagePO, | ||
tuiGoto, | ||
} from '@demo-playwright/utils'; | ||
import {expect, type Locator, test} from '@playwright/test'; | ||
|
||
test.describe('CalendarRange', () => { | ||
let example!: Locator; | ||
let calendarRange!: TuiCalendarRangePO; | ||
let documentationPage!: TuiDocumentationPagePO; | ||
|
||
test.beforeEach(async ({page}) => { | ||
await tuiGoto(page, DemoRoute.CalendarRange, {date: new Date(2024, 9, 31)}); | ||
|
||
documentationPage = new TuiDocumentationPagePO(page); | ||
example = documentationPage.getExample('#with-another-range-switcher'); | ||
calendarRange = new TuiCalendarRangePO(example.locator('tui-calendar-range')); | ||
}); | ||
|
||
test.describe('Examples', () => { | ||
test('With another range switcher', async () => { | ||
const getRangeSwitcher = (): Locator => | ||
example.locator('p button[data-appearance="link"]'); | ||
|
||
await expect(example).toHaveScreenshot( | ||
Check failure on line 27 in projects/demo-playwright/tests/kit/calendar-range/calendar-range.spec.ts GitHub Actions / playwright / (6 of 9)[chromium] › tests/kit/calendar-range/calendar-range.spec.ts:23:13 › CalendarRange › Examples › With another range switcher
Check failure on line 27 in projects/demo-playwright/tests/kit/calendar-range/calendar-range.spec.ts GitHub Actions / playwright / (6 of 9)[chromium] › tests/kit/calendar-range/calendar-range.spec.ts:23:13 › CalendarRange › Examples › With another range switcher
Check failure on line 27 in projects/demo-playwright/tests/kit/calendar-range/calendar-range.spec.ts GitHub Actions / playwright / (6 of 9)[chromium] › tests/kit/calendar-range/calendar-range.spec.ts:23:13 › CalendarRange › Examples › With another range switcher
|
||
'05-calendar-range-correct-display-defaults-items-and-values.png', | ||
); | ||
|
||
await calendarRange.selectItem(1); | ||
await calendarRange.itemHasCheckmark(1); | ||
|
||
await expect(example).toHaveScreenshot( | ||
'05-calendar-range-correct-display-range-switcher-after-select-week.png', | ||
); | ||
|
||
getRangeSwitcher().click(); | ||
|
||
await expect(example).toHaveScreenshot( | ||
'05-calendar-range-correct-display-items-and-values-after-click-on-month-range-switcher.png', | ||
); | ||
|
||
getRangeSwitcher().click(); | ||
|
||
await expect(example).toHaveScreenshot( | ||
'05-calendar-range-correct-display-items-and-values-after-click-on-quarter-range-switcher.png', | ||
); | ||
|
||
getRangeSwitcher().click(); | ||
|
||
await expect(example).toHaveScreenshot( | ||
'05-calendar-range-correct-display-defaults-items-and-values.png', | ||
); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {expect, type Locator} from '@playwright/test'; | ||
|
||
export class TuiCalendarRangePO { | ||
constructor(private readonly host: Locator) {} | ||
|
||
public async getItems(): Promise<Locator[]> { | ||
const dataList = this.host.locator('[automation-id="tui-calendar-range__menu"]'); | ||
|
||
await expect(dataList).toBeAttached(); | ||
|
||
return dataList.locator('[tuiOption]').all(); | ||
} | ||
|
||
public async selectItem(index: number): Promise<void> { | ||
const items = await this.getItems(); | ||
|
||
await items[index].click(); | ||
} | ||
|
||
public async itemHasCheckmark(index: number): Promise<boolean> { | ||
const items = await this.getItems(); | ||
|
||
const itemCheckmark = await items[index] | ||
.locator('[automation-id="tui-calendar-range__checkmark"]') | ||
.count(); | ||
|
||
return !!itemCheckmark; | ||
} | ||
} |