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; }