rsnext/test/e2e/app-dir
Andrew Clark f9b85387fb
loading.tsx should have no effect on partial rendering when PPR is enabled (#59196)
Before PPR, the way instant navigations work in Next.js is we prefetch
everything up to the first route segment that defines a loading.js
boundary. The rest of the tree is defered until the actual navigation.
It does not take into account whether the data is dynamic — even if the
tree is completely static, it will still defer everything inside the
loading boundary.

The approach with PPR is different — we prefetch as deeply as possible,
and only defer when dynamic data is accessed. If so, we only defer the
nearest parent Suspense boundary of the dynamic data access, regardless
of whether the boundary is defined by loading.js or a normal <Suspense>
component in userspace.

This PR removes the partial behavior of loading.js when the PPR flag is
enabled. In effect, loading.js now acts like a regular Suspense boundary
with no additional special behavior.

Note that in practice this usually means we'll end up prefetching more
than we were before PPR, which may or may not be considered a
performance regression by some apps. The plan is to address this before
General Availability of PPR by introducing granular per-segment
fetching, so we can reuse as much of the tree as possible during both
prefetches and dynamic navigations. But during the beta period, we
should be clear about this trade off in our communications.

## Testing strategy

While I was writing a test, I noticed that it's currently pretty
difficult to test all the scenarios that PPR is designed to handle, so I
gave special attention to setting up a testing strategy that I hope will
make this easier going forward. The overall pattern is based on how
we've been testing concurrent rendering features in the React repo for
many years:

- In the e2e test, spin up an HTTP server for responding to requests
sent by the test app. This simulates the data service that would be used
in a real Next.js application, whether it's direct db access, an ORM, or
a higher-level data access layer. The e2e test can observe when
individual requests are received, and control the timing of when the
data is fulfilled, without needing to mock any lower level I/O. (We're
already using a similar pattern to [test fetch
deduping](a3616d33ed/test/e2e/app-dir/app-fetch-deduping/app-fetch-deduping.test.ts (L8-L29)).)
- Each time a request is received, write to an event log. Then assert on
the result of the log at different points throughout the test. This
helps catch subtle mistakes where the order of events is not expected,
or the same event happens more than it should.

(I wrote some test helpers, but to avoid early abstraction, I've
intentionally not moved them into a separate module.)

Closes NEXT-1779
2023-12-08 18:41:01 -05:00
..
_allow-underscored-root-directory Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
actions fix server actions behavior on intercepted routes (#59175) 2023-12-01 14:45:00 -08:00
actions-allowed-origins Change allowed forwarded hosts to be allowed origins for Server Actions (#58023) 2023-11-08 11:20:32 +01:00
actions-navigation Remove the experimental serverActions flag (#57145) 2023-10-20 20:45:25 +00:00
app loading.tsx should have no effect on partial rendering when PPR is enabled (#59196) 2023-12-08 18:41:01 -05:00
app-a11y Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
app-alias Update default moduleResolution in tsconfig.json from node to bundler (#51957) 2023-07-18 15:11:09 +00:00
app-basepath test: merge base path tests (#55069) 2023-09-06 17:20:47 +00:00
app-client-cache app-router: tweak prefetch cache status heuristics (#53864) 2023-08-20 11:25:48 +00:00
app-compilation Fix HMR for missing dependencies in next-app-loader (#51778) 2023-06-25 19:26:09 +00:00
app-config-crossorigin fix(#53190): add missing crossOrigin to assetsPrefix resources (#56311) 2023-10-02 17:21:49 +00:00
app-css Turbopack: switch to a single client components entrypoint (#59352) 2023-12-08 08:24:08 +01:00
app-css-pageextensions Use consistent name for App Router tests (#56352) 2023-10-06 11:06:06 +02:00
app-edge fix: next dev with edge runtime on windows (#56502) 2023-10-10 14:03:03 +00:00
app-edge-root-layout Fix static metadata routes runtime when root layout is in edge runtime (#50351) 2023-05-25 15:39:57 -07:00
app-external Fix server output bundling packages module resolving (#59369) 2023-12-07 18:11:11 +01:00
app-fetch-deduping dedupe pending revalidation requests (#58990) 2023-11-28 14:38:59 +00:00
app-middleware Use consistent name for App Router tests (#56352) 2023-10-06 11:06:06 +02:00
app-prefetch remove additional static prefetch code (#59313) 2023-12-05 21:29:23 -08:00
app-prefetch-false type check tests (and convert next-test-utils.js to ts) (#51071) 2023-06-23 17:42:50 +00:00
app-prefetch-false-loading remove optimistic navigation behavior when prefetch is false (#58413) 2023-11-16 11:58:17 +01:00
app-prefetch-static Reland static prefetches & fix prefetch bailout behavior (#56228) 2023-10-02 17:12:55 +00:00
app-rendering Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
app-routes route handlers: make req.cookies opt you into dynamic (#58769) 2023-11-22 14:29:01 +00:00
app-routes-trailing-slash Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
app-simple-routes Turbopack: add edge app routes (#53387) 2023-08-07 13:00:06 +02:00
app-static remove additional static prefetch code (#59313) 2023-12-05 21:29:23 -08:00
app-validation Use consistent name for App Router tests (#56352) 2023-10-06 11:06:06 +02:00
asset-prefix Add new build and test workflow (#50436) 2023-05-27 21:02:31 -07:00
async-component-preload Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
autoscroll-with-css-modules Skip Babel tests for Turbopack (#56091) 2023-09-27 16:12:43 +02:00
back-button-download-bug chore(next/image)!: mark domains as deprecated in favor remotePatterns (#57062) 2023-10-19 20:24:48 +00:00
build-size Improve performance of String.prototype.split uses (#56746) 2023-10-19 00:25:15 +00:00
chunk-loading App Router - preinitialize chunks during SSR (#54752) 2023-10-03 21:40:25 +00:00
create-next-app-template Update default moduleResolution in tsconfig.json from node to bundler (#51957) 2023-07-18 15:11:09 +00:00
create-root-layout Polish auto create layout warning color (#57190) 2023-10-21 19:21:22 +00:00
crypto-globally-available Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
draft-mode Allow next/headers in middleware & draftMode in edge runtime (#53465) 2023-08-02 20:22:35 +00:00
dynamic Remove client only dynamic chunks from edge bundle (#56761) 2023-11-16 15:10:28 +00:00
dynamic-href Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
edge-route-catchall fix edge route catch-all param parsing (#59343) 2023-12-06 12:21:28 -08:00
edge-route-rewrite fix rewrites to edge routes (#58797) 2023-11-23 05:25:00 +00:00
edge-runtime-node-compatibility Update default moduleResolution in tsconfig.json from node to bundler (#51957) 2023-07-18 15:11:09 +00:00
emotion-js Fix emotion-js transform for server components (#54284) 2023-08-20 03:14:16 +00:00
error-boundary-navigation Fix root not-found page tree loader structure (#54080) 2023-08-16 15:10:08 +00:00
externals Turbopack + app router: always use externals for predefined packages (#56440) 2023-10-06 19:08:01 +00:00
front-redirect-issue Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
global-error Fix next internal is missing in flight manifest (#59085) 2023-11-30 16:36:14 +01:00
headers-static-bailout Add docs page for uncaught DynamicServerErrors (#53402) 2023-08-08 12:49:53 +02:00
hello-world Bail out of 404 page when favicon.ico doesn't exist (#50795) 2023-06-06 10:58:40 +02:00
hooks Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
i18n-hybrid Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
import Use consistent name for App Router tests (#56352) 2023-10-06 11:06:06 +02:00
interception-dynamic-segment fix interception routes with dynamic segments (#59273) 2023-12-05 08:47:40 -08:00
interception-middleware-rewrite fix behavior when revisiting an intercepted route (#59168) 2023-12-01 08:54:01 -08:00
interoperability-with-pages improve error DX on pages with RSC build errors (#52843) 2023-07-20 00:32:57 +00:00
layout-params Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
logging fixes the logging by showing full URLs only on demand (#58088) 2023-12-07 20:54:34 +01:00
mdx Fix client reference proxies (#57301) 2023-10-24 00:24:22 +00:00
metadata Support generating multi-meta tahs for metadata api other prop (#59106) 2023-11-30 16:44:49 +01:00
metadata-dynamic-routes Polish logging segments of page route (#57834) 2023-11-01 16:34:52 +00:00
metadata-edge Move ImageResponse to next/og (#56662) 2023-10-19 14:26:48 +00:00
metadata-missing-metadata-base Polish unsupported metadata warning with doc link (#58750) 2023-11-23 05:42:20 +00:00
metadata-suspense Remove throw for unknown messages in hot-reloader-client (#57353) 2023-11-03 01:06:53 +00:00
mjs-as-extension Enable .mjs extension config in Turbopack (#58825) 2023-11-23 14:17:36 +00:00
modularizeimports Fix bugs with baseUrl and mdxRs (#58968) 2023-11-28 10:50:14 +01:00
navigation fix inconsistent scroll restoration behavior (#59366) 2023-12-07 11:17:15 -08:00
next-config Avoid loading Next.js config again in render workers (#52587) 2023-07-12 11:21:05 +00:00
next-font Add app router name to font tests (#59257) 2023-12-04 20:25:41 +01:00
next-image test(next-image): adjust assertion compatible to turbopack (#57350) 2023-10-24 22:25:57 +00:00
not-found Ensure unique name for app dir css tests (#56088) 2023-09-27 18:38:01 +02:00
not-found-default Fix group routes custom root not-found (#54931) 2023-09-03 20:15:24 +00:00
pages-to-app-routing Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
parallel-routes-and-interception Fix: expected "catch all routes" are not matched in “parallel routes" (#58368) 2023-11-13 23:26:45 +01:00
parallel-routes-not-found Recover not found errors from flight data to render with proper boundary (#53703) 2023-08-12 08:41:47 +00:00
params-hooks-compat Make useSearchParams and useParams compatible between app and pages router (#55280) 2023-09-18 12:42:20 +00:00
ppr add full PPR e2e tests (#59025) 2023-11-29 11:34:01 -08:00
ppr-errors Disable more Turbopack build tests (#59245) 2023-12-04 14:23:32 +00:00
ppr-full add full PPR e2e tests (#59025) 2023-11-29 11:34:01 -08:00
ppr-navigations loading.tsx should have no effect on partial rendering when PPR is enabled (#59196) 2023-12-08 18:41:01 -05:00
revalidate-dynamic revalidate APIs should make route handlers dynamic (#58466) 2023-11-16 11:57:55 +01:00
rewrites-redirects Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
root-layout Ensure root layout only render once per request (#52589) 2023-07-13 17:34:31 +02:00
root-layout-redirect Update default moduleResolution in tsconfig.json from node to bundler (#51957) 2023-07-18 15:11:09 +00:00
root-layout-render-once Ensure root layout only render once per request (#52589) 2023-07-13 17:34:31 +02:00
route-page-manifest-bug Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
router-autoscroll Fix scroll bailout logic when targeting fixed/sticky elements (#53873) 2023-08-15 13:31:39 +00:00
router-stuck-dynamic-static-segment Update default moduleResolution in tsconfig.json from node to bundler (#51957) 2023-07-18 15:11:09 +00:00
rsc-basic Enable PPR tests for test suites (#59030) 2023-11-29 03:22:45 +00:00
search-params-react-key Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
searchparams-static-bailout Update default moduleResolution in tsconfig.json from node to bundler (#51957) 2023-07-18 15:11:09 +00:00
server-actions-relative-redirect Remove the experimental serverActions flag (#57145) 2023-10-20 20:45:25 +00:00
set-cookies Fix mjs import for Turbopack test (#56354) 2023-10-03 13:33:04 +02:00
shallow-routing Ensure original history is read in effect (#58861) 2023-12-03 09:18:34 +01:00
similar-pages-paths Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
taint Expose Experimental Taint APIs (#56507) 2023-10-19 19:02:37 -07:00
test-template/{{ toFileName name }} Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
third-parties Fix mixed module swc compilation for app router (#58967) 2023-12-01 15:23:43 +01:00
trailingslash Add new build and test workflow (#50436) 2023-05-27 21:02:31 -07:00
underscore-ignore-app-paths Update default moduleResolution in tsconfig.json from node to bundler (#51957) 2023-07-18 15:11:09 +00:00
use-params Make useSearchParams and useParams compatible between app and pages router (#55280) 2023-09-18 12:42:20 +00:00
use-selected-layout-segment-s chore: upgrade jest (#56909) 2023-10-19 17:38:24 +00:00
with-babel Update tests for Turbopack (#59354) 2023-12-07 15:03:44 +01:00
with-exported-function-config chore: upgrade jest (#56909) 2023-10-19 17:38:24 +00:00
x-forwarded-headers fix: set x-forwarded-host based on request (#58500) 2023-11-16 12:00:41 +01:00