Unverified Commit a777ebcf authored by Janka Uryga's avatar Janka Uryga Committed by GitHub

test: retry waiting for ISR fallback in prefetch-static-shell (#98884)

- ISR prerenders can take a moment to propagate in `deploy`, longer than
in `start`, so do a retry loop that waits for the fallback to go away
before running tests that need it
- ISR fallbacks are only upgraded when using adapters, skip the tests
that care about those if using legacy deploy bc they'll fail otherwise
parent 389f164d
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import type * as Playwright from 'playwright' import type * as Playwright from 'playwright'
import { createRouterAct } from 'router-act' import { createRouterAct } from 'router-act'
import { retry } from '../../../../lib/next-test-utils'
const REPRODUCE_UNNECESSARY_RUNTIME_SHELL = const REPRODUCE_UNNECESSARY_RUNTIME_SHELL =
!!process.env.REPRODUCE_UNNECESSARY_RUNTIME_SHELL || false !!process.env.REPRODUCE_UNNECESSARY_RUNTIME_SHELL || false
...@@ -58,16 +59,12 @@ const REPRODUCE_UNNECESSARY_RUNTIME_PREFETCH = ...@@ -58,16 +59,12 @@ const REPRODUCE_UNNECESSARY_RUNTIME_PREFETCH =
// piece of content arrived: 'static' matches per-segment static prefetch // piece of content arrived: 'static' matches per-segment static prefetch
// requests (including the route tree prefetch), 'runtime' matches dynamic // requests (including the route tree prefetch), 'runtime' matches dynamic
// prefetch requests (e.g. the runtime shell request). // prefetch requests (e.g. the runtime shell request).
// @force-gate prefetching
describe('static App Shell prefetch attempt', () => { describe('static App Shell prefetch attempt', () => {
const { next, isNextDev } = nextTestSetup({ const { next } = nextTestSetup({
files: __dirname, files: __dirname,
}) })
if (isNextDev) {
// The feature depends on build-time prerenders and ISR regeneration
// semantics that don't exist in dev.
it('is skipped', () => {})
return
}
it('prefetches a fully static route with static requests only, then navigates instantly from cache', async () => { it('prefetches a fully static route with static requests only, then navigates instantly from cache', async () => {
let page: Playwright.Page let page: Playwright.Page
...@@ -1744,9 +1741,12 @@ describe('static App Shell prefetch attempt', () => { ...@@ -1744,9 +1741,12 @@ describe('static App Shell prefetch attempt', () => {
}) })
}) })
// The legacy Vercel builder does not implement the Cache Components shell
// eligibility and upgrade behavior asserted here.
// @force-gate !deploy || adapter
describe('when a link to a non-prerendered param is revealed first', () => { describe('when a link to a non-prerendered param is revealed first', () => {
beforeAll(async () => { beforeAll(async () => {
// Trigger an ISR prerender for the new param value // Trigger an ISR prerender for the new param value.
await next.fetch( await next.fetch(
'/maybe-runtime-prefetch/yes-cookies-in-prefetch-not-prerendered' '/maybe-runtime-prefetch/yes-cookies-in-prefetch-not-prerendered'
) )
...@@ -1759,22 +1759,40 @@ describe('static App Shell prefetch attempt', () => { ...@@ -1759,22 +1759,40 @@ describe('static App Shell prefetch attempt', () => {
}) })
const act = createRouterAct(page, { includeAppShellRequests: true }) const act = createRouterAct(page, { includeAppShellRequests: true })
// The client router should get the result of the ISR prerender, not the fallback. // Wait until the client router gets the result of the ISR prerender instead of the fallback.
await act(async () => { let attemptCount = 0
await browser await retry(
.elementByCss( async () => {
linkAccordionSelector({ // Force a new prefetch by refreshing --
href: '/maybe-runtime-prefetch/yes-cookies-in-prefetch-not-prerendered', // the client's ISR retry loop is hard to assert on with `act()`.
prefetch: 'auto', if (attemptCount > 0) {
}) await browser.refresh()
) }
.click()
}, [ try {
{ await act(async () => {
includes: 'Slug: yes-cookies-in-prefetch-not-prerendered', await browser
kind: 'static', .elementByCss(
linkAccordionSelector({
href: '/maybe-runtime-prefetch/yes-cookies-in-prefetch-not-prerendered',
prefetch: 'auto',
})
)
.click()
}, [
{
includes: 'Slug: yes-cookies-in-prefetch-not-prerendered',
kind: 'static',
},
])
} finally {
attemptCount++
}
}, },
]) 10_000,
1_000,
'wait for ISR prerender to finish'
)
}) })
it('attempts a static prefetch before falling back to a runtime prefetch', async () => { it('attempts a static prefetch before falling back to a runtime prefetch', async () => {
......
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