mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
## Summary - Fixes flaky test "per-page value overrides global staleTimes.dynamic regardless of direction" introduced by #91437 - The test was flaky because `browser.back()` restored accordion state from BFCache, causing previously-opened `LinkAccordion` links to be immediately visible. This triggered uncontrolled re-prefetches outside the `act` scope. When the `IntersectionObserver` fired inside a subsequent `act` scope (after clock advancement), stale data would trigger a prefetch that violated the `no-requests` assertion. - Fix: instead of navigating back to a previously visited page, navigate forward to fresh "hub" pages with their own `LinkAccordion` components. Since these are never-visited pages, accordions start closed and no uncontrolled prefetches are triggered. - General principle: when using the router `act` test utility, always use `LinkAccordion` to control when prefetches happen. Prefetches should only be triggered inside an `act` scope by toggling an accordion, never by navigating back to a page where links are already visible. ## Test plan - [x] Ran the full test file 4 times locally — all 5 tests pass consistently
31 lines
704 B
TypeScript
31 lines
704 B
TypeScript
import { Suspense } from 'react'
|
|
import { connection } from 'next/server'
|
|
import { LinkAccordion } from '../../../components/link-accordion'
|
|
|
|
export const unstable_dynamicStaleTime = 60
|
|
|
|
async function Content() {
|
|
await connection()
|
|
return (
|
|
<div id="dynamic-stale-60-content">Dynamic content (stale time 60s)</div>
|
|
)
|
|
}
|
|
|
|
export default function Page() {
|
|
return (
|
|
<>
|
|
<Suspense fallback="Loading...">
|
|
<Content />
|
|
</Suspense>
|
|
<ul>
|
|
<li>
|
|
<LinkAccordion href="/per-page-config/hub-a">Hub A</LinkAccordion>
|
|
</li>
|
|
<li>
|
|
<LinkAccordion href="/per-page-config/hub-c">Hub C</LinkAccordion>
|
|
</li>
|
|
</ul>
|
|
</>
|
|
)
|
|
}
|