From ba9759f44ffa162c3d4769329fd5f6bdbc90c6a3 Mon Sep 17 00:00:00 2001 From: rays Date: Sun, 11 Oct 2026 12:58:26 +0000 Subject: [PATCH] Gesture tests send a drag's touches at once, not one by one (#184) Each touch event was awaited before the next went, so on a busy machine a drag's ten messages took longer than the 800 ms a swipe has, and the page took it for a slow drag. Reproduced by spacing the messages 110 ms apart: the swipe back stayed on Second Episode, as the failing run did. The page is right to want a swipe quick; a finger does it in well under that. Co-Authored-By: Claude Opus 5.5 --- tests/ui/app.spec.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/ui/app.spec.js b/tests/ui/app.spec.js index c8e5f52..9cb905a 100644 --- a/tests/ui/app.spec.js +++ b/tests/ui/app.spec.js @@ -1429,15 +1429,17 @@ test('a failing feed is marked on its artwork and says why', async ({ page }) => test.describe('touch gestures on a phone', () => { test.use({ viewport: { width: 390, height: 844 }, hasTouch: true, isMobile: true }); - // Playwright's touchscreen only taps; a drag goes through the DevTools protocol. + // Playwright's touchscreen only taps; a drag goes through the DevTools protocol. Sent all at + // once, in order: awaited one by one, a busy machine stretched a drag past the 800 ms a swipe + // has, and it was taken for a slow drag and went nowhere (#184). async function drag(page, from, to, lift = true) { const cdp = await page.context().newCDPSession(page); - const steps = 8; - await cdp.send('Input.dispatchTouchEvent', { type: 'touchStart', touchPoints: [from] }); + const steps = 8, touch = (type, touchPoints) => cdp.send('Input.dispatchTouchEvent', { type, touchPoints }); + const sent = [touch('touchStart', [from])]; for (let i = 1; i <= steps; i++) - await cdp.send('Input.dispatchTouchEvent', { type: 'touchMove', touchPoints: [{ - x: from.x + (to.x - from.x) * i / steps, y: from.y + (to.y - from.y) * i / steps }] }); - if (lift) await cdp.send('Input.dispatchTouchEvent', { type: 'touchEnd', touchPoints: [] }); + sent.push(touch('touchMove', [{ x: from.x + (to.x - from.x) * i / steps, y: from.y + (to.y - from.y) * i / steps }])); + if (lift) sent.push(touch('touchEnd', [])); + await Promise.all(sent); return cdp; }