Files
next.js/test/e2e/app-dir/metadata-streaming-static-generation/metadata-streaming-static-generation.test.ts
Arian Tron 61f56f997c
Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled
first commit
2026-03-10 19:37:31 +03:30

113 lines
4.4 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
const isPPREnabled = process.env.__NEXT_CACHE_COMPONENTS === 'true'
// Skip PPR test as it's covered in test/e2e/app-dir/ppr-metadata-streaming/ppr-metadata-streaming.test.ts
;(isPPREnabled ? describe.skip : describe)(
'app-dir - metadata-streaming-static-generation',
() => {
const { next, isNextDev, isNextStart } = nextTestSetup({
files: __dirname,
})
if (isNextStart) {
// Precondition for the following tests in build mode.
// This test is only useful for non-PPR mode as in PPR mode those routes
// are all listed in the prerender manifest.
it('should generate all pages static', async () => {
const prerenderManifest = JSON.parse(
await next.readFile('.next/prerender-manifest.json')
)
const staticRoutes = prerenderManifest.routes
expect(Object.keys(staticRoutes).sort()).toEqual([
'/',
'/_global-error',
'/_not-found',
'/slow/static',
'/suspenseful/static',
])
})
}
if (isNextDev) {
// In development it's still dynamic rendering that metadata will be inserted into body
describe('static pages (development)', () => {
it('should contain async generated metadata in body for simple static page', async () => {
const $ = await next.render$('/')
expect($('body title').text()).toBe('index page')
})
it('should contain async generated metadata in body for slow static page', async () => {
const $ = await next.render$('/slow/static')
expect($('body title').text()).toBe('slow page - static')
})
it('should contain async generated metadata in body static page with suspenseful content', async () => {
const $ = await next.render$('/suspenseful/static')
expect($('body title').text()).toBe('suspenseful page - static')
})
})
} else {
describe('static pages (production)', () => {
it('should contain async generated metadata in head for simple static page', async () => {
const $ = await next.render$('/')
expect($('head title').text()).toBe('index page')
})
it('should contain async generated metadata in head for slow static page', async () => {
const $ = await next.render$('/slow/static')
expect($('head title').text()).toBe('slow page - static')
})
it('should contain async generated metadata in head static page with suspenseful content', async () => {
const $ = await next.render$('/suspenseful/static')
expect($('head title').text()).toBe('suspenseful page - static')
})
})
}
describe('dynamic pages', () => {
it('should contain async generated metadata in body for simple dynamics page', async () => {
const $ = await next.render$('/suspenseful/dynamic')
expect($('body title').text()).toBe('suspenseful page - dynamic')
})
it('should contain async generated metadata in body for suspenseful dynamic page', async () => {
const $ = await next.render$('/slow/dynamic')
expect($('body title').text()).toBe('slow page - dynamic')
})
})
describe('dynamic pages with html limited bots', () => {
it('should contain stream metadata in head for suspenseful dynamic page', async () => {
const $ = await next.render$('/suspenseful/dynamic', undefined, {
headers: {
'User-Agent': 'Discordbot/2.0;',
},
})
expect($('head title').text()).toBe('suspenseful page - dynamic')
// Ensure it's suspenseful content
expect($('.suspenseful-layout').text()).toBe('')
// Can still render the suspenseful content with browser
const browser = await next.browser('/suspenseful/dynamic')
await retry(async () => {
expect(await browser.elementByCss('.suspenseful-layout').text()).toBe(
'suspenseful - dynamic'
)
})
})
it('should contain async generated metadata in head for simple dynamic page', async () => {
const $ = await next.render$('/slow/dynamic', undefined, {
headers: {
'User-Agent': 'Discordbot/2.0;',
},
})
expect($('head title').text()).toBe('slow page - dynamic')
})
})
}
)