Skip to content

Commit

Permalink
fix(kit): InputDate click any day after Until today selected
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlufy committed Oct 22, 2024
1 parent 81ed55c commit 1a15f35
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 1 deletion.
39 changes: 39 additions & 0 deletions projects/demo-playwright/tests/kit/input-date/input-date.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {TuiDocumentationPagePO, tuiGoto} from '@demo-playwright/utils';

Check failure on line 1 in projects/demo-playwright/tests/kit/input-date/input-date.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (3 of 4)

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

1) [chromium] › tests/kit/input-date/input-date.spec.ts:27:13 › InputDate › API › Click any day after `Until today` was selected Test timeout of 30000ms exceeded.

Check failure on line 1 in projects/demo-playwright/tests/kit/input-date/input-date.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (3 of 4)

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

1) [chromium] › tests/kit/input-date/input-date.spec.ts:27:13 › InputDate › API › Click any day after `Until today` was selected Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Test timeout of 30000ms exceeded.
import type {Locator} from '@playwright/test';
import {expect, test} from '@playwright/test';

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

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

test.use({
viewport: {
width: 600,
height: 800,
},
});

test.beforeEach(({page}) => {
documentationPage = new TuiDocumentationPagePO(page);
example = documentationPage.apiPageExample;

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

test('Click any day after `Until today` was selected', async ({page}) => {
await tuiGoto(page, 'components/input-date/API?items$=1');

await inputDate.textfield.click();
await inputDate.clickItemButton();

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

await expect(inputDate.textfield).toHaveScreenshot('01-input-date.png');
});
});
});
1 change: 1 addition & 0 deletions projects/demo-playwright/utils/page-objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './calendar-range.po';
export * from './documentation-page.po';
export * from './input-card.po';
export * from './input-card-grouped.po';
export * from './input-date.po';
export * from './input-date-range.po';
export * from './input-date-time.po';
export * from './input-month.po';
Expand Down
25 changes: 25 additions & 0 deletions projects/demo-playwright/utils/page-objects/input-date.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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"]',
);

constructor(private readonly host: Locator) {}

async clickItemButton(): Promise<void> {
const itemButton = this.host
.page()
.locator('[automation-id="tui-input-date__button"]');

await itemButton.click();

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

View workflow job for this annotation

GitHub Actions / playwright / (3 of 4)

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

1) [chromium] › tests/kit/input-date/input-date.spec.ts:27: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:17 15 | .locator('[automation-id="tui-input-date__button"]'); 16 | > 17 | await itemButton.click(); | ^ 18 | } 19 | 20 | async clickOnCalendarDay(day: number): Promise<void> { at TuiInputDatePO.clickItemButton (/home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/utils/page-objects/input-date.po.ts:17:26) at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-date/input-date.spec.ts:31:29

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

View workflow job for this annotation

GitHub Actions / playwright / (3 of 4)

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

1) [chromium] › tests/kit/input-date/input-date.spec.ts:27: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:17 15 | .locator('[automation-id="tui-input-date__button"]'); 16 | > 17 | await itemButton.click(); | ^ 18 | } 19 | 20 | async clickOnCalendarDay(day: number): Promise<void> { at TuiInputDatePO.clickItemButton (/home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/utils/page-objects/input-date.po.ts:17:26) at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-date/input-date.spec.ts:31:29
}

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

await calendar.clickOnCalendarDay(day);
}
}
10 changes: 9 additions & 1 deletion projects/kit/components/input-date/input-date.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,15 @@ export class TuiInputDateComponent
}

get computedMask(): MaskitoOptions {
return this.activeItem
/**
* TODO: we can delete this workaround in v4.0
* after solving this issue:
* https://github.com/taiga-family/maskito/issues/604
*/
const nativeValueIsNotSynced =
this.textfield?.nativeFocusableElement?.value !== this.computedValue;

return this.activeItem || nativeValueIsNotSynced
? MASKITO_DEFAULT_OPTIONS
: this.computeMaskOptions(
this.dateFormat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
class="t-button"
>
<button
automation-id="tui-input-date__button"
tuiLink
type="button"
(click)="onDayClick(items[0].day)"
Expand Down

0 comments on commit 1a15f35

Please sign in to comment.