Skip to content

Commit a2c6f52

Browse files
committed
web: Fix flakiness of mouse_wheel_avm2
wdio was randomly causing the browser to fire pointerenter and pointerleave events, which resulted in the test being flaky. When pointerleave event was sent before moving the mouse, there was no hovered object and scroll was not dispatched to the object it should have been. This patch uses wdio's .moveTo() to update the hover before dispatching scroll event which fixes this issue.
1 parent c174fff commit a2c6f52

File tree

1 file changed

+6
-9
lines changed
  • web/packages/selfhosted/test/integration_tests/mouse_wheel_avm2

1 file changed

+6
-9
lines changed

web/packages/selfhosted/test/integration_tests/mouse_wheel_avm2/test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ async function scroll(
1919
lines: number,
2020
) {
2121
const canvas = await player.shadow$("canvas");
22+
const canvasSize = await canvas.getSize();
23+
24+
const xOffset = x - canvasSize.width / 2;
25+
const yOffset = y - canvasSize.height / 2;
26+
await canvas.moveTo({ xOffset, yOffset });
2227

2328
return await browser.execute(
24-
(element, x, y, lines) => {
29+
(element, lines) => {
2530
const el = element as unknown as HTMLElement;
26-
el.dispatchEvent(
27-
new PointerEvent("pointermove", {
28-
clientX: x as unknown as number,
29-
clientY: y as unknown as number,
30-
}),
31-
);
3231
return el.dispatchEvent(
3332
new WheelEvent("wheel", {
3433
deltaY: lines as unknown as number,
@@ -38,8 +37,6 @@ async function scroll(
3837
);
3938
},
4039
canvas,
41-
x,
42-
y,
4340
lines,
4441
);
4542
}

0 commit comments

Comments
 (0)