Skip to content

Commit

Permalink
feat(kit): test for input-date-range with preventing of selection for…
Browse files Browse the repository at this point in the history
… disabled days
  • Loading branch information
p-ivannikov committed Aug 4, 2024
1 parent 2c144d0 commit 39f3609
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,39 @@ test.describe('InputDateRange', () => {
'07-item-and-calendar-interactions.png',
);
});

test('Prevent selection of range with disabled days', async ({page}) => {
const calendar = new TuiCalendarPO(
inputDateRange.calendarRange.locator('tui-calendar'),
);

const getCellState = async (cell: Locator): Promise<string | null> =>
cell.getAttribute('data-state');

const getDaysState = async (): Promise<Array<string | null>> =>
Promise.all((await calendar.getDays()).map(getCellState));

await tuiGoto(page, 'components/input-date-range/API?disabledItemHandler$=1');

await inputDateRange.textfield.click();

// check disabled items length before day selection
expect(
(await getDaysState()).filter(state => state === 'disabled'),
).toHaveLength(20);

await calendar.clickOnCalendarDay(7);

// check range which includes disabled days
// range should have only 2 enabled items
expect(
(await getDaysState()).filter(state => state !== 'disabled'),
).toHaveLength(2);

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

View workflow job for this annotation

GitHub Actions / playwright / (3 of 4)

[chromium] › tests/kit/input-date-range/input-date-range.spec.ts:164:13 › InputDateRange › API › Prevent selection of range with disabled days

1) [chromium] › tests/kit/input-date-range/input-date-range.spec.ts:164:13 › InputDateRange › API › Prevent selection of range with disabled days Error: expect(received).toHaveLength(expected) Expected length: 2 Received length: 41 Received array: [null, null, null, null, "hover", null, null, null, null, null, …] 188 | expect( 189 | (await getDaysState()).filter(state => state !== 'disabled'), > 190 | ).toHaveLength(2); | ^ 191 | 192 | await expect(example).toHaveScreenshot( 193 | '09-prevent-disabled-days-selection.png', at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-date-range/input-date-range.spec.ts:190:15

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

View workflow job for this annotation

GitHub Actions / playwright / (3 of 4)

[chromium] › tests/kit/input-date-range/input-date-range.spec.ts:164:13 › InputDateRange › API › Prevent selection of range with disabled days

1) [chromium] › tests/kit/input-date-range/input-date-range.spec.ts:164:13 › InputDateRange › API › Prevent selection of range with disabled days Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toHaveLength(expected) Expected length: 2 Received length: 41 Received array: [null, null, null, null, "hover", null, null, null, null, null, …] 188 | expect( 189 | (await getDaysState()).filter(state => state !== 'disabled'), > 190 | ).toHaveLength(2); | ^ 191 | 192 | await expect(example).toHaveScreenshot( 193 | '09-prevent-disabled-days-selection.png', at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/input-date-range/input-date-range.spec.ts:190:15

await expect(example).toHaveScreenshot(
'09-prevent-disabled-days-selection.png',
);
});
});

test.describe('Examples', () => {
Expand Down

0 comments on commit 39f3609

Please sign in to comment.