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
168 lines
4.8 KiB
TypeScript
168 lines
4.8 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('use-cache-metadata-route-handler', () => {
|
|
const { next, isNextDev, isNextStart } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
it('should generate an opengraph image with a metadata route handler that uses "use cache"', async () => {
|
|
const res = await next.fetch('/opengraph-image')
|
|
expect(res.status).toBe(200)
|
|
expect(res.headers.get('content-type')).toBe('image/png')
|
|
|
|
if (isNextStart) {
|
|
const [buildStatus] = next.cliOutput.match(/. \/opengraph-image/)
|
|
|
|
// TODO: Should always be `○ /opengraph-image`.
|
|
expect(buildStatus).toBeOneOf([
|
|
'○ /opengraph-image',
|
|
'ƒ /opengraph-image',
|
|
])
|
|
}
|
|
})
|
|
|
|
it('should generate an icon image with a metadata route handler that uses "use cache"', async () => {
|
|
const res = await next.fetch('/icon')
|
|
expect(res.status).toBe(200)
|
|
expect(res.headers.get('content-type')).toBe('image/png')
|
|
|
|
if (isNextStart) {
|
|
const [buildStatus] = next.cliOutput.match(/. \/icon/)
|
|
|
|
// TODO: Should always be `○ /icon`.
|
|
expect(buildStatus).toBeOneOf(['○ /icon', 'ƒ /icon'])
|
|
}
|
|
})
|
|
|
|
it('should generate sitemaps with a metadata route handler that uses "use cache"', async () => {
|
|
const res = await next.fetch('/sitemap.xml')
|
|
expect(res.status).toBe(200)
|
|
expect(res.headers.get('content-type')).toBe('application/xml')
|
|
|
|
const body = await res.text()
|
|
|
|
if (isNextDev) {
|
|
expect(body).toMatchInlineSnapshot(`
|
|
"<?xml version="1.0" encoding="UTF-8"?>
|
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
<url>
|
|
<loc>https://acme.com?sentinel=runtime</loc>
|
|
</url>
|
|
</urlset>
|
|
"
|
|
`)
|
|
} else {
|
|
expect(body).toMatchInlineSnapshot(`
|
|
"<?xml version="1.0" encoding="UTF-8"?>
|
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
<url>
|
|
<loc>https://acme.com?sentinel=buildtime</loc>
|
|
</url>
|
|
</urlset>
|
|
"
|
|
`)
|
|
}
|
|
})
|
|
|
|
it('should generate multiple sitemaps with a metadata route handler that uses "use cache"', async () => {
|
|
const res = await next.fetch('/products/sitemap/1.xml')
|
|
expect(res.status).toBe(200)
|
|
expect(res.headers.get('content-type')).toBe('application/xml')
|
|
|
|
const body = await res.text()
|
|
|
|
if (isNextDev) {
|
|
expect(body).toMatchInlineSnapshot(`
|
|
"<?xml version="1.0" encoding="UTF-8"?>
|
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
<url>
|
|
<loc>https://acme.com/1?sentinel=runtime</loc>
|
|
</url>
|
|
</urlset>
|
|
"
|
|
`)
|
|
} else {
|
|
expect(body).toMatchInlineSnapshot(`
|
|
"<?xml version="1.0" encoding="UTF-8"?>
|
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
<url>
|
|
<loc>https://acme.com/1?sentinel=buildtime</loc>
|
|
</url>
|
|
</urlset>
|
|
"
|
|
`)
|
|
}
|
|
})
|
|
|
|
it('should generate robots.txt with a metadata route handler that uses "use cache"', async () => {
|
|
const res = await next.fetch('/robots.txt')
|
|
expect(res.status).toBe(200)
|
|
expect(res.headers.get('content-type')).toContain('text/plain')
|
|
|
|
const body = await res.text()
|
|
|
|
if (isNextDev) {
|
|
expect(body).toMatchInlineSnapshot(`
|
|
"User-Agent: *
|
|
Allow: /runtime
|
|
|
|
"
|
|
`)
|
|
} else {
|
|
expect(body).toMatchInlineSnapshot(`
|
|
"User-Agent: *
|
|
Allow: /buildtime
|
|
|
|
"
|
|
`)
|
|
}
|
|
})
|
|
|
|
it('should generate manifest.json with a metadata route handler that uses "use cache"', async () => {
|
|
const res = await next.fetch('/manifest.webmanifest')
|
|
expect(res.status).toBe(200)
|
|
expect(res.headers.get('content-type')).toContain(
|
|
'application/manifest+json'
|
|
)
|
|
|
|
const body = await res.json()
|
|
|
|
if (isNextDev) {
|
|
expect(body).toEqual({ name: 'runtime' })
|
|
} else {
|
|
expect(body).toEqual({ name: 'buildtime' })
|
|
}
|
|
})
|
|
|
|
if (isNextStart) {
|
|
it('should include the client reference manifest in the route.js.nft.json files of dynamic metadata routes', async () => {
|
|
for (const filename of [
|
|
'icon',
|
|
'manifest.webmanifest',
|
|
'opengraph-image',
|
|
'products/sitemap/[__metadata_id__]',
|
|
'robots.txt',
|
|
'sitemap.xml',
|
|
]) {
|
|
const { files } = await next.readJSON(
|
|
`/.next/server/app/${filename}/route.js.nft.json`
|
|
)
|
|
|
|
expect(
|
|
files.find((e) => e.endsWith('route_client-reference-manifest.js'))
|
|
).toBeString()
|
|
}
|
|
})
|
|
|
|
it('should not include the client reference manifest in the route.js.nft.json files of static metadata routes', async () => {
|
|
const { files } = await next.readJSON(
|
|
'/.next/server/app/favicon.ico/route.js.nft.json'
|
|
)
|
|
|
|
expect(
|
|
files.find((e) => e.endsWith('route_client-reference-manifest.js'))
|
|
).toBeUndefined()
|
|
})
|
|
}
|
|
})
|