From 08cd8a45e1873f6b22d97bfb6d794565ef6fb96e Mon Sep 17 00:00:00 2001 From: mdlufy Date: Thu, 31 Oct 2024 11:05:41 +0300 Subject: [PATCH] chore(demo-playwright): `InputDate` add tests --- .../tests/kit/input-date/input-date.spec.ts | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/projects/demo-playwright/tests/kit/input-date/input-date.spec.ts b/projects/demo-playwright/tests/kit/input-date/input-date.spec.ts index 3bd7fc4403d9..72a3f1f68c25 100644 --- a/projects/demo-playwright/tests/kit/input-date/input-date.spec.ts +++ b/projects/demo-playwright/tests/kit/input-date/input-date.spec.ts @@ -43,7 +43,9 @@ test.describe('InputDate', () => { await expect(inputDate.textfield).toHaveScreenshot('01-input-date.png'); }); - test('Click `Until today`', async ({page}) => { + test('Click `Until today`, calendar not switched to large date', async ({ + page, + }) => { await tuiGoto(page, 'components/input-date/API?items$=1'); await inputDate.textfield.click(); @@ -51,9 +53,39 @@ test.describe('InputDate', () => { await inputDate.textfield.click(); + await expect(inputDate.textfield).toHaveValue('Until today'); await expect(inputDate.calendar).toHaveScreenshot( '02-input-date-calendar.png', ); }); + + test('Press backspace to remove `Until today`, textfield is empty', async ({ + page, + }) => { + await tuiGoto(page, 'components/input-date/API?items$=1'); + + await inputDate.textfield.click(); + await calendar.itemButton.click(); + + await inputDate.textfield.focus(); + await inputDate.textfield.press('Backspace'); + + await expect(inputDate.textfield).toHaveValue(''); + await expect(inputDate.textfield).toHaveScreenshot( + '03-input-date-textfield-empty.png', + ); + }); + + test('Enter item date, it converts to item date name', async ({page}) => { + await tuiGoto(page, 'components/input-date/API?items$=1'); + + await inputDate.textfield.focus(); + await inputDate.textfield.fill('31.12.9998'); + + await expect(inputDate.textfield).toHaveValue('Until today'); + await expect(inputDate.textfield).toHaveScreenshot( + '04-input-date-item-name.png', + ); + }); }); });