Unverified Commit 1cd37793 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Fix app dir page detection (#38475)

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
parent 8282c819
...@@ -479,8 +479,7 @@ export async function renderToHTML( ...@@ -479,8 +479,7 @@ export async function renderToHTML(
}): { Component: React.ComponentType } => { }): { Component: React.ComponentType } => {
const Loading = loading ? interopDefault(loading()) : undefined const Loading = loading ? interopDefault(loading()) : undefined
const layoutOrPageMod = layout ? layout() : page ? page() : undefined const layoutOrPageMod = layout ? layout() : page ? page() : undefined
// TODO: improve detection const isPage = typeof page !== undefined
const isPage = !firstItem && segment === ''
const isClientComponentModule = const isClientComponentModule =
layoutOrPageMod && !layoutOrPageMod.hasOwnProperty('__next_rsc__') layoutOrPageMod && !layoutOrPageMod.hasOwnProperty('__next_rsc__')
......
...@@ -155,10 +155,10 @@ describe('app dir - react server components', () => { ...@@ -155,10 +155,10 @@ describe('app dir - react server components', () => {
await browser.waitForElementByCss('#goto-next-link').click() await browser.waitForElementByCss('#goto-next-link').click()
await new Promise((res) => setTimeout(res, 1000)) 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 browser.waitForElementByCss('#goto-home').click()
await new Promise((res) => setTimeout(res, 1000)) 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() const content = await browser.elementByCss('body').text()
expect(content).toContain('component:root.server') expect(content).toContain('component:root.server')
...@@ -180,7 +180,7 @@ describe('app dir - react server components', () => { ...@@ -180,7 +180,7 @@ describe('app dir - react server components', () => {
expect(content).toMatchInlineSnapshot('"next_streaming_data"') 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 linkHTML = await renderViaHTTP(next.url, '/next-api/link')
const linkText = getNodeBySelector( const linkText = getNodeBySelector(
linkHTML, linkHTML,
......
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