Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kit): InputDate click any day after Until today selected #9582

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {TuiDocumentationPagePO, tuiGoto} from '@demo-playwright/utils';
import type {Locator} from '@playwright/test';
import {expect, test} from '@playwright/test';

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

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

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'));
calendar = new TuiCalendarPO(inputDate.calendar);
});

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.itemButton.click();

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

await expect(inputDate.textfield).toHaveScreenshot('01-input-date.png');

Check failure on line 38 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: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: Screenshot comparison failed: 498 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/kit/input-date/input-date.spec.ts-snapshots/01-input-date-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-date-input-346f6-er-Until-today-was-selected-chromium/01-input-date-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-date-input-346f6-er-Until-today-was-selected-chromium/01-input-date-diff.png Call log: - expect.toHaveScreenshot(01-input-date.png) with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#demo-content').locator('tui-input-date').getByRole('textbox') - locator resolved to <input tabindex="0" tuimaskaccessor="" aria-invalid="false" _ngcontent-tui-demo-c171="" id="tui_interactive_561601061540000" class="t-input ng-untouched ng-valid ng-dirty" automation-id="tui-primitive-textfield__native-input"/> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - 498 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#demo-content').locator('tui-input-date').getByRole('textbox') - locator resolved to <input tabindex="0" tuimaskaccessor="" aria-invalid="false" _ngcontent-tui-demo-c171="" id="tui_interactive_561601061540000" class="t-input ng-untouched ng-valid ng-dirty" automation-id="tui-primitive-textfield__native-input"/> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - captured a stable screenshot - 498 pixels (ratio 0.01 of all image pixels) are different. 36 | await calendar.clickOnCalendarDay(1); 37 | > 38 | await expect(inputDate.textfield).toHaveScreenshot('01-input-date.png'); | ^ 39 | }); 40 | }); 41 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-date/input-date.spec.ts:38:47

Check failure on line 38 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: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: Screenshot comparison failed: 498 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/kit/input-date/input-date.spec.ts-snapshots/01-input-date-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-date-input-346f6-er-Until-today-was-selected-chromium-retry1/01-input-date-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-input-date-input-346f6-er-Until-today-was-selected-chromium-retry1/01-input-date-diff.png Call log: - expect.toHaveScreenshot(01-input-date.png) with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#demo-content').locator('tui-input-date').getByRole('textbox') - locator resolved to <input tabindex="0" tuimaskaccessor="" aria-invalid="false" _ngcontent-tui-demo-c171="" id="tui_interactive_561601061540000" class="t-input ng-untouched ng-valid ng-dirty" automation-id="tui-primitive-textfield__native-input"/> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - 498 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#demo-content').locator('tui-input-date').getByRole('textbox') - locator resolved to <input tabindex="0" tuimaskaccessor="" aria-invalid="false" _ngcontent-tui-demo-c171="" id="tui_interactive_561601061540000" class="t-input ng-untouched ng-valid ng-dirty" automation-id="tui-primitive-textfield__native-input"/> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - captured a stable screenshot - 498 pixels (ratio 0.01 of all image pixels) are different. 36 | await calendar.clickOnCalendarDay(1); 37 | > 38 | await expect(inputDate.textfield).toHaveScreenshot('01-input-date.png'); | ^ 39 | }); 40 | }); 41 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-date/input-date.spec.ts:38:47
});
});
});
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
11 changes: 11 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,11 @@
import {Locator} from '@playwright/test';

export class TuiInputDatePO {
readonly textfield: Locator = this.host.getByRole('textbox');
readonly calendar: Locator = this.host.page().locator('tui-calendar');
readonly itemButton: Locator = this.host
.page()
.locator('tui-dropdown tui-calendar ~ * button');
nsbarsukov marked this conversation as resolved.
Show resolved Hide resolved

constructor(private readonly host: Locator) {}
}
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
Loading