Skip to content

Commit

Permalink
add test case for intercepting route + catchall + generateStaticParams (
Browse files Browse the repository at this point in the history
#75167)

This case is fixed on `canary`, but has a regression on 15.1. This PR
adds a test case that succeeds on `canary` but fails on the backport
branch. A fix for the backport branch is forthcoming.
  • Loading branch information
ztanner authored Jan 22, 2025
1 parent 8e2bd16 commit d12e2e8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function CatchAll() {
return null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return 'intercepted'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
type Props = {
params: Promise<{ slug: string }>
}

export default async function Page({ params }: Props) {
const { slug } = await params
return <div>Hello {slug}</div>
}

export function generateStaticParams() {
return [
{ slug: 'a' },
{ slug: 'b' },
{ slug: 'c' },
{ slug: 'd' },
{ slug: 'e' },
{ slug: 'f' },
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { nextTestSetup } from 'e2e-utils'
import { check } from 'next-test-utils'

describe('interception-dynamic-segment', () => {
const { next } = nextTestSetup({
const { next, isNextStart } = nextTestSetup({
files: __dirname,
})

Expand All @@ -15,4 +15,13 @@ describe('interception-dynamic-segment', () => {
await check(() => browser.elementById('modal').text(), '')
await check(() => browser.elementById('children').text(), /not intercepted/)
})

if (isNextStart) {
it('should correctly prerender segments with generateStaticParams', async () => {
expect(next.cliOutput).toContain('/generate-static-params/a')
const res = await next.fetch('/generate-static-params/a')
expect(res.status).toBe(200)
expect(res.headers.get('x-nextjs-cache')).toBe('HIT')
})
}
})

0 comments on commit d12e2e8

Please sign in to comment.