Skip to content

Commit

Permalink
Resolve flaky navigation test
Browse files Browse the repository at this point in the history
```
1) [firefox] › navigation_tests.ts:161:1 › test following a same-origin unannotated link inside a data-turbo=false container

    page.click: Target closed
    =========================== logs ===========================
    waiting for selector "#same-origin-unannotated-link-inside-false-container"
      selector resolved to visible <a href="/src/tests/fixtures/one.html" id="same-ori…>Same-origin unannotated link inside data-turbo=fa…</a>
    attempting click action
      waiting for element to be visible, enabled and stable
      element is visible, enabled and stable
      scrolling into view if needed
    ============================================================

      160 |
      161 | test("test following a same-origin unannotated link inside a data-turbo=false container", async ({ page }) => {
    > 162 |   page.click("#same-origin-unannotated-link-inside-false-container")
          |        ^
      163 |   await nextBody(page)
      164 |   assert.equal(pathname(page.url()), "/src/tests/fixtures/one.html")
      165 |   assert.equal(await visitAction(page), "load")

        at /home/runner/work/turbo/turbo/src/tests/functional/navigation_tests.ts:162:8
```

When driving tests that navigate `[data-turbo="false"]` anchors, replace
the bespoke `await nextBody(page)` helper with Playwright's built-in and
more predictable [Page.waitForEvent("load")][], since the entire
document will navigate.

[Page.waitForEvent("load")]: https://playwright.dev/docs/api/class-page#page-wait-for-event
  • Loading branch information
seanpdoyle committed Aug 17, 2022
1 parent 4a86bbe commit f40de69
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/tests/functional/navigation_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ test("test following a POST form clears cache", async ({ page }) => {
})

test("test following a same-origin data-turbo=false link", async ({ page }) => {
page.click("#same-origin-false-link")
await nextBody(page)
await page.click("#same-origin-false-link")
await page.waitForEvent("load")
assert.equal(pathname(page.url()), "/src/tests/fixtures/one.html")
assert.equal(await visitAction(page), "load")
})

test("test following a same-origin unannotated link inside a data-turbo=false container", async ({ page }) => {
page.click("#same-origin-unannotated-link-inside-false-container")
await nextBody(page)
await page.click("#same-origin-unannotated-link-inside-false-container")
await page.waitForEvent("load")
assert.equal(pathname(page.url()), "/src/tests/fixtures/one.html")
assert.equal(await visitAction(page), "load")
})
Expand Down

0 comments on commit f40de69

Please sign in to comment.