Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pages not visible in dev when named children #54007

Merged
merged 6 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/next/src/server/dev/on-demand-entry-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ export function getEntryKey(
) {
// TODO: handle the /children slot better
// this is a quick hack to handle when children is provided as children/page instead of /page
return `${compilerType}@${pageBundleType}@${page.replace(/\/children/g, '')}`
return `${compilerType}@${pageBundleType}@${page.replace(
/(@[^/]+)\/children/g,
'$1'
)}`
}

function getPageBundleType(pageBundlePath: string) {
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/children-page/app/children/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page(props) {
return <p id="children-page">children - app</p>
}
7 changes: 7 additions & 0 deletions test/e2e/children-page/app/layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function RootLayout({ children }) {
return (
<html>
<body>{children}</body>
</html>
)
}
41 changes: 41 additions & 0 deletions test/e2e/children-page/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { createNextDescribe } from 'e2e-utils'

createNextDescribe(
ztanner marked this conversation as resolved.
Show resolved Hide resolved
'children-page',
{
files: __dirname,
},
({ next }) => {
describe('with app dir', () => {
it('should show the content if you have a page named children', async () => {
const browser = await next.browser('/children')

const text = await browser.waitForElementByCss('#children-page').text()

expect(text).toBe('children - app')

const currentDisplay = await browser.eval(
`window.getComputedStyle(document.querySelector('body')).display`
)

expect(currentDisplay).toBe('block')
})
})

describe('with pages dir', () => {
it('should show the content if you have a page named children', async () => {
const browser = await next.browser('/other/children')

const text = await browser.waitForElementByCss('#children-page').text()

expect(text).toBe('children - pages')

const currentDisplay = await browser.eval(
`window.getComputedStyle(document.querySelector('body')).display`
)

expect(currentDisplay).toBe('block')
})
})
}
)
3 changes: 3 additions & 0 deletions test/e2e/children-page/pages/other/children.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page(props) {
return <p id="children-page">children - pages</p>
}