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(legacy): InputDate{Range|Time} + input[tuiTextfieldLegacy] + tuiTextfieldFiller has CD problems #9932

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Expand Up @@ -291,5 +291,38 @@
'08-calendar-correct-selected-period-after-close-open.png',
);
});

test.describe('with `input[tuiTextfieldLegacy]` inside', () => {
test('filler has no change detection problems', async () => {
const example = documentationPage.getExample('#base');
const inputDateRange = new TuiInputDateRangePO(
example.locator('tui-input-date-range'),
);

/**
* To ensure that example is not changed and
* still contains InputDateRange with projected <input tuiTextfieldLegacy>
*/
await expect(
inputDateRange.host.locator('input[tuiTextfieldLegacy]'),
).toBeAttached();

await inputDateRange.textfield.focus();

await expect(inputDateRange.host).toHaveScreenshot(
'12-backspace-pressed-0-times.png',
);

for (let i = 1; i <= 16; i++) {
await inputDateRange.textfield.press('Backspace');

await expect(inputDateRange.host).toHaveScreenshot(

Check failure on line 319 in projects/demo-playwright/tests/legacy/input-date-range/input-date-range.pw.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / ubuntu-latest / 7 of 9

[chromium] › tests/legacy/input-date-range/input-date-range.pw.spec.ts:296:17 › InputDateRange › Examples › with `input[tuiTextfieldLegacy]` inside › filler has no change detection problems

3) [chromium] › tests/legacy/input-date-range/input-date-range.pw.spec.ts:296:17 › InputDateRange › Examples › with `input[tuiTextfieldLegacy]` inside › filler has no change detection problems Error: expect(locator).toHaveScreenshot(expected) 204 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/legacy/input-date-range/input-date-range.pw.spec.ts-snapshots/12-backspace-pressed-2-times-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-ra-9043d-o-change-detection-problems-chromium/12-backspace-pressed-2-times-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-ra-9043d-o-change-detection-problems-chromium/12-backspace-pressed-2-times-diff.png Call log: - expect.toHaveScreenshot(12-backspace-pressed-2-times.png) with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#base [automation-id="tui-doc-example"]').locator('tui-input-date-range') - locator resolved to <tui-input-date-range data-size="l" _nghost-ng-c592222274="" formcontrolname="testValue" tuiunfinishedvalidator="Finish filling the field" class="ng-untouched _focused ng-dirty ng-invalid">…</tui-input-date-range> - 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 - 204 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#base [automation-id="tui-doc-example"]').locator('tui-input-date-range') - locator resolved to <tui-input-date-range data-size="l" _nghost-ng-c592222274="" formcontrolname="testValue" tuiunfinishedvalidator="Finish filling the field" class="ng-untouched _focused ng-dirty ng-invalid">…</tui-input-date-range> - 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 - 204 pixels (ratio 0.01 of all image pixels) are different. 317 | await inputDateRange.textfield.press('Backspace'); 318 | > 319 | await expect(inputDateRange.host).toHaveScreenshot( | ^ 320 | `12-backspace-pressed-${i}-times.png`, 321 | ); 322 | } at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/legacy/input-date-range/input-date-range.pw.spec.ts:319:55

Check failure on line 319 in projects/demo-playwright/tests/legacy/input-date-range/input-date-range.pw.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / ubuntu-latest / 7 of 9

[chromium] › tests/legacy/input-date-range/input-date-range.pw.spec.ts:296:17 › InputDateRange › Examples › with `input[tuiTextfieldLegacy]` inside › filler has no change detection problems

3) [chromium] › tests/legacy/input-date-range/input-date-range.pw.spec.ts:296:17 › InputDateRange › Examples › with `input[tuiTextfieldLegacy]` inside › filler has no change detection problems Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveScreenshot(expected) 204 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/legacy/input-date-range/input-date-range.pw.spec.ts-snapshots/12-backspace-pressed-2-times-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-ra-9043d-o-change-detection-problems-chromium-retry1/12-backspace-pressed-2-times-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-ra-9043d-o-change-detection-problems-chromium-retry1/12-backspace-pressed-2-times-diff.png Call log: - expect.toHaveScreenshot(12-backspace-pressed-2-times.png) with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#base [automation-id="tui-doc-example"]').locator('tui-input-date-range') - locator resolved to <tui-input-date-range data-size="l" _nghost-ng-c592222274="" formcontrolname="testValue" tuiunfinishedvalidator="Finish filling the field" class="ng-untouched _focused ng-dirty ng-invalid">…</tui-input-date-range> - 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 - 204 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#base [automation-id="tui-doc-example"]').locator('tui-input-date-range') - locator resolved to <tui-input-date-range data-size="l" _nghost-ng-c592222274="" formcontrolname="testValue" tuiunfinishedvalidator="Finish filling the field" class="ng-untouched _focused ng-dirty ng-invalid">…</tui-input-date-range> - 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 - 204 pixels (ratio 0.01 of all image pixels) are different. 317 | await inputDateRange.textfield.press('Backspace'); 318 | > 319 | await expect(inputDateRange.host).toHaveScreenshot( | ^ 320 | `12-backspace-pressed-${i}-times.png`, 321 | ); 322 | } at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/legacy/input-date-range/input-date-range.pw.spec.ts:319:55

Check failure on line 319 in projects/demo-playwright/tests/legacy/input-date-range/input-date-range.pw.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / ubuntu-latest / 7 of 9

[chromium] › tests/legacy/input-date-range/input-date-range.pw.spec.ts:296:17 › InputDateRange › Examples › with `input[tuiTextfieldLegacy]` inside › filler has no change detection problems

3) [chromium] › tests/legacy/input-date-range/input-date-range.pw.spec.ts:296:17 › InputDateRange › Examples › with `input[tuiTextfieldLegacy]` inside › filler has no change detection problems Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveScreenshot(expected) 204 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/legacy/input-date-range/input-date-range.pw.spec.ts-snapshots/12-backspace-pressed-2-times-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-ra-9043d-o-change-detection-problems-chromium-retry2/12-backspace-pressed-2-times-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-ra-9043d-o-change-detection-problems-chromium-retry2/12-backspace-pressed-2-times-diff.png Call log: - expect.toHaveScreenshot(12-backspace-pressed-2-times.png) with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#base [automation-id="tui-doc-example"]').locator('tui-input-date-range') - locator resolved to <tui-input-date-range data-size="l" _nghost-ng-c592222274="" formcontrolname="testValue" tuiunfinishedvalidator="Finish filling the field" class="ng-untouched _focused ng-dirty ng-invalid">…</tui-input-date-range> - 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 - 204 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#base [automation-id="tui-doc-example"]').locator('tui-input-date-range') - locator resolved to <tui-input-date-range data-size="l" _nghost-ng-c592222274="" formcontrolname="testValue" tuiunfinishedvalidator="Finish filling the field" class="ng-untouched _focused ng-dirty ng-invalid">…</tui-input-date-range> - 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 - 204 pixels (ratio 0.01 of all image pixels) are different. 317 | await inputDateRange.textfield.press('Backspace'); 318 | > 319 | await expect(inputDateRange.host).toHaveScreenshot( | ^ 320 | `12-backspace-pressed-${i}-times.png`, 321 | ); 322 | } at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/legacy/input-date-range/input-date-range.pw.spec.ts:319:55
`12-backspace-pressed-${i}-times.png`,
);
}

await expect(inputDateRange.textfield).toHaveValue('');
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -312,24 +312,17 @@
});

test.describe('Examples', () => {
let example!: Locator;
let documentationPage!: TuiDocumentationPagePO;
let inputDateTime!: TuiInputDateTimePO;

test.beforeEach(async ({page}) => {
await tuiGoto(page, DemoRoute.InputDateTime);

documentationPage = new TuiDocumentationPagePO(page);
example = documentationPage.apiPageExample;

inputDateTime = new TuiInputDateTimePO(
example.locator('tui-input-date-time'),
);
});

test('With validator: enter incomplete date -> validator error', async () => {
example = documentationPage.getExample('#with-validator');
inputDateTime = new TuiInputDateTimePO(
const example = documentationPage.getExample('#with-validator');
const inputDateTime = new TuiInputDateTimePO(
example.locator('tui-input-date-time'),
);

Expand All @@ -343,5 +336,38 @@
{animations: 'allow'},
);
});

test.describe('with `input[tuiTextfieldLegacy]` inside', () => {
test('filler has no change detection problems', async () => {
const example = documentationPage.getExample('#base');
const inputDateTime = new TuiInputDateTimePO(
example.locator('tui-input-date-time'),
);

/**
* To ensure that example is not changed and
* still contains InputDateTime with projected <input tuiTextfieldLegacy>
*/
await expect(
inputDateTime.host.locator('input[tuiTextfieldLegacy]'),
).toBeAttached();

await inputDateTime.textfield.focus();

await expect(inputDateTime.host).toHaveScreenshot(
'05-backspace-pressed-0-times.png',
);

for (let i = 1; i <= 8; i++) {
await inputDateTime.textfield.press('Backspace');

await expect(inputDateTime.host).toHaveScreenshot(

Check failure on line 364 in projects/demo-playwright/tests/legacy/input-date-time/input-date-time.pw.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / ubuntu-latest / 7 of 9

[chromium] › tests/legacy/input-date-time/input-date-time.pw.spec.ts:341:17 › InputDateTime › Examples › with `input[tuiTextfieldLegacy]` inside › filler has no change detection problems

4) [chromium] › tests/legacy/input-date-time/input-date-time.pw.spec.ts:341:17 › InputDateTime › Examples › with `input[tuiTextfieldLegacy]` inside › filler has no change detection problems Error: expect(locator).toHaveScreenshot(expected) 1060 pixels (ratio 0.02 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/legacy/input-date-time/input-date-time.pw.spec.ts-snapshots/05-backspace-pressed-2-times-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-ti-d7c48-o-change-detection-problems-chromium/05-backspace-pressed-2-times-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-ti-d7c48-o-change-detection-problems-chromium/05-backspace-pressed-2-times-diff.png Call log: - expect.toHaveScreenshot(05-backspace-pressed-2-times.png) with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#base [automation-id="tui-doc-example"]').locator('tui-input-date-time') - locator resolved to <tui-input-date-time data-size="l" _nghost-ng-c1833090300="" formcontrolname="testValue" class="ng-untouched ng-valid _focused ng-dirty">…</tui-input-date-time> - 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 - 1060 pixels (ratio 0.02 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#base [automation-id="tui-doc-example"]').locator('tui-input-date-time') - locator resolved to <tui-input-date-time data-size="l" _nghost-ng-c1833090300="" formcontrolname="testValue" class="ng-untouched ng-valid _focused ng-dirty">…</tui-input-date-time> - 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 - 1060 pixels (ratio 0.02 of all image pixels) are different. 362 | await inputDateTime.textfield.press('Backspace'); 363 | > 364 | await expect(inputDateTime.host).toHaveScreenshot( | ^ 365 | `05-backspace-pressed-${i}-times.png`, 366 | ); 367 | } at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/legacy/input-date-time/input-date-time.pw.spec.ts:364:54
`05-backspace-pressed-${i}-times.png`,
);
}

await expect(inputDateTime.textfield).toHaveValue('');
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,25 @@

test.describe('InputDate', () => {
test.describe('Examples', () => {
let documentationPage!: TuiDocumentationPagePO;

test.use({
viewport: {
width: 450,
height: 650,
},
});

test('correct filler display for size', async ({page}) => {
test.beforeEach(async ({page}) => {
await tuiGoto(page, DemoRoute.InputDate);

const api = new TuiDocumentationPagePO(page);
const example = api.getExample('#sizes');
documentationPage = new TuiDocumentationPagePO(page);
});

await api.prepareBeforeScreenshot();
test('correct filler display for size', async ({page}) => {
const example = documentationPage.getExample('#sizes');

await documentationPage.prepareBeforeScreenshot();

for (const size of ['s', 'm', 'l']) {
const input = example
Expand All @@ -39,7 +44,7 @@

await input.clear();

await expect(page).toHaveScreenshot(`01-02-input-date-${size}.png`);

Check failure on line 47 in projects/demo-playwright/tests/legacy/input-date/input-date.pw.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / ubuntu-latest / 7 of 9

[chromium] › tests/legacy/input-date/input-date.pw.spec.ts:30:13 › InputDate › Examples › correct filler display for size

1) [chromium] › tests/legacy/input-date/input-date.pw.spec.ts:30:13 › InputDate › Examples › correct filler display for size Error: expect(page).toHaveScreenshot(expected) 699 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/legacy/input-date/input-date.pw.spec.ts-snapshots/01-02-input-date-m-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-in-b4ee5-ect-filler-display-for-size-chromium/01-02-input-date-m-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-in-b4ee5-ect-filler-display-for-size-chromium/01-02-input-date-m-diff.png Call log: - expect.toHaveScreenshot(01-02-input-date-m.png) with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 699 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 699 pixels (ratio 0.01 of all image pixels) are different. 45 | await input.clear(); 46 | > 47 | await expect(page).toHaveScreenshot(`01-02-input-date-${size}.png`); | ^ 48 | 49 | await input.focus(); 50 | await page.keyboard.type('01.'); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/legacy/input-date/input-date.pw.spec.ts:47:36

Check failure on line 47 in projects/demo-playwright/tests/legacy/input-date/input-date.pw.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / ubuntu-latest / 7 of 9

[chromium] › tests/legacy/input-date/input-date.pw.spec.ts:30:13 › InputDate › Examples › correct filler display for size

1) [chromium] › tests/legacy/input-date/input-date.pw.spec.ts:30:13 › InputDate › Examples › correct filler display for size Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(page).toHaveScreenshot(expected) 699 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/legacy/input-date/input-date.pw.spec.ts-snapshots/01-02-input-date-m-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-in-b4ee5-ect-filler-display-for-size-chromium-retry1/01-02-input-date-m-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-in-b4ee5-ect-filler-display-for-size-chromium-retry1/01-02-input-date-m-diff.png Call log: - expect.toHaveScreenshot(01-02-input-date-m.png) with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 699 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 699 pixels (ratio 0.01 of all image pixels) are different. 45 | await input.clear(); 46 | > 47 | await expect(page).toHaveScreenshot(`01-02-input-date-${size}.png`); | ^ 48 | 49 | await input.focus(); 50 | await page.keyboard.type('01.'); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/legacy/input-date/input-date.pw.spec.ts:47:36

Check failure on line 47 in projects/demo-playwright/tests/legacy/input-date/input-date.pw.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / ubuntu-latest / 7 of 9

[chromium] › tests/legacy/input-date/input-date.pw.spec.ts:30:13 › InputDate › Examples › correct filler display for size

1) [chromium] › tests/legacy/input-date/input-date.pw.spec.ts:30:13 › InputDate › Examples › correct filler display for size Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(page).toHaveScreenshot(expected) 699 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/legacy/input-date/input-date.pw.spec.ts-snapshots/01-02-input-date-m-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-in-b4ee5-ect-filler-display-for-size-chromium-retry2/01-02-input-date-m-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-in-b4ee5-ect-filler-display-for-size-chromium-retry2/01-02-input-date-m-diff.png Call log: - expect.toHaveScreenshot(01-02-input-date-m.png) with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - 699 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 699 pixels (ratio 0.01 of all image pixels) are different. 45 | await input.clear(); 46 | > 47 | await expect(page).toHaveScreenshot(`01-02-input-date-${size}.png`); | ^ 48 | 49 | await input.focus(); 50 | await page.keyboard.type('01.'); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/legacy/input-date/input-date.pw.spec.ts:47:36

await input.focus();
await page.keyboard.type('01.');
Expand All @@ -52,6 +57,37 @@
await expect(page).toHaveScreenshot(`01-04-input-date-${size}.png`);
}
});

test.describe('with `input[tuiTextfieldLegacy]` inside', () => {
test('filler has no change detection problems', async () => {
const example = documentationPage.getExample('#date-localization');
const inputDate = new TuiInputDatePO(example.locator('tui-input-date'));

/**
* To ensure that example is not changed and
* still contains InputDate with projected <input tuiTextfieldLegacy>
*/
await expect(
inputDate.host.locator('input[tuiTextfieldLegacy]'),
).toBeAttached();

await inputDate.textfield.focus();

await expect(inputDate.host).toHaveScreenshot(
'14-backspace-pressed-0-times.png',
);

for (let i = 1; i <= 8; i++) {
await inputDate.textfield.press('Backspace');

await expect(inputDate.host).toHaveScreenshot(

Check failure on line 83 in projects/demo-playwright/tests/legacy/input-date/input-date.pw.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / ubuntu-latest / 7 of 9

[chromium] › tests/legacy/input-date/input-date.pw.spec.ts:62:17 › InputDate › Examples › with `input[tuiTextfieldLegacy]` inside › filler has no change detection problems

2) [chromium] › tests/legacy/input-date/input-date.pw.spec.ts:62:17 › InputDate › Examples › with `input[tuiTextfieldLegacy]` inside › filler has no change detection problems Error: expect(locator).toHaveScreenshot(expected) 286 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/legacy/input-date/input-date.pw.spec.ts-snapshots/14-backspace-pressed-2-times-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-in-680f8-o-change-detection-problems-chromium/14-backspace-pressed-2-times-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-in-680f8-o-change-detection-problems-chromium/14-backspace-pressed-2-times-diff.png Call log: - expect.toHaveScreenshot(14-backspace-pressed-2-times.png) with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#date-localization [automation-id="tui-doc-example"]').locator('tui-input-date') - locator resolved to <tui-input-date data-size="l" _nghost-ng-c2257176783="" class="ng-untouched ng-valid _focused ng-dirty">…</tui-input-date> - 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 - 286 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#date-localization [automation-id="tui-doc-example"]').locator('tui-input-date') - locator resolved to <tui-input-date data-size="l" _nghost-ng-c2257176783="" class="ng-untouched ng-valid _focused ng-dirty">…</tui-input-date> - 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 - 286 pixels (ratio 0.01 of all image pixels) are different. 81 | await inputDate.textfield.press('Backspace'); 82 | > 83 | await expect(inputDate.host).toHaveScreenshot( | ^ 84 | `14-backspace-pressed-${i}-times.png`, 85 | ); 86 | } at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/legacy/input-date/input-date.pw.spec.ts:83:50

Check failure on line 83 in projects/demo-playwright/tests/legacy/input-date/input-date.pw.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / ubuntu-latest / 7 of 9

[chromium] › tests/legacy/input-date/input-date.pw.spec.ts:62:17 › InputDate › Examples › with `input[tuiTextfieldLegacy]` inside › filler has no change detection problems

2) [chromium] › tests/legacy/input-date/input-date.pw.spec.ts:62:17 › InputDate › Examples › with `input[tuiTextfieldLegacy]` inside › filler has no change detection problems Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveScreenshot(expected) 286 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/legacy/input-date/input-date.pw.spec.ts-snapshots/14-backspace-pressed-2-times-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-in-680f8-o-change-detection-problems-chromium-retry1/14-backspace-pressed-2-times-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-in-680f8-o-change-detection-problems-chromium-retry1/14-backspace-pressed-2-times-diff.png Call log: - expect.toHaveScreenshot(14-backspace-pressed-2-times.png) with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#date-localization [automation-id="tui-doc-example"]').locator('tui-input-date') - locator resolved to <tui-input-date data-size="l" _nghost-ng-c2257176783="" class="ng-untouched ng-valid _focused ng-dirty">…</tui-input-date> - 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 - 286 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#date-localization [automation-id="tui-doc-example"]').locator('tui-input-date') - locator resolved to <tui-input-date data-size="l" _nghost-ng-c2257176783="" class="ng-untouched ng-valid _focused ng-dirty">…</tui-input-date> - 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 - 286 pixels (ratio 0.01 of all image pixels) are different. 81 | await inputDate.textfield.press('Backspace'); 82 | > 83 | await expect(inputDate.host).toHaveScreenshot( | ^ 84 | `14-backspace-pressed-${i}-times.png`, 85 | ); 86 | } at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/legacy/input-date/input-date.pw.spec.ts:83:50

Check failure on line 83 in projects/demo-playwright/tests/legacy/input-date/input-date.pw.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright / ubuntu-latest / 7 of 9

[chromium] › tests/legacy/input-date/input-date.pw.spec.ts:62:17 › InputDate › Examples › with `input[tuiTextfieldLegacy]` inside › filler has no change detection problems

2) [chromium] › tests/legacy/input-date/input-date.pw.spec.ts:62:17 › InputDate › Examples › with `input[tuiTextfieldLegacy]` inside › filler has no change detection problems Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveScreenshot(expected) 286 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/legacy/input-date/input-date.pw.spec.ts-snapshots/14-backspace-pressed-2-times-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-in-680f8-o-change-detection-problems-chromium-retry2/14-backspace-pressed-2-times-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-legacy-input-date-in-680f8-o-change-detection-problems-chromium-retry2/14-backspace-pressed-2-times-diff.png Call log: - expect.toHaveScreenshot(14-backspace-pressed-2-times.png) with timeout 5000ms - verifying given screenshot expectation - waiting for locator('#date-localization [automation-id="tui-doc-example"]').locator('tui-input-date') - locator resolved to <tui-input-date data-size="l" _nghost-ng-c2257176783="" class="ng-untouched ng-valid _focused ng-dirty">…</tui-input-date> - 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 - 286 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for locator('#date-localization [automation-id="tui-doc-example"]').locator('tui-input-date') - locator resolved to <tui-input-date data-size="l" _nghost-ng-c2257176783="" class="ng-untouched ng-valid _focused ng-dirty">…</tui-input-date> - 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 - 286 pixels (ratio 0.01 of all image pixels) are different. 81 | await inputDate.textfield.press('Backspace'); 82 | > 83 | await expect(inputDate.host).toHaveScreenshot( | ^ 84 | `14-backspace-pressed-${i}-times.png`, 85 | ); 86 | } at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/legacy/input-date/input-date.pw.spec.ts:83:50
`14-backspace-pressed-${i}-times.png`,
);
}

await expect(inputDate.textfield).toHaveValue('');
});
});
});

test.describe('API', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class TuiInputDateRangePO {
'[automation-id="tui-calendar-range__menu"]',
);

constructor(private readonly host: Locator) {}
constructor(public readonly host: Locator) {}

public async getItems(): Promise<Locator[]> {
const dataList = this.calendar.locator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export class TuiInputDatePO {
public readonly textfield: Locator = this.host.getByRole('textbox');
public readonly calendar: Locator = this.host.page().locator('tui-calendar');

constructor(private readonly host: Locator) {}
constructor(public readonly host: Locator) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Component,
inject,
Input,
signal,
ViewChild,
} from '@angular/core';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
Expand Down Expand Up @@ -86,6 +87,7 @@ export class TuiInputDateRangeComponent
private readonly mobileCalendar = inject(TUI_MOBILE_CALENDAR, {optional: true});
private readonly options = inject(TUI_INPUT_DATE_OPTIONS);
private readonly textfieldSize = inject(TUI_TEXTFIELD_SIZE);
private readonly nativeValue = signal(this.nativeFocusableElement?.value || '');
nsbarsukov marked this conversation as resolved.
Show resolved Hide resolved

protected readonly dateTexts$ = inject(TUI_DATE_TEXTS);
protected override readonly valueTransformer = inject(
Expand Down Expand Up @@ -160,7 +162,7 @@ export class TuiInputDateRangeComponent

return value
? value.getFormattedDayRange(this.dateFormat.mode, this.dateFormat.separator)
: nativeValue;
: nativeValue();
}

public get size(): TuiSizeL | TuiSizeS {
Expand All @@ -174,6 +176,8 @@ export class TuiInputDateRangeComponent
}

public onValueChange(value: string): void {
this.nativeValue.set(value);

if (this.control) {
this.control.updateValueAndValidity({emitEvent: false});
}
Expand All @@ -183,7 +187,7 @@ export class TuiInputDateRangeComponent
}

if (this.activePeriod) {
this.nativeValue = '';
this.nativeValue.set('');
}

this.value =
Expand All @@ -201,15 +205,15 @@ export class TuiInputDateRangeComponent
this.focusInput();

if (!range) {
this.nativeValue = '';
this.nativeValue.set('');
}

this.value = range;
}

public override writeValue(value: TuiDayRange | null): void {
super.writeValue(value);
this.nativeValue = value ? this.computedValue : '';
this.nativeValue.set(value ? this.computedValue : '');
}

protected get computedMobile(): boolean {
Expand Down Expand Up @@ -269,16 +273,6 @@ export class TuiInputDateRangeComponent
return null;
}

protected get nativeValue(): string {
return this.nativeFocusableElement?.value || '';
}

protected set nativeValue(value: string) {
if (this.nativeFocusableElement) {
this.nativeFocusableElement.value = value;
}
}

protected getComputedRangeFiller(dateFiller: string): string {
return this.activePeriod ? '' : this.getDateRangeFiller(dateFiller);
}
Expand All @@ -299,12 +293,12 @@ export class TuiInputDateRangeComponent
if (
!focused &&
!this.itemSelected &&
(this.nativeValue.length === DATE_FILLER_LENGTH ||
this.nativeValue.length ===
(this.nativeValue().length === DATE_FILLER_LENGTH ||
this.nativeValue().length ===
DATE_FILLER_LENGTH + RANGE_SEPARATOR_CHAR.length)
) {
this.value = TuiDayRange.normalizeParse(
this.nativeValue,
this.nativeValue(),
this.dateFormat.mode,
);
}
Expand All @@ -318,7 +312,7 @@ export class TuiInputDateRangeComponent
}

private get itemSelected(): boolean {
return this.items.findIndex((item) => String(item) === this.nativeValue) !== -1;
return this.items.findIndex((item) => String(item) === this.nativeValue()) !== -1;
}

@tuiPure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,17 @@ describe('InputDateRangeComponent', () => {
});

it('correctly sets stringify selected range via calendar', async () => {
inputPO.sendTextAndBlur('12/01/2021-02/14/2022');
inputPO.sendText('12/01/2021-02/14/2022');
/**
* TODO
* Uncomment me to see [TypeError: Cannot read properties of undefined (reading 'addEventListener')]
* ___
* Stacktrace says that error happens inside `TUI_ACTIVE_ELEMENT`.
* Utility `tuiGetDocumentOrShadowRoot` returns `undefined`.
*/
// inputPO.blur();

await fixture.whenStable();

clickOnTextfield();

Expand Down Expand Up @@ -541,17 +551,19 @@ describe('InputDateRangeComponent', () => {
expect(inputPO.value).toBe('12.09.2021 – 18.10.2021');
});

it('transforms value which was programmatically patched', () => {
testComponent.control.patchValue([
new Date(1922, 11, 30),
new Date(1991, 11, 26),
]);
it('transforms value which was programmatically patched', async () => {
const newDateRange = [new Date(1922, 11, 30), new Date(1991, 11, 26)] as [
Date,
Date,
];

testComponent.control.patchValue(newDateRange);

fixture.detectChanges();
await fixture.whenStable();

expect(inputPO.value).toBe('30.12.1922 – 26.12.1991');
expect(testComponent.control.value).toEqual([
new Date(1922, 11, 30),
new Date(1991, 11, 26),
]);
expect(testComponent.control.value).toEqual(newDateRange);
});
});

Expand Down
Loading
Loading