Files
next.js/test/e2e/app-dir/metadata-static-file/metadata-static-file-parallel-route.test.ts
Aurora ScharffandGitHub 41114a31b8 Remove 'silence this warning' from instant validation fix output (#95187)
## What

Removes the `silence this warning` phrasing from the structured fix
lines in instant validation output:

- `- [block] Set \`export const instant = false\` to ~~silence this
warning and~~ allow a blocking route`
- `- [ignore] Set \`export const instant = false\` to ~~silence this
warning and~~ opt the route out of instant-navigation validation`
- `- [ignore] Set \`export const instant = false\` to ~~silence this
warning and~~ opt the dropped segment out of instant-navigation
validation`

## Why

The line called itself a warning while being logged via `Error:`. This
PR originally renamed it to `silence this error`, but that has the
mirror problem: at validation level `warning` or `manual-warning` (or
when the check only surfaces in dev) nothing blocks, so "error"
over-claims.

The verb is also wrong either way. Setting `instant = false` doesn't
silence a problem that still exists. It declares that blocking is
acceptable for the route, so validation stops treating it as one.
Removing the clause leaves wording that is correct at every validation
level and matches the dev overlay cards ("Allow blocking route",
"Disable validation on this route") and the docs sections the lines link
to.

## How

- `blocking-route-messages.ts`, `dynamic-rendering-utils.ts`: drop
`silence this warning and` from the `[block]` lines
- `instant-messages.ts`: drop it from the `[ignore]` lines (unrendered
segment, link prefetch)
- `errors.json`: regenerated, append-only (codes 1394-1405)
- Storybook fixture and 15 test files updated to the new strings

<!-- NEXT_JS_LLM_PR -->
2026-07-01 20:42:56 -04:00

159 lines
4.6 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
import {
getCommonMetadataHeadTags,
readFixtureBuffer,
readFixtureText,
} from './utils'
describe('metadata-files-static-output-parallel-route', () => {
if (process.env.__NEXT_CACHE_COMPONENTS) {
// Cache Components build fails when metadata files are inside a dynamic route.
//
// Route "/dynamic/[id]": Next.js encountered uncached or runtime data in `generateMetadata()`.
//
// This prevents the page from being prerendered, leading to a slower user experience.
//
// Ways to fix this:
// - [static] Use a static metadata export instead of `generateMetadata()`
// - [cache] Cache the metadata with `"use cache"` in `generateMetadata()`
// - [dynamic] Render a marker component that calls `await connection()` inside `<Suspense>` on the page
// - [block] Set `export const instant = false` to allow a blocking route
//
// Learn more: https://nextjs.org/docs/messages/blocking-prerender-metadata-dynamic
// Error occurred prerendering page "/dynamic/[id]". Read more: https://nextjs.org/docs/messages/prerender-error
// Export encountered an error on /dynamic/[id]/page: /dynamic/[id], exiting the build.
//
// TODO: Remove this skip when metadata files are supported in dynamic routes for Cache Components.
it.skip('should skip test for Cache Components', () => {})
return
}
const { next, skipped } = nextTestSetup({
files: __dirname,
})
if (skipped) {
return
}
it('should have correct link tags for parallel slot page', async () => {
const browser = await next.browser('/parallel')
expect(await getCommonMetadataHeadTags(browser)).toMatchInlineSnapshot(`
{
"links": [
{
"href": "/favicon.ico",
"rel": "icon",
"type": "image/x-icon",
},
{
"href": "/manifest.json",
"rel": "manifest",
},
{
"href": "/parallel/apple-icon-kzjltp.png",
"rel": "apple-touch-icon",
"type": "image/png",
},
{
"href": "/parallel/icon-kzjltp.png",
"rel": "icon",
"type": "image/png",
},
],
"metas": [
{
"name": "twitter:card",
},
{
"name": "twitter:image",
},
{
"name": "twitter:image:height",
},
{
"name": "twitter:image:type",
},
{
"name": "twitter:image:width",
},
{
"name": "viewport",
},
{
"property": "og:image",
},
{
"property": "og:image:height",
},
{
"property": "og:image:type",
},
{
"property": "og:image:width",
},
],
}
`)
})
it('should serve static files when requested to its route for parallel slot page', async () => {
const [
appleIconRes,
iconRes,
opengraphImageRes,
twitterImageRes,
sitemapRes,
] = await Promise.all([
next.fetch('/parallel/apple-icon-kzjltp.png'),
next.fetch('/parallel/icon-kzjltp.png'),
next.fetch('/parallel/opengraph-image-kzjltp.png'),
next.fetch('/parallel/twitter-image-kzjltp.png'),
next.fetch(`/parallel/sitemap.xml`),
])
// Compare response content with actual files
const [
actualAppleIcon,
actualIcon,
actualOpengraphImage,
actualTwitterImage,
actualSitemap,
] = await Promise.all([
readFixtureBuffer('app/parallel/@parallel/apple-icon.png'),
readFixtureBuffer('app/parallel/@parallel/icon.png'),
readFixtureBuffer('app/parallel/@parallel/opengraph-image.png'),
readFixtureBuffer('app/parallel/@parallel/twitter-image.png'),
readFixtureText('app/parallel/@parallel/sitemap.xml'),
])
expect({
appleIcon: Buffer.compare(
Buffer.from(await appleIconRes.arrayBuffer()),
actualAppleIcon
),
icon: Buffer.compare(
Buffer.from(await iconRes.arrayBuffer()),
actualIcon
),
opengraphImage: Buffer.compare(
Buffer.from(await opengraphImageRes.arrayBuffer()),
actualOpengraphImage
),
twitterImage: Buffer.compare(
Buffer.from(await twitterImageRes.arrayBuffer()),
actualTwitterImage
),
sitemap: await sitemapRes.text(),
}).toEqual({
// Buffer comparison returns 0 for equal
appleIcon: 0,
icon: 0,
opengraphImage: 0,
twitterImage: 0,
sitemap: actualSitemap,
})
})
})