Skip to content

Commit

Permalink
Fix app dir page detection (#38475)
Browse files Browse the repository at this point in the history
## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
  • Loading branch information
huozhi committed Jul 9, 2022
1 parent 8282c81 commit 1cd3779
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions packages/next/server/app-render.tsx
Expand Up @@ -479,8 +479,7 @@ export async function renderToHTML(
}): { Component: React.ComponentType } => {
const Loading = loading ? interopDefault(loading()) : undefined
const layoutOrPageMod = layout ? layout() : page ? page() : undefined
// TODO: improve detection
const isPage = !firstItem && segment === ''
const isPage = typeof page !== undefined

const isClientComponentModule =
layoutOrPageMod && !layoutOrPageMod.hasOwnProperty('__next_rsc__')
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/app-dir/rsc-basic.test.ts
Expand Up @@ -155,10 +155,10 @@ describe('app dir - react server components', () => {

await browser.waitForElementByCss('#goto-next-link').click()
await new Promise((res) => setTimeout(res, 1000))
expect(await browser.url()).toBe(`${next.url}/next-api/link`)
await check(() => browser.url(), `${next.url}/next-api/link`)
await browser.waitForElementByCss('#goto-home').click()
await new Promise((res) => setTimeout(res, 1000))
expect(await browser.url()).toBe(`${next.url}/root`)
await check(() => browser.url(), `${next.url}/root`)
const content = await browser.elementByCss('body').text()
expect(content).toContain('component:root.server')

Expand All @@ -180,7 +180,7 @@ describe('app dir - react server components', () => {
expect(content).toMatchInlineSnapshot('"next_streaming_data"')
})

it.skip('should support next/link in server components', async () => {
it('should support next/link in server components', async () => {
const linkHTML = await renderViaHTTP(next.url, '/next-api/link')
const linkText = getNodeBySelector(
linkHTML,
Expand Down

0 comments on commit 1cd3779

Please sign in to comment.