File tree Expand file tree Collapse file tree 7 files changed +82
-0
lines changed
test/e2e/app-dir/segment-cache/no-prefetch Expand file tree Collapse file tree 7 files changed +82
-0
lines changed Original file line number Diff line number Diff line change
1
+ export default function RootLayout ( { children } : LayoutProps < '/' > ) {
2
+ return (
3
+ < html >
4
+ < head > </ head >
5
+ < body > { children } </ body >
6
+ </ html >
7
+ )
8
+ }
Original file line number Diff line number Diff line change
1
+ import Link from 'next/link'
2
+
3
+ export default function Page ( ) {
4
+ return (
5
+ < main >
6
+ < h1 > Home</ h1 >
7
+ < Link href = "/with-loading" prefetch = { false } >
8
+ Go to /with-loading (no prefetch)
9
+ </ Link >
10
+ </ main >
11
+ )
12
+ }
Original file line number Diff line number Diff line change
1
+ 'use client'
2
+
3
+ import { use } from 'react'
4
+
5
+ const infinitePromise = new Promise < never > ( ( ) => { } )
6
+
7
+ export function SuspendForeverOnClient ( ) {
8
+ use ( infinitePromise )
9
+ return null
10
+ }
Original file line number Diff line number Diff line change
1
+ export default function Loading ( ) {
2
+ return < div id = "loading-component" > Loading...</ div >
3
+ }
Original file line number Diff line number Diff line change
1
+ import { connection } from 'next/server'
2
+ import { SuspendForeverOnClient } from './client'
3
+
4
+ export default async function Page ( ) {
5
+ await connection ( )
6
+ return (
7
+ < main >
8
+ { /* Block on the client to make sure that the loading boundary works correctly. */ }
9
+ < SuspendForeverOnClient />
10
+ </ main >
11
+ )
12
+ }
Original file line number Diff line number Diff line change
1
+ /** @type {import('next').NextConfig } */
2
+ module . exports = {
3
+ experimental : {
4
+ clientSegmentCache : true ,
5
+ clientParamParsing : true ,
6
+ } ,
7
+ productionBrowserSourceMaps : true ,
8
+ }
Original file line number Diff line number Diff line change
1
+ import { nextTestSetup } from 'e2e-utils'
2
+ import { createRouterAct } from '../router-act'
3
+
4
+ describe ( 'navigating without a prefetch' , ( ) => {
5
+ const { next } = nextTestSetup ( {
6
+ files : __dirname ,
7
+ } )
8
+
9
+ it ( 'can show a loading boundary from the dynamic response' , async ( ) => {
10
+ let act : ReturnType < typeof createRouterAct >
11
+ const browser = await next . browser ( '/' , {
12
+ beforePageLoad ( page ) {
13
+ act = createRouterAct ( page )
14
+ } ,
15
+ } )
16
+
17
+ // Navigate to a dynamic page with a `loading.tsx` without a prefetch.
18
+ await act ( async ( ) => {
19
+ await browser . elementByCss ( 'a[href="/with-loading"]' ) . click ( )
20
+ } )
21
+
22
+ // The page suspends on the client, so we should display the `loading` that we got from the dynamic response.
23
+ expect (
24
+ await browser
25
+ . elementByCss ( '#loading-component' , { state : 'visible' } )
26
+ . text ( )
27
+ ) . toContain ( 'Loading...' )
28
+ } )
29
+ } )
You can’t perform that action at this time.
0 commit comments