mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
[diff facebook/[email protected]](https://github.com/facebook/react/compare/f0dfee38...43bcbf80) <details> <summary>React upstream changes</summary> - https://github.com/facebook/react/pull/36586 - https://github.com/facebook/react/pull/36603 - https://github.com/facebook/react/pull/36585 - https://github.com/facebook/react/pull/36580 - https://github.com/facebook/react/pull/36584 - https://github.com/facebook/react/pull/36583 - https://github.com/facebook/react/pull/36576 - https://github.com/facebook/react/pull/36575 - https://github.com/facebook/react/pull/36574 </details> --------- Co-authored-by: next-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com> Co-authored-by: Josh Story <[email protected]>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
import {
|
|
retry,
|
|
getClientBuildManifestLoaderChunkUrlPath,
|
|
} from 'next-test-utils'
|
|
|
|
describe('Middleware Production Prefetch', () => {
|
|
const { next } = nextTestSetup({
|
|
files: __dirname,
|
|
env: {
|
|
MIDDLEWARE_TEST: 'asdf',
|
|
},
|
|
})
|
|
|
|
it('prefetch correctly for unexistent routes', async () => {
|
|
const browser = await next.browser('/')
|
|
await browser.elementByCss('#made-up-link').moveTo()
|
|
await retry(async () => {
|
|
const scripts = await browser.elementsByCss('script')
|
|
const attrs = await Promise.all(
|
|
scripts.map((script) => script.getAttribute('src'))
|
|
)
|
|
const chunk = getClientBuildManifestLoaderChunkUrlPath(
|
|
next.testDir,
|
|
'/ssg-page'
|
|
)
|
|
expect(attrs.some((src) => src && src.includes(chunk))).toBe(true)
|
|
})
|
|
})
|
|
|
|
it('does not prefetch provided path if it will be rewritten', async () => {
|
|
const browser = await next.browser('/')
|
|
await browser.elementByCss('#ssg-page-2').moveTo()
|
|
await retry(async () => {
|
|
const scripts = await browser.elementsByCss('script')
|
|
const attrs = await Promise.all(
|
|
scripts.map((script) => script.getAttribute('src'))
|
|
)
|
|
const chunk = getClientBuildManifestLoaderChunkUrlPath(
|
|
next.testDir,
|
|
'/ssg-page-2'
|
|
)
|
|
expect(attrs.some((src) => src && src.includes(chunk))).toBe(false)
|
|
})
|
|
})
|
|
})
|