Files
next.js/test/e2e/app-dir/ppr-root-param-fallback/ppr-root-param-fallback.test.ts
Zack TannerandGitHub c986bcccf1 fix: preserve cache behavior for PPR fallback shells with root params (#88556)
When generating PPR fallback shells, a cache miss during warmup was
being treated as a dynamic hole, so the warmup render never filled new
cache entries. This caused root‑param fallback shells (e.g.
`/en/blog/[slug]`) to suspend even though root params were already
known.

This change always creates a fresh prerender RDC for warmup and copies
any seed hits into it. The final render then uses the warmed cache, so
fallback shells can reuse populated entries without short‑circuiting. On
the export side, we now choose a seed RDC by matching known params (e.g.
locale) so /en/... fallback shells don’t get seeded with /fr/... data.
(Previously, the RDC seed was "last-write-wins".

Fixes NAR-716
2026-01-21 08:45:07 -08:00

31 lines
1.2 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
describe('ppr-root-param-fallback', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should have use-cache content in fallback shells for all pregenerated locales', async () => {
// Setup: The app has a [locale] param with generateStaticParams returning
// ['en', 'fr'], and a nested /[locale]/blog/[slug] route. The layout uses
// a 'use cache' function to fetch locale-specific translations.
//
// This test ensures that we generate fallback shells with the correct locale
// filled in for all pregenerated locales.
for (const locale of ['en', 'fr']) {
// next.render$ doesn't stream, so we get just the shell content
const $ = await next.render$(`/${locale}/blog/new-post`)
// The shell should have the locale-header with cached content,
// NOT the locale-loading Suspense fallback
expect($('#locale-header').length).toBe(1)
expect($('#locale-header').text()).toContain(`Locale: ${locale}`)
expect($('#translations').text()).toContain(`Home (${locale})`)
// The Suspense fallback should NOT be in the shell
expect($('#locale-loading').length).toBe(0)
}
})
})