Commit 90841a5f authored by Jimmy Lai's avatar Jimmy Lai

test: add failing test for #67034 - interception with identical paths in different groups

parent daca04d0
export default function InterceptedFromGroup1() {
return <div id="intercepted-modal">Intercepted from Group 1</div>
}
import { ReactNode } from 'react'
export default function Group1Layout({
children,
modal,
}: {
children: ReactNode
modal: ReactNode
}) {
return (
<>
<div id="group1-children">{children}</div>
<div id="group1-modal">{modal}</div>
</>
)
}
import Link from 'next/link'
export default function Group1Home() {
return (
<div>
<h1>Group 1 Home</h1>
<Link href="/shared" id="group1-link">
Go to shared
</Link>
</div>
)
}
export default function InterceptedFromGroup2() {
return <div id="intercepted-modal">Intercepted from Group 2</div>
}
import Link from 'next/link'
export default function Group2Page() {
return (
<div>
<h1>Group 2 Page</h1>
<Link href="/shared" id="group2-link">
Go to shared
</Link>
</div>
)
}
import { ReactNode } from 'react'
export default function Group2Layout({
children,
modal,
}: {
children: ReactNode
modal: ReactNode
}) {
return (
<>
<div id="group2-children">{children}</div>
<div id="group2-modal">{modal}</div>
</>
)
}
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
export default function SharedPage() {
return (
<div>
<h1 id="full-page">Full Shared Page</h1>
</div>
)
}
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
describe('intercepting-routes-duplicate-groups', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should intercept from group1', async () => {
const browser = await next.browser('/')
await browser.elementByCss('#group1-link').click()
await retry(async () => {
expect(await browser.elementById('intercepted-modal').text()).toBe(
'Intercepted from Group 1'
)
})
})
it('should intercept from group2', async () => {
const browser = await next.browser('/group2')
await browser.elementByCss('#group2-link').click()
await retry(async () => {
// This assertion should verify the interception works from group2.
// Due to the bug (#67034), the interception from group2 does not work:
// generate-interception-routes-rewrites.ts strips route group context,
// producing identical rewrite rules for both groups.
// Only the first group's rewrite matches, so group2 falls through
// to the full /shared page instead of showing the intercepted modal.
expect(await browser.elementById('intercepted-modal').text()).toBe(
'Intercepted from Group 2'
)
})
})
})
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {}
module.exports = nextConfig
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