Skip to content

Commit 50d806e

Browse files
authored
test(all): add await to relevant assertions (#25527)
1 parent d65e5a7 commit 50d806e

File tree

33 files changed

+131
-142
lines changed

33 files changed

+131
-142
lines changed

core/src/components/datetime/test/basic/datetime.e2e.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test.describe('datetime: closing time popover', () => {
2727
await ionPopoverDidDismiss.next();
2828
await page.waitForChanges();
2929

30-
expect(calendarMonthYear).toHaveText(currentMonthAndYear);
30+
await expect(calendarMonthYear).toHaveText(currentMonthAndYear);
3131
});
3232
});
3333

@@ -41,13 +41,13 @@ test.describe('datetime: selecting a day', () => {
4141
`#${datetimeID} .calendar-day[data-day='${today.getDate()}'][data-month='${today.getMonth() + 1}']`
4242
);
4343

44-
expect(todayBtn).toHaveClass(/calendar-day-today/);
45-
expect(todayBtn).not.toHaveClass(/calendar-day-active/);
44+
await expect(todayBtn).toHaveClass(/calendar-day-today/);
45+
await expect(todayBtn).not.toHaveClass(/calendar-day-active/);
4646

4747
await todayBtn.click();
4848
await page.waitForChanges();
4949

50-
expect(todayBtn).toHaveClass(/calendar-day-active/);
50+
await expect(todayBtn).toHaveClass(/calendar-day-active/);
5151
};
5252

5353
test('should not highlight a day until one is selected', async ({ page }) => {
@@ -64,13 +64,13 @@ test.describe('datetime: selecting a day', () => {
6464

6565
const activeDay = page.locator('ion-datetime .calendar-day-active');
6666

67-
expect(activeDay).toHaveText('25');
67+
await expect(activeDay).toHaveText('25');
6868

6969
const dayBtn = page.locator('ion-datetime .calendar-day[data-day="13"][data-month="12"]');
7070
await dayBtn.click();
7171
await page.waitForChanges();
7272

73-
expect(activeDay).toHaveText('13');
73+
await expect(activeDay).toHaveText('13');
7474
});
7575
});
7676

@@ -125,10 +125,10 @@ test.describe('datetime: footer', () => {
125125
await page.setContent('<ion-datetime value="2022-05-03" show-default-buttons="true"></ion-datetime>');
126126

127127
const cancelButton = page.locator('ion-datetime #cancel-button');
128-
expect(cancelButton).toHaveText('Cancel');
128+
await expect(cancelButton).toHaveText('Cancel');
129129

130130
const confirmButton = page.locator('ion-datetime #confirm-button');
131-
expect(confirmButton).toHaveText('Done');
131+
await expect(confirmButton).toHaveText('Done');
132132

133133
const datetime = page.locator('ion-datetime');
134134
expect(await datetime.screenshot()).toMatchSnapshot(
@@ -139,7 +139,7 @@ test.describe('datetime: footer', () => {
139139
await page.setContent('<ion-datetime value="2022-05-03" show-clear-button="true"></ion-datetime>');
140140

141141
const clearButton = page.locator('ion-datetime #clear-button');
142-
expect(clearButton).toHaveText('Clear');
142+
await expect(clearButton).toHaveText('Clear');
143143

144144
const datetime = page.locator('ion-datetime');
145145
expect(await datetime.screenshot()).toMatchSnapshot(
@@ -152,13 +152,13 @@ test.describe('datetime: footer', () => {
152152
);
153153

154154
const cancelButton = page.locator('ion-datetime #cancel-button');
155-
expect(cancelButton).toHaveText('Cancel');
155+
await expect(cancelButton).toHaveText('Cancel');
156156

157157
const confirmButton = page.locator('ion-datetime #confirm-button');
158-
expect(confirmButton).toHaveText('Done');
158+
await expect(confirmButton).toHaveText('Done');
159159

160160
const clearButton = page.locator('ion-datetime #clear-button');
161-
expect(clearButton).toHaveText('Clear');
161+
await expect(clearButton).toHaveText('Clear');
162162

163163
const datetime = page.locator('ion-datetime');
164164
expect(await datetime.screenshot()).toMatchSnapshot(
@@ -175,7 +175,7 @@ test.describe('datetime: footer', () => {
175175
`);
176176

177177
const customButton = page.locator('ion-datetime #custom-button');
178-
expect(customButton).toBeVisible();
178+
await expect(customButton).toBeVisible();
179179

180180
const datetime = page.locator('ion-datetime');
181181
expect(await datetime.screenshot()).toMatchSnapshot(

core/src/components/datetime/test/disable-dates/datetime.e2e.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,21 @@ test.describe('datetime: disable dates', () => {
122122
test('should disable a specific date', async ({ page }) => {
123123
const disabledDay = queryAllDisabledDays(page, '#specificDate');
124124

125-
expect(disabledDay).toHaveText('10');
125+
await expect(disabledDay).toHaveText('10');
126126
});
127127

128128
test('should disable specific days of the week', async ({ page }) => {
129129
const disabledDays = queryAllWorkingMonthDisabledDays(page, '#weekends');
130130

131131
expect(await disabledDays.count()).toEqual(10);
132-
expect(disabledDays).toHaveText(['2', '3', '9', '10', '16', '17', '23', '24', '30', '31']);
132+
await expect(disabledDays).toHaveText(['2', '3', '9', '10', '16', '17', '23', '24', '30', '31']);
133133
});
134134

135135
test('should disable a range of dates', async ({ page }) => {
136136
const disabledDays = queryAllDisabledDays(page, '#dateRange');
137137

138138
expect(await disabledDays.count()).toEqual(11);
139-
expect(disabledDays).toHaveText(['10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20']);
139+
await expect(disabledDays).toHaveText(['10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20']);
140140
});
141141

142142
test('should disable a month', async ({ page }) => {

core/src/components/datetime/test/display/datetime.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ test.describe('datetime: display', () => {
106106

107107
const calendarMonthYear = page.locator('ion-datetime .calendar-month-year');
108108

109-
expect(calendarMonthYear).toHaveText('March 2022');
109+
await expect(calendarMonthYear).toHaveText('March 2022');
110110

111111
// ensure it still works if presentation is changed more than once
112112
await select.selectOption('date-time');
@@ -118,7 +118,7 @@ test.describe('datetime: display', () => {
118118

119119
await ionWorkingPartsDidChange.next();
120120

121-
expect(calendarMonthYear).toHaveText('February 2022');
121+
await expect(calendarMonthYear).toHaveText('February 2022');
122122
});
123123
});
124124
});

core/src/components/datetime/test/hour-cycle/datetime.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ test.describe('datetime: hour cycle', () => {
88
`);
99

1010
const timeButton = page.locator('ion-datetime .time-body');
11-
expect(timeButton).toHaveText('16:30');
11+
await expect(timeButton).toHaveText('16:30');
1212
});
1313
test('should set the h12 hour cycle correctly', async ({ page }) => {
1414
await page.setContent(`
1515
<ion-datetime hour-cycle="h12" value="2022-01-01T16:30:00"></ion-datetime>
1616
`);
1717

1818
const timeButton = page.locator('ion-datetime .time-body');
19-
expect(timeButton).toHaveText('4:30 PM');
19+
await expect(timeButton).toHaveText('4:30 PM');
2020
});
2121
});

core/src/components/datetime/test/minmax/datetime.e2e.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ test.describe('datetime: minmax', () => {
3333
const prevButton = page.locator('ion-datetime .calendar-next-prev ion-button:nth-child(1)');
3434
const nextButton = page.locator('ion-datetime .calendar-next-prev ion-button:nth-child(2)');
3535

36-
expect(nextButton).toBeEnabled();
37-
expect(prevButton).toBeDisabled();
36+
await expect(nextButton).toBeEnabled();
37+
await expect(prevButton).toBeDisabled();
3838

3939
await page.evaluate('initDatetimeChangeEvent()');
4040

@@ -45,8 +45,8 @@ test.describe('datetime: minmax', () => {
4545

4646
await monthDidChangeSpy.next();
4747

48-
expect(nextButton).toBeDisabled();
49-
expect(prevButton).toBeEnabled();
48+
await expect(nextButton).toBeDisabled();
49+
await expect(prevButton).toBeEnabled();
5050
});
5151

5252
test('datetime: minmax months disabled', async ({ page }) => {
@@ -55,9 +55,9 @@ test.describe('datetime: minmax', () => {
5555

5656
await page.waitForSelector('.datetime-ready');
5757

58-
expect(calendarMonths.nth(0)).not.toHaveClass(/calendar-month-disabled/);
59-
expect(calendarMonths.nth(1)).not.toHaveClass(/calendar-month-disabled/);
60-
expect(calendarMonths.nth(2)).toHaveClass(/calendar-month-disabled/);
58+
await expect(calendarMonths.nth(0)).not.toHaveClass(/calendar-month-disabled/);
59+
await expect(calendarMonths.nth(1)).not.toHaveClass(/calendar-month-disabled/);
60+
await expect(calendarMonths.nth(2)).toHaveClass(/calendar-month-disabled/);
6161
});
6262

6363
test('datetime: minmax navigation disabled', async ({ page }) => {
@@ -66,8 +66,8 @@ test.describe('datetime: minmax', () => {
6666

6767
const navButtons = page.locator('ion-datetime#outside .calendar-next-prev ion-button');
6868

69-
expect(navButtons.nth(0)).toHaveAttribute('disabled', '');
70-
expect(navButtons.nth(1)).toHaveAttribute('disabled', '');
69+
await expect(navButtons.nth(0)).toHaveAttribute('disabled', '');
70+
await expect(navButtons.nth(1)).toHaveAttribute('disabled', '');
7171
});
7272

7373
test('datetime: min including day should not disable month', async ({ page }) => {
@@ -76,9 +76,9 @@ test.describe('datetime: minmax', () => {
7676

7777
const calendarMonths = page.locator('ion-datetime#min-with-day .calendar-month');
7878

79-
expect(calendarMonths.nth(0)).toHaveClass(/calendar-month-disabled/);
80-
expect(calendarMonths.nth(1)).not.toHaveClass(/calendar-month-disabled/);
81-
expect(calendarMonths.nth(2)).not.toHaveClass(/calendar-month-disabled/);
79+
await expect(calendarMonths.nth(0)).toHaveClass(/calendar-month-disabled/);
80+
await expect(calendarMonths.nth(1)).not.toHaveClass(/calendar-month-disabled/);
81+
await expect(calendarMonths.nth(2)).not.toHaveClass(/calendar-month-disabled/);
8282
});
8383

8484
test.describe('when the datetime does not have a value', () => {
@@ -116,7 +116,7 @@ test.describe('datetime: minmax', () => {
116116
await page.waitForSelector('.datetime-ready');
117117

118118
const calendarMonthYear = page.locator('ion-datetime .calendar-month-year');
119-
expect(calendarMonthYear).toHaveText('June 2021');
119+
await expect(calendarMonthYear).toHaveText('June 2021');
120120
};
121121

122122
test('when min is defined', async ({ page }) => {

core/src/components/datetime/test/month-year-picker/datetime.e2e.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ test.describe('datetime: month-year picker', () => {
99

1010
test('should hide the footer when picker is open', async ({ page }) => {
1111
const datetimeFooter = page.locator('#date-time .datetime-footer');
12-
expect(datetimeFooter).toBeVisible();
12+
await expect(datetimeFooter).toBeVisible();
1313

1414
const pickerButton = page.locator('#date-time .calendar-month-year > ion-item');
1515
await pickerButton.click();
1616
await page.waitForChanges();
17-
expect(datetimeFooter).not.toBeVisible();
17+
await expect(datetimeFooter).not.toBeVisible();
1818
});
1919

2020
test('should not hide the footer on month-year presentation', async ({ page }) => {
2121
const monthyearFooter = page.locator('#month-year .datetime-footer');
22-
expect(monthyearFooter).toBeVisible();
22+
await expect(monthyearFooter).toBeVisible();
2323
});
2424
});

core/src/components/datetime/test/set-value/datetime.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test.describe('datetime: set-value', () => {
1313
await page.waitForChanges();
1414

1515
const activeDate = page.locator('ion-datetime .calendar-day-active');
16-
expect(activeDate).toHaveText('25');
16+
await expect(activeDate).toHaveText('25');
1717
});
1818
test('should update the active time', async ({ page }) => {
1919
const datetime = page.locator('ion-datetime');
@@ -22,6 +22,6 @@ test.describe('datetime: set-value', () => {
2222
await page.waitForChanges();
2323

2424
const activeDate = page.locator('ion-datetime .time-body');
25-
expect(activeDate).toHaveText('12:40 PM');
25+
await expect(activeDate).toHaveText('12:40 PM');
2626
});
2727
});

core/src/components/datetime/test/sub-pixel-width/datetime.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test.describe('datetime: sub-pixel width', () => {
2121
await datetimeMonthDidChange.next();
2222

2323
const monthYear = page.locator('ion-datetime .calendar-month-year');
24-
expect(monthYear).toHaveText('March 2022');
24+
await expect(monthYear).toHaveText('March 2022');
2525
});
2626

2727
test('should update the month when prev button is clicked', async ({ page }) => {
@@ -40,6 +40,6 @@ test.describe('datetime: sub-pixel width', () => {
4040
await datetimeMonthDidChange.next();
4141

4242
const monthYear = page.locator('ion-datetime .calendar-month-year');
43-
expect(monthYear).toHaveText('January 2022');
43+
await expect(monthYear).toHaveText('January 2022');
4444
});
4545
});

core/src/components/datetime/test/time-label/datetime.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test.describe('datetime: time label', () => {
99
await page.waitForSelector('.datetime-ready');
1010

1111
const timeLabel = page.locator('ion-datetime .time-header');
12-
expect(timeLabel).toHaveText('Time');
12+
await expect(timeLabel).toHaveText('Time');
1313
});
1414
test('should not render a custom time label', async ({ page }) => {
1515
await page.setContent(`
@@ -18,6 +18,6 @@ test.describe('datetime: time label', () => {
1818
await page.waitForSelector('.datetime-ready');
1919

2020
const timeLabel = page.locator('ion-datetime .time-header');
21-
expect(timeLabel).toHaveText('');
21+
await expect(timeLabel).toHaveText('');
2222
});
2323
});

core/src/components/datetime/test/values/datetime.e2e.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,38 @@ test.describe('datetime: values', () => {
1515
* so this ensures that dayValues is applying to all
1616
* rendered months, not just the initial month.
1717
*/
18-
expect(items).toHaveText(['1', '2', '3', '1', '2', '3', '1', '2', '3']);
18+
await expect(items).toHaveText(['1', '2', '3', '1', '2', '3', '1', '2', '3']);
1919
});
2020
test('should render correct months', async ({ page }) => {
2121
await page.setContent(`
2222
<ion-datetime locale="en-US" presentation="month-year" month-values="5,6,10"></ion-datetime>
2323
`);
2424

2525
const items = page.locator('.month-column .picker-item:not(.picker-item-empty)');
26-
expect(items).toHaveText(['May', 'June', 'October']);
26+
await expect(items).toHaveText(['May', 'June', 'October']);
2727
});
2828
test('should render correct years', async ({ page }) => {
2929
await page.setContent(`
3030
<ion-datetime locale="en-US" presentation="month-year" year-values="2022,2021,2020"></ion-datetime>
3131
`);
3232

3333
const items = page.locator('.year-column .picker-item:not(.picker-item-empty)');
34-
expect(items).toHaveText(['2022', '2021', '2020']);
34+
await expect(items).toHaveText(['2022', '2021', '2020']);
3535
});
3636
test('should render correct hours', async ({ page }) => {
3737
await page.setContent(`
3838
<ion-datetime locale="en-US" presentation="time" hour-values="1,2,3"></ion-datetime>
3939
`);
4040

4141
const items = page.locator('ion-picker-column-internal:first-of-type .picker-item:not(.picker-item-empty)');
42-
expect(items).toHaveText(['1', '2', '3']);
42+
await expect(items).toHaveText(['1', '2', '3']);
4343
});
4444
test('should render correct minutes', async ({ page }) => {
4545
await page.setContent(`
4646
<ion-datetime locale="en-US" presentation="time" minute-values="1,2,3"></ion-datetime>
4747
`);
4848

4949
const items = page.locator('ion-picker-column-internal:nth-of-type(2) .picker-item:not(.picker-item-empty)');
50-
expect(items).toHaveText(['01', '02', '03']);
50+
await expect(items).toHaveText(['01', '02', '03']);
5151
});
5252
});

0 commit comments

Comments
 (0)