Unverified Commit 04906eff authored by David Alexandru Ilie's avatar David Alexandru Ilie Committed by GitHub

test: cover blocking not-found status stability

parent 0b7e96f4
import { notFound } from 'next/navigation'
const prerenderedSlugs = ['known']
const runtimeSlugs = ['runtime']
export const instant = false
export function generateStaticParams() {
return prerenderedSlugs.map((slug) => ({ slug: [slug] }))
}
export default async function Page({
params,
}: {
params: Promise<{ slug?: string[] }>
}) {
const { slug } = await params
const pathname = slug?.join('/') ?? ''
if (
!prerenderedSlugs.includes(pathname) &&
!runtimeSlugs.includes(pathname)
) {
notFound()
}
return <p id="blocking-slug">{pathname}</p>
}
...@@ -240,4 +240,25 @@ describe('partial-fallback-shell-upgrade - partialPrefetching disabled', () => { ...@@ -240,4 +240,25 @@ describe('partial-fallback-shell-upgrade - partialPrefetching disabled', () => {
'generic shell should remain shared without partialPrefetching' 'generic shell should remain shared without partialPrefetching'
) )
}) })
it('keeps blocking not-found responses stable after the first request', async () => {
for (let attempt = 0; attempt < 2; attempt++) {
const response = await next.fetch('/blocking/missing')
const html = await response.text()
expect(response.status).toBe(404)
expect(html).toContain('<meta name="robots" content="noindex"')
}
})
it('serves valid ungenerated params before and after the first request', async () => {
for (let attempt = 0; attempt < 2; attempt++) {
const response = await next.fetch('/blocking/runtime')
expect(response.status).toBe(200)
expect(await response.text()).toContain(
'<p id="blocking-slug">runtime</p>'
)
}
})
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment