From 3da1643bbd0e31fb15050e2d388d57fa23d0f3c1 Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Mon, 1 Aug 2022 13:06:57 -0400 Subject: [PATCH] Resolve flaky double-clicking link test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switch the test from a time-based waiting mechanism (1200 milliseconds) to an event-based waiting mechanism. ``` 2) [firefox] › navigation_tests.ts:341:1 › test double-clicking on a link ======================== AssertionError: expected '/src/tests/fixtures/navigation.html' to equal '/__turbo/delayed_response' 344 | 345 | await nextBody(page, 1200) > 346 | assert.equal(pathname(page.url()), "/__turbo/delayed_response") | ^ 347 | assert.equal(await visitAction(page), "advance") 348 | }) 349 | at /home/runner/work/turbo/turbo/src/tests/functional/navigation_tests.ts:346:10 ``` --- src/tests/functional/navigation_tests.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tests/functional/navigation_tests.ts b/src/tests/functional/navigation_tests.ts index afaf54221..eab540d34 100644 --- a/src/tests/functional/navigation_tests.ts +++ b/src/tests/functional/navigation_tests.ts @@ -339,10 +339,11 @@ test("test correct referrer header", async ({ page }) => { }) test("test double-clicking on a link", async ({ page }) => { - page.click("#delayed-link") - page.click("#delayed-link") + await page.click("#delayed-link", { clickCount: 2 }) + + await nextEventNamed(page, "turbo:load") + await nextEventNamed(page, "turbo:load") - await nextBody(page, 1200) assert.equal(pathname(page.url()), "/__turbo/delayed_response") assert.equal(await visitAction(page), "advance") })