mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
This PR changes the timing used in `CacheSignal.cacheReady()` to work correctly when rendering, not just prerendering. When rendering, React schedules new work in `setImmediate` (as opposed to using a microtask when prerendering), and `CacheSignal.cacheReady()` needs to account for that, because we need to wait longer to make sure that react had time to render and thus we've started all the relevant cache reads. Note that this PR increases the delay for both prerender _and_ render. This is to make it easier to reason about (by not having separate codepaths), but also to not be so tightly coupled to React pinging work in a microtask when prerendering, in case that changes in the future.
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('cache-components', () => {
|
|
const { next, isNextDev, skipped } = nextTestSetup({
|
|
files: __dirname,
|
|
skipDeployment: true,
|
|
})
|
|
|
|
if (skipped) {
|
|
return
|
|
}
|
|
|
|
it('should partially prerender pages that use connection', async () => {
|
|
let $ = await next.render$('/connection/static-behavior/boundary', {})
|
|
if (isNextDev) {
|
|
expect($('#layout').text()).toBe('at runtime')
|
|
expect($('#page').text()).toBe('at runtime')
|
|
expect($('#foo').text()).toBe('foo')
|
|
} else {
|
|
expect($('#layout').text()).toBe('at buildtime')
|
|
expect($('#page').text()).toBe('at buildtime')
|
|
expect($('#foo').text()).toBe('foo')
|
|
}
|
|
})
|
|
|
|
it('should be able to pass connection as a promise to another component and trigger an intermediate Suspense boundary', async () => {
|
|
const $ = await next.render$('/connection/static-behavior/pass-deeply')
|
|
if (isNextDev) {
|
|
expect($('#layout').text()).toBe('at runtime')
|
|
// In dev, whether or not the fallback appears in the HTML is unreliable
|
|
// and depends on timing, so we don't assert on its presence
|
|
// (if we want to assert on it, we should use a browser test)
|
|
expect($('#page').text()).toBe('at runtime')
|
|
} else {
|
|
expect($('#layout').text()).toBe('at buildtime')
|
|
expect($('#fallback').text()).toBe('at buildtime')
|
|
expect($('#page').text()).toBe('at runtime')
|
|
}
|
|
})
|
|
})
|