Skip to content

Commit 4e602e8

Browse files
authored
test: stabilize tests using setFocus (#7295)
**Related Issue:** N/A ## Summary Adds more `page.waitForChanges()` after `setFocus` calls. This is needed after #7277.
1 parent 20cd09a commit 4e602e8

File tree

12 files changed

+126
-1
lines changed

12 files changed

+126
-1
lines changed

packages/calcite-components/src/components/color-picker-hex-input/color-picker-hex-input.e2e.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ describe("calcite-color-picker-hex-input", () => {
407407
await input.setProperty("value", noColorValue);
408408
await page.waitForChanges();
409409
await input.callMethod("setFocus");
410+
await page.waitForChanges();
410411

411412
await page.keyboard.press("ArrowUp");
412413
await page.waitForChanges();
@@ -525,6 +526,7 @@ describe("calcite-color-picker-hex-input", () => {
525526
await input.setProperty("value", noColorValue);
526527
await page.waitForChanges();
527528
await input.callMethod("setFocus");
529+
await page.waitForChanges();
528530

529531
await page.keyboard.press("ArrowUp");
530532
await page.waitForChanges();

packages/calcite-components/src/components/color-picker/color-picker.e2e.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ describe("calcite-color-picker", () => {
281281
value: string
282282
): Promise<void> => {
283283
await channelInputOrHexInput.callMethod("setFocus");
284+
await page.waitForChanges();
284285
await selectText(channelInputOrHexInput);
285286
await channelInputOrHexInput.press("Backspace");
286287
await channelInputOrHexInput.type(value);
@@ -1051,6 +1052,7 @@ describe("calcite-color-picker", () => {
10511052

10521053
const assertChannelValueNudge = async (page: E2EPage, calciteInput: E2EElement): Promise<void> => {
10531054
await calciteInput.callMethod("setFocus");
1055+
await page.waitForChanges();
10541056
const currentValue = await calciteInput.getProperty("value");
10551057

10561058
await page.keyboard.press("ArrowUp");
@@ -1140,7 +1142,6 @@ describe("calcite-color-picker", () => {
11401142
});
11411143

11421144
const assertChannelValueNudge = async (page: E2EPage, calciteInput: E2EElement): Promise<void> => {
1143-
await calciteInput.callMethod("setFocus");
11441145
await clearAndEnterHexOrChannelValue(page, calciteInput, "");
11451146

11461147
// using page.waitForChanges as keyboard nudges occur in the next frame
@@ -1598,6 +1599,7 @@ describe("calcite-color-picker", () => {
15981599

15991600
const assertChannelValueNudge = async (page: E2EPage, calciteInputOrSlider: E2EElement): Promise<void> => {
16001601
await calciteInputOrSlider.callMethod("setFocus");
1602+
await page.waitForChanges();
16011603
const currentValue = await calciteInputOrSlider.getProperty("value");
16021604

16031605
function ensureValueType(value: string | number): number | string {
@@ -1717,6 +1719,7 @@ describe("calcite-color-picker", () => {
17171719
}
17181720

17191721
await calciteInputOrSlider.callMethod("setFocus");
1722+
await page.waitForChanges();
17201723
await clearValue();
17211724

17221725
// using page.waitForChanges as keyboard nudges occur in the next frame

packages/calcite-components/src/components/combobox/combobox.e2e.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ describe("calcite-combobox", () => {
783783
}
784784
} else {
785785
await combobox.callMethod("setFocus");
786+
await page.waitForChanges();
786787
await page.keyboard.press("Escape");
787788
}
788789

packages/calcite-components/src/components/dropdown-item/dropdown-item.e2e.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ describe("calcite-dropdown-item", () => {
3131

3232
calciteDropdownItemSelectEvent = page.waitForEvent("calciteDropdownItemSelect");
3333
await element.callMethod("setFocus");
34+
await page.waitForChanges();
3435
await page.keyboard.press("Enter");
3536
await calciteDropdownItemSelectEvent;
3637

3738
expect(itemChangeSpy).toHaveReceivedEventTimes(2);
3839

3940
calciteDropdownItemSelectEvent = page.waitForEvent("calciteDropdownItemSelect");
4041
await element.callMethod("setFocus");
42+
await page.waitForChanges();
4143
await page.keyboard.press("Space");
4244
await calciteDropdownItemSelectEvent;
4345

packages/calcite-components/src/components/dropdown/dropdown.e2e.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ describe("calcite-dropdown", () => {
754754
expect(calciteDropdownClose).toHaveReceivedEventTimes(0);
755755

756756
await element.callMethod("setFocus");
757+
await page.waitForChanges();
757758
await page.keyboard.press("Space");
758759
await page.waitForChanges();
759760
expect(await dropdownWrapper.isVisible()).toBe(false);
@@ -799,6 +800,7 @@ describe("calcite-dropdown", () => {
799800
expect(calciteDropdownClose).toHaveReceivedEventTimes(0);
800801

801802
await element.callMethod("setFocus");
803+
await page.waitForChanges();
802804
await page.keyboard.press("Space");
803805
await page.waitForChanges();
804806
expect(await dropdownWrapper.isVisible()).toBe(false);

packages/calcite-components/src/components/filter/filter.e2e.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ describe("calcite-filter", () => {
9393
it("should clear the value in the input when pressed", async () => {
9494
const filter = await page.find("calcite-filter");
9595
await filter.callMethod("setFocus");
96+
await page.waitForChanges();
9697

9798
await page.keyboard.type("developer");
9899
await page.waitForChanges();
@@ -118,6 +119,7 @@ describe("calcite-filter", () => {
118119
it("should clear the value in the input when the Escape key is pressed", async () => {
119120
const filter = await page.find("calcite-filter");
120121
await filter.callMethod("setFocus");
122+
await page.waitForChanges();
121123

122124
await page.keyboard.type("developer");
123125
await page.waitForChanges();
@@ -203,6 +205,7 @@ describe("calcite-filter", () => {
203205

204206
const filterChangeEvent = page.waitForEvent("calciteFilterChange");
205207
await filter.callMethod("setFocus");
208+
await page.waitForChanges();
206209
await filter.type("developer");
207210
await filterChangeEvent;
208211

@@ -224,6 +227,7 @@ describe("calcite-filter", () => {
224227
const filter = await page.find("calcite-filter");
225228

226229
await filter.callMethod("setFocus");
230+
await page.waitForChanges();
227231
await filter.type("volt");
228232
await waitForEvent;
229233

@@ -235,6 +239,7 @@ describe("calcite-filter", () => {
235239
const filter = await page.find("calcite-filter");
236240

237241
await filter.callMethod("setFocus");
242+
await page.waitForChanges();
238243
await filter.type("regex()");
239244
await waitForEvent;
240245

0 commit comments

Comments
 (0)