Skip to content

Commit

Permalink
fix: Enhance test stability in drive_tests.js
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AfolabiOlaoluwa authored and shiftyp committed Sep 10, 2023
1 parent 1f3416f commit 93aa412
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/tests/functional/drive_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand All @@ -19,16 +20,17 @@ 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/")
assert.equal(await page.textContent("body"), "Hello from the outside world")
})

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")
})

0 comments on commit 93aa412

Please sign in to comment.