Skip to content

Commit

Permalink
feat(core/date-picker-refactor): fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiashader committed Oct 12, 2023
1 parent 086f708 commit 40bd126
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ test.describe('date picker tests single', () => {
});

test('date is selected', async ({ page }) => {
await page.waitForSelector('ix-date-time-card');

expect(await getDateObj(page)).toEqual({
from: '2023/09/05',
to: undefined,
});
});

test('select different date', async ({ page }) => {
await page.waitForSelector('ix-date-time-card');
await page.getByText(/^19$/).click();

expect(await getDateObj(page)).toEqual({
Expand All @@ -46,6 +49,8 @@ test.describe('date picker tests single', () => {
});

test('select different date in next month', async ({ page }) => {
await page.waitForSelector('ix-date-time-card');

await page.getByRole('button').filter({ hasText: 'chevron-right' }).click();
await page.getByText(/^31$/).click();

Expand All @@ -56,6 +61,8 @@ test.describe('date picker tests single', () => {
});

test('select different date in previous month', async ({ page }) => {
await page.waitForSelector('ix-date-time-card');

await page.getByRole('button').filter({ hasText: 'chevron-left' }).click();
await page.getByText(/^31$/).nth(1).click();

Expand All @@ -66,6 +73,8 @@ test.describe('date picker tests single', () => {
});

test('select different date from specific month', async ({ page }) => {
await page.waitForSelector('ix-date-time-card');

await page
.locator('ix-button')
.filter({ hasText: /^September 2023$/ })
Expand All @@ -90,6 +99,8 @@ test.describe('date picker tests single', () => {
});

test('select different date fires dateChange event', async ({ page }) => {
await page.waitForSelector('ix-date-time-card');

const eventPromise = page.evaluate(() => {
return new Promise((f) => {
document.addEventListener('dateChange', (data) => f(data));
Expand All @@ -110,13 +121,17 @@ test.describe('date picker tests range', () => {
});

test('range is selected', async ({ page }) => {
await page.waitForSelector('ix-date-time-card');

expect(await getDateObj(page)).toEqual({
from: '2023/09/05',
to: '2023/09/10',
});
});

test('select different range', async ({ page }) => {
await page.waitForSelector('ix-date-time-card');

await page.getByText(/^12$/).click();
await page.getByText(/^17$/).click();

Expand All @@ -127,6 +142,8 @@ test.describe('date picker tests range', () => {
});

test('select range spanning over 2 months', async ({ page }) => {
await page.waitForSelector('ix-date-time-card');

await page.getByText(/^28$/).click();
await page.getByRole('button').filter({ hasText: 'chevron-right' }).click();
await page.getByText(/^5$/).click();
Expand All @@ -140,6 +157,8 @@ test.describe('date picker tests range', () => {
test('select different range fires dateChange and dateRangeChange event', async ({
page,
}) => {
await page.waitForSelector('ix-date-time-card');

const dateChangeEventPromise = page.evaluate(() => {
return new Promise((f) => {
document.addEventListener('dateChange', (data) => f(data));
Expand All @@ -159,6 +178,8 @@ test.describe('date picker tests range', () => {
});

test('done click fires dateSelect event', async ({ page }) => {
await page.waitForSelector('ix-date-time-card');

const dateSelectEventPromise = page.evaluate(() => {
return new Promise((f) => {
document.addEventListener('dateSelect', (data) => f(data));
Expand Down

0 comments on commit 40bd126

Please sign in to comment.