File tree Expand file tree Collapse file tree 6 files changed +15
-30
lines changed
test/e2e/app-dir/app-prefetch
prefetch-auto-route-groups Expand file tree Collapse file tree 6 files changed +15
-30
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,7 @@ export function generateStaticParams() {
1414
1515export default function IdPage ( props ) {
1616 const params = use ( props . params )
17- const data = use ( getData ( ) )
18- console . log ( data )
17+ use ( getData ( ) )
1918
2019 if ( params . id === '123' ) {
2120 return (
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ export default function Root({ children }) {
22 return (
33 < html >
44 < head >
5- < script src = "https://cdn.tailwindcss.com?plugins=typography" > </ script >
65 < title > Hello World</ title >
76 < script
87 dangerouslySetInnerHTML = { {
Original file line number Diff line number Diff line change @@ -5,22 +5,16 @@ import Link from 'next/link'
55export default function Layout ( { children } : { children : React . ReactNode } ) {
66 return (
77 < >
8- < nav className = "bg-gray-800" >
9- < ul className = "flex" >
10- < li className = "mr-6" >
11- < Link href = "/prefetch-auto-route-groups" >
12- < p className = "text-white hover:text-gray-300" > Dashboard</ p >
13- </ Link >
8+ < nav style = { { border : '1px solid #1f2937' } } >
9+ < ul style = { { display : 'flex' } } >
10+ < li style = { { marginRight : '1.5rem' } } >
11+ < Link href = "/prefetch-auto-route-groups" > Dashboard</ Link >
1412 </ li >
15- < li className = "mr-6" >
16- < Link href = "/prefetch-auto-route-groups/sub/foo" >
17- < p className = "text-white hover:text-gray-300" > Foo</ p >
18- </ Link >
13+ < li style = { { marginRight : '1.5rem' } } >
14+ < Link href = "/prefetch-auto-route-groups/sub/foo" > Foo</ Link >
1915 </ li >
20- < li className = "mr-6" >
21- < Link href = "/prefetch-auto-route-groups/sub/bar" >
22- < p className = "text-white hover:text-gray-300" > Bar</ p >
23- </ Link >
16+ < li style = { { marginRight : '1.5rem' } } >
17+ < Link href = "/prefetch-auto-route-groups/sub/bar" > Bar</ Link >
2418 </ li >
2519 </ ul >
2620 </ nav >
Original file line number Diff line number Diff line change 1- import Link from 'next/link'
2-
31export const dynamic = 'force-dynamic'
42
53function getData ( ) {
64 const res = new Promise ( ( resolve ) => {
75 setTimeout ( ( ) => {
86 resolve ( { message : 'Layout Data!' } )
9- } , 2000 )
7+ } , 1000 )
108 } )
119 return res
1210}
@@ -17,9 +15,6 @@ export default async function Layout({ children }) {
1715 return (
1816 < div >
1917 < h1 > Layout</ h1 >
20- < Link prefetch = { undefined } href = "/prefetch-auto/justputit" >
21- Prefetch Link
22- </ Link >
2318 { children }
2419 < h3 > { JSON . stringify ( result ) } </ h3 >
2520 </ div >
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ function getData() {
44 const res = new Promise ( ( resolve ) => {
55 setTimeout ( ( ) => {
66 resolve ( { message : 'Page Data!' } )
7- } , 2000 )
7+ } , 1000 )
88 } )
99 return res
1010}
Original file line number Diff line number Diff line change @@ -314,22 +314,20 @@ describe('app dir - prefetching', () => {
314314 async ( ) => {
315315 const reveal = await browser . elementByCss ( '#accordion-to-dynamic-page' )
316316 await reveal . click ( )
317- await browser . waitForElementByCss ( '#to-dynamic-page' )
318- return await browser . elementByCss ( '#to-dynamic-page' )
317+ return browser . elementByCss ( '#to-dynamic-page' )
319318 } ,
320319 { includes : 'Loading Prefetch Auto' }
321320 )
322321
323322 // Click the link to navigate - should trigger dynamic data fetch
324- await act (
323+ const loadingText = await act (
325324 async ( ) => {
326325 await link . click ( )
327- await browser . waitForElementByCss ( '#loading-text' )
328- const loadingText = await browser . elementByCss ( '#loading-text' ) . text ( )
329- expect ( loadingText ) . toBe ( 'Loading Prefetch Auto' )
326+ return browser . elementByCss ( '#loading-text' ) . text ( )
330327 } ,
331328 { includes : 'prefetch-auto-page-data' }
332329 )
330+ expect ( loadingText ) . toBe ( 'Loading Prefetch Auto' )
333331
334332 // Wait for final data to appear
335333 await browser . waitForElementByCss ( '#prefetch-auto-page-data' )
You can’t perform that action at this time.
0 commit comments