mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
7c97f56bfd
This gates the part that depends on runtime logs. This test is still valuable without this particular check.
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
import { check } from 'next-test-utils'
|
|
|
|
describe('app-prefetch-false-loading', () => {
|
|
const { next, isNextDeploy } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
it('should render loading for the initial render', async () => {
|
|
const $ = await next.render$('/en/testing')
|
|
|
|
expect($('#loading').text()).toBe('Loading...')
|
|
})
|
|
it('should not re-trigger loading state when navigating between pages that share a dynamic layout', async () => {
|
|
const logStartIndex = next.cliOutput.length
|
|
|
|
const browser = await next.browser('/en/testing')
|
|
let initialRandomNumber = await browser.elementById('random-number').text()
|
|
await browser.elementByCss('[href="/en/testing/test"]').click()
|
|
expect(await browser.hasElementByCssSelector('#loading')).toBeFalsy()
|
|
|
|
await check(
|
|
() => browser.hasElementByCssSelector('#nested-testing-page'),
|
|
true
|
|
)
|
|
|
|
const newRandomNumber = await browser.elementById('random-number').text()
|
|
|
|
expect(initialRandomNumber).toBe(newRandomNumber)
|
|
|
|
// Deploy doesn't have access to runtime logs. This assertion is also redundant since if
|
|
// the layout was re-fetched, the `no-store` on the random number would have resulted in a new value.
|
|
// Keeping this here for consistency with the original test.
|
|
if (!isNextDeploy) {
|
|
await check(() => {
|
|
const logOccurrences =
|
|
next.cliOutput.slice(logStartIndex).split('re-fetching in layout')
|
|
.length - 1
|
|
|
|
return logOccurrences
|
|
}, 1)
|
|
}
|
|
})
|
|
})
|