Files
next.js/test/e2e/app-dir/parallel-routes-catchall-children-slot/parallel-routes-catchall-children-slot.test.ts
Zack TannerandGitHub efebba80a7 parallel routes: fix @children slots (#60288)
### What?
Our
[docs](https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#convention)
point out that `app/page.js` is equivalent to `app/@children/page.js`,
however in practice this is not the case, and causes type errors when
using `@children` slots as well as incorrect behavior when matching
catch-all routes.

### Why?
- When typechecking, `@children` slots would be added to the typeguard
file for the associated layout, resulting in duplicate identifiers for
the `children` prop
- When determining where to insert catchall slots, the `hasMatchedSlots`
check wasn't considering that the `@children` slot corresponds with the
page component, so matching another page would clobber the previous one.

### How?
- Filters out the `@children` slot when collecting slots for
typechecking
- Filters out the `@children` slot when running the `hasMatchedSlots`
function in the catch-all normalizer

Closes NEXT-1984
2024-01-06 07:24:44 -08:00

29 lines
820 B
TypeScript

import { createNextDescribe } from 'e2e-utils'
createNextDescribe(
'parallel-routes-catchall-children-slot',
{
files: __dirname,
},
({ next }) => {
it('should match the @children slot for a page before attempting to match the catchall', async () => {
let browser = await next.browser('/')
await expect(browser.elementById('children').text()).resolves.toBe(
'Hello from @children/page'
)
await expect(browser.elementById('slot').text()).resolves.toBe(
'@slot content'
)
browser = await next.browser('/nested')
await expect(browser.elementById('children').text()).resolves.toBe(
'Hello from nested @children page'
)
await expect(browser.elementById('slot').text()).resolves.toBe(
'Default @slot'
)
})
}
)