Skip to content

Commit 055eb8f

Browse files
rosaclaude
andcommitted
Fix some flaky tests that were failing in recent runs
- Fix flaky frame test by using targeted event check: change `noNextEventNamed` to `noNextEventOnTarget` for the frame form navigation test. The previous check would pick up unrelated `turbo:before-fetch-request` events from link prefetching on other elements, causing random test failures. - Fix rendering test that was failing due to execution context being destroyed during full page reload. Use `waitForURL` instead of `nextEventNamed` since the tracked element mismatch causes a real browser reload. - Fix `pausable_requests` test race condition by using a single dialog handler that collects all messages, rather than registering handlers sequentially which could miss dialogs on Firefox. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e5cbd84 commit 055eb8f

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/tests/functional/frame_tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ test("navigating a frame with a form[method=get] that does not redirect still up
740740
await nextEventOnTarget(page, "frame", "turbo:frame-render")
741741
await nextEventOnTarget(page, "frame", "turbo:frame-load")
742742

743-
expect(await noNextEventNamed(page, "turbo:before-fetch-request")).toBeTruthy()
743+
expect(await noNextEventOnTarget(page, "frame", "turbo:before-fetch-request")).toBeTruthy()
744744

745745
const src = (await attributeForSelector(page, "#frame", "src")) ?? ""
746746

src/tests/functional/pausable_requests_tests.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,22 @@ test("pauses and resumes request", async ({ page }) => {
1717
})
1818

1919
test("aborts request", async ({ page }) => {
20-
page.once("dialog", (dialog) => {
21-
expect(dialog.message()).toEqual("Continue request?")
22-
dialog.dismiss()
20+
const dialogMessages = []
21+
22+
page.on("dialog", async (dialog) => {
23+
dialogMessages.push(dialog.message())
24+
if (dialog.message() === "Continue request?") {
25+
await dialog.dismiss()
26+
} else {
27+
await dialog.accept()
28+
}
2329
})
2430

2531
await page.click("#link")
2632
await nextBeat()
27-
28-
page.once("dialog", (dialog) => {
29-
expect(dialog.message()).toEqual("Request aborted")
30-
dialog.accept()
31-
})
32-
3333
await nextBeat()
3434

35+
expect(dialogMessages).toContain("Continue request?")
36+
expect(dialogMessages).toContain("Request aborted")
3537
await expect(page.locator("h1")).toHaveText("Pausable Requests")
3638
})

src/tests/functional/rendering_tests.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,9 @@ test("reloads when tracked elements change", async ({ page }) => {
5757
)
5858

5959
await page.click("#tracked-asset-change-link")
60-
await nextEventNamed(page, "turbo:load")
60+
await page.waitForURL("**/tracked_asset_change.html")
6161

6262
const reason = await page.evaluate(() => localStorage.getItem("reloadReason"))
63-
64-
await expect(page).toHaveURL(withPathname("/src/tests/fixtures/tracked_asset_change.html"))
6563
expect(await visitAction(page)).toEqual("load")
6664
expect(reason).toEqual("tracked_element_mismatch")
6765
})

0 commit comments

Comments
 (0)