Skip to content

Commit

Permalink
chore(demo-playwright): InputDate use calendar inside InputDatePO
Browse files Browse the repository at this point in the history
mdlufy committed Oct 23, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 1a15f35 commit 9260160
Showing 2 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -2,13 +2,14 @@ import {TuiDocumentationPagePO, tuiGoto} from '@demo-playwright/utils';
import type {Locator} from '@playwright/test';
import {expect, test} from '@playwright/test';

import {TuiInputDatePO} from '../../../utils';
import {TuiCalendarPO, TuiInputDatePO} from '../../../utils';

test.describe('InputDate', () => {
test.describe('API', () => {
let documentationPage: TuiDocumentationPagePO;
let example: Locator;
let inputDate!: TuiInputDatePO;
let documentationPage: TuiDocumentationPagePO;
let calendar!: TuiCalendarPO;

test.use({
viewport: {
@@ -22,6 +23,7 @@ test.describe('InputDate', () => {
example = documentationPage.apiPageExample;

inputDate = new TuiInputDatePO(example.locator('tui-input-date'));
calendar = new TuiCalendarPO(inputDate.calendar);
});

test('Click any day after `Until today` was selected', async ({page}) => {
@@ -31,7 +33,7 @@ test.describe('InputDate', () => {
await inputDate.clickItemButton();

await inputDate.textfield.click();
await inputDate.clickOnCalendarDay(1);
await calendar.clickOnCalendarDay(1);

await expect(inputDate.textfield).toHaveScreenshot('01-input-date.png');
});
13 changes: 2 additions & 11 deletions projects/demo-playwright/utils/page-objects/input-date.po.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import {Locator} from '@playwright/test';

import {TuiCalendarPO} from './calendar.po';

export class TuiInputDatePO {
readonly textfield: Locator = this.host.locator(
'[automation-id="tui-primitive-textfield__native-input"]',
);
readonly textfield: Locator = this.host.getByRole('textbox');
readonly calendar: Locator = this.host.page().locator('tui-calendar');

constructor(private readonly host: Locator) {}

@@ -16,10 +13,4 @@ export class TuiInputDatePO {

await itemButton.click();

Check failure on line 14 in projects/demo-playwright/utils/page-objects/input-date.po.ts

GitHub Actions / playwright / (3 of 4)

[chromium] › tests/kit/input-date/input-date.spec.ts:29:13 › InputDate › API › Click any day after `Until today` was selected

1) [chromium] › tests/kit/input-date/input-date.spec.ts:29:13 › InputDate › API › Click any day after `Until today` was selected Error: locator.click: Test timeout of 30000ms exceeded. Call log: - waiting for locator('[automation-id="tui-input-date__button"]') at utils/page-objects/input-date.po.ts:14 12 | .locator('[automation-id="tui-input-date__button"]'); 13 | > 14 | await itemButton.click(); | ^ 15 | } 16 | } 17 | at TuiInputDatePO.clickItemButton (/home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/utils/page-objects/input-date.po.ts:14:26) at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-date/input-date.spec.ts:33:29

Check failure on line 14 in projects/demo-playwright/utils/page-objects/input-date.po.ts

GitHub Actions / playwright / (3 of 4)

[chromium] › tests/kit/input-date/input-date.spec.ts:29:13 › InputDate › API › Click any day after `Until today` was selected

1) [chromium] › tests/kit/input-date/input-date.spec.ts:29:13 › InputDate › API › Click any day after `Until today` was selected Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: locator.click: Test timeout of 30000ms exceeded. Call log: - waiting for locator('[automation-id="tui-input-date__button"]') at utils/page-objects/input-date.po.ts:14 12 | .locator('[automation-id="tui-input-date__button"]'); 13 | > 14 | await itemButton.click(); | ^ 15 | } 16 | } 17 | at TuiInputDatePO.clickItemButton (/home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/utils/page-objects/input-date.po.ts:14:26) at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-date/input-date.spec.ts:33:29
}

async clickOnCalendarDay(day: number): Promise<void> {
const calendar = new TuiCalendarPO(this.host.page().locator('tui-calendar'));

await calendar.clickOnCalendarDay(day);
}
}

0 comments on commit 9260160

Please sign in to comment.