mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Test-only.
The test assertion was racy: it asserted no with-query-param RSC request
during hash-only navigations, but a late prefetch of the
`#link-to-query-param` link makes exactly that request (failed 3/3 on a
prod CI shard).
Assert the actual invariants instead:
- hash-only navigations issue no navigation RSC requests at all
(prefetches, identified by their headers, are ignored)
- a query change *does* issue one — with `prefetch={false}` on the link
so it can't be served from the prefetch cache.
54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
import Link from 'next/link'
|
|
import './global.css'
|
|
|
|
export default function HashPage() {
|
|
// Create list of 5000 items that all have unique id
|
|
const items = Array.from({ length: 5000 }, (_, i) => ({ id: i }))
|
|
|
|
return (
|
|
<div style={{ fontFamily: 'sans-serif', fontSize: '16px' }}>
|
|
<p>Hash Page</p>
|
|
<Link href="/hash#hash-6" id="link-to-6">
|
|
To 6
|
|
</Link>
|
|
<Link href="/hash#hash-50" id="link-to-50">
|
|
To 50
|
|
</Link>
|
|
<Link href="/hash#hash-160" id="link-to-160">
|
|
To 160
|
|
</Link>
|
|
<Link href="/hash#hash-300" id="link-to-300">
|
|
To 300
|
|
</Link>
|
|
<Link href="#hash-500" id="link-to-500">
|
|
To 500 (hash only)
|
|
</Link>
|
|
<Link href="/hash#top" id="link-to-top">
|
|
To Top
|
|
</Link>
|
|
<Link href="/hash#non-existent" id="link-to-non-existent">
|
|
To non-existent
|
|
</Link>
|
|
<div>
|
|
<Link
|
|
href="?with-query-param#hash-160"
|
|
id="link-to-query-param"
|
|
// The test asserts that hash-only navigations never request this
|
|
// query's RSC payload; prefetching this link would race that
|
|
// assertion.
|
|
prefetch={false}
|
|
>
|
|
To 160 (with query param)
|
|
</Link>
|
|
</div>
|
|
<div>
|
|
{items.map((item) => (
|
|
<div key={item.id}>
|
|
<div id={`hash-${item.id}`}>{item.id}</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|