Commit 10d8b6a8 authored by Matt Mastracci's avatar Matt Mastracci

Fix flaky prefetch-runtime test by waiting for elements

The "includes root params, but not dynamic content" test was timing out
due to race conditions. Added explicit waits for link elements to be
visible after each checkbox click and after browser.back(), ensuring
the UI is ready before proceeding to the next interaction.

Waits added:
- After first act(): Wait for "en" link to confirm prefetch completed
- After second act(): Wait for "de" link to confirm prefetch completed
- After browser.back(): Wait for "de" link before navigation
parent c7d45bb5
......@@ -172,6 +172,13 @@ describe('runtime prefetching', () => {
},
])
// Wait for the "en" link to be visible (confirms the checkbox click revealed it
// and the prefetch was triggered). This also ensures we don't proceed until the
// UI is ready for the next interaction.
await browser.elementByCss(
`a[href="/with-root-param/en/${prefix}/root-params"]`
)
// TODO(runtime-ppr) - visiting root params that weren't in generateStaticParams errors when deployed
if (!isNextDeploy) {
// Reveal the link to trigger a runtime prefetch for a different value of the root param
......@@ -191,6 +198,11 @@ describe('runtime prefetching', () => {
block: 'reject',
},
])
// Wait for the "de" link to be visible before navigating
await browser.elementByCss(
`a[href="/with-root-param/de/${prefix}/root-params"]`
)
}
// Navigate to the first page
......@@ -226,6 +238,11 @@ describe('runtime prefetching', () => {
if (!isNextDeploy) {
await browser.back()
// Wait for the link to the "de" page to be visible before clicking it
await browser.elementByCss(
`a[href="/with-root-param/de/${prefix}/root-params"]`
)
// Navigate to the other page
await act(async () => {
await act(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment