From 641947d719d4162e90c189f990700bbe898b37dc Mon Sep 17 00:00:00 2001 From: Afolabi Olaoluwa Date: Sat, 9 Sep 2023 01:55:55 +0100 Subject: [PATCH 1/3] fix: Enhance test stability in drive_tests.js In the drive_tests.js file, I improved test stability by introducing steps in two test cases: "test drive to external link" and "test drive enabled by default; click link inside data-turbo='false'." The added calls ensure that the respective elements (e.g., "#drive_enabled_external" and "#drive_disabled") are present and visible before interacting with them, reducing the chances of element unavailability issues during test execution. This resolves test failures where elements were not immediately accessible, leading to test timeouts. --- src/tests/functional/drive_tests.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/tests/functional/drive_tests.js b/src/tests/functional/drive_tests.js index 56491bdb0..cfb798f72 100644 --- a/src/tests/functional/drive_tests.js +++ b/src/tests/functional/drive_tests.js @@ -9,7 +9,8 @@ test.beforeEach(async ({ page }) => { }) test("test drive enabled by default; click normal link", async ({ page }) => { - page.click("#drive_enabled") + await page.waitForSelector("#drive_enabled") + await page.click("#drive_enabled") await nextBody(page) assert.equal(pathname(page.url()), path) }) @@ -19,7 +20,7 @@ test("test drive to external link", async ({ page }) => { await route.fulfill({ body: "Hello from the outside world" }) }) - page.click("#drive_enabled_external") + await page.click("#drive_enabled_external") await nextBody(page) assert.equal(await page.evaluate(() => window.location.href), "https://example.com/") @@ -27,8 +28,9 @@ test("test drive to external link", async ({ page }) => { }) test("test drive enabled by default; click link inside data-turbo='false'", async ({ page }) => { - page.click("#drive_disabled") - await nextBody(page) + await page.waitForSelector("#drive_disabled") + await page.click("#drive_disabled") + assert.equal(pathname(page.url()), path) assert.equal(await visitAction(page), "load") }) From d731d1c5fbb52e17609291431c3d5d8faaf6971b Mon Sep 17 00:00:00 2001 From: Afolabi Olaoluwa Date: Mon, 11 Sep 2023 11:32:12 +0100 Subject: [PATCH 2/3] Revert 'await page.click(#drive_disabled)' to 'nextBody' for explicit navigation wait This commit reverts one of the changes made in commit 641947d719d4162e90c189f990700bbe898b37dc where I replaced 'nextBody' with 'await page.click(#drive_disabled)'. The reason for this reversion is to stick to explicit waiting for page navigation to ensure that the page has fully transitioned to its new state before making assertions. The 'nextBody' function is used to achieve this waiting behavior, ensuring the reliability of our tests in certain scenarios. --- src/tests/functional/drive_tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/functional/drive_tests.js b/src/tests/functional/drive_tests.js index cfb798f72..096f17334 100644 --- a/src/tests/functional/drive_tests.js +++ b/src/tests/functional/drive_tests.js @@ -29,7 +29,7 @@ test("test drive to external link", async ({ page }) => { test("test drive enabled by default; click link inside data-turbo='false'", async ({ page }) => { await page.waitForSelector("#drive_disabled") - await page.click("#drive_disabled") + await nextBody(page) assert.equal(pathname(page.url()), path) assert.equal(await visitAction(page), "load") From 17c214c772a310d08e4408f6ca08c38609950810 Mon Sep 17 00:00:00 2001 From: Afolabi Olaoluwa Date: Wed, 13 Sep 2023 18:25:20 +0100 Subject: [PATCH 3/3] refactor: Removed unnecessary page.waitForSelector from the PR 'https://github.com/hotwired/turbo/commit/641947d719d4162e90c189f990700bbe898b37dc' --- src/tests/functional/drive_tests.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tests/functional/drive_tests.js b/src/tests/functional/drive_tests.js index 096f17334..35ee012ef 100644 --- a/src/tests/functional/drive_tests.js +++ b/src/tests/functional/drive_tests.js @@ -9,7 +9,6 @@ test.beforeEach(async ({ page }) => { }) test("test drive enabled by default; click normal link", async ({ page }) => { - await page.waitForSelector("#drive_enabled") await page.click("#drive_enabled") await nextBody(page) assert.equal(pathname(page.url()), path) @@ -28,7 +27,7 @@ test("test drive to external link", async ({ page }) => { }) test("test drive enabled by default; click link inside data-turbo='false'", async ({ page }) => { - await page.waitForSelector("#drive_disabled") + await page.click("#drive_disabled") await nextBody(page) assert.equal(pathname(page.url()), path)