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

Update tests root->app #37477

Merged
merged 2 commits into from
Jun 6, 2022
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function ChangelogPage(props) {
return (
<>
<p>hello from root/dashboard/changelog</p>
<p>hello from app/dashboard/changelog</p>
</>
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function HelloPage(props) {
return (
<>
<p>hello from root/dashboard/rootonly/hello</p>
<p>hello from app/dashboard/rootonly/hello</p>
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function ClientComponentRoute() {
}, [count])
return (
<>
<p>hello from root/client-component-route. count: {count}</p>
<p>hello from app/client-component-route. count: {count}</p>
</>
)
}
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/client-nested/page.server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function ClientPage() {
return (
<>
<p>hello from root/client-nested</p>
<p>hello from app/client-nested</p>
</>
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function DeploymentsBreakdownPage(props) {
return (
<>
<p>hello from root/dashboard/(custom)/deployments/breakdown</p>
<p>hello from app/dashboard/(custom)/deployments/breakdown</p>
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function getServerSideProps({ params }) {
export default function DeploymentsPage(props) {
return (
<>
<p>hello from root/dashboard/deployments/[id]. ID is: {props.id}</p>
<p>hello from app/dashboard/deployments/[id]. ID is: {props.id}</p>
</>
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function DeploymentsInfoPage(props) {
return (
<>
<p>hello from root/dashboard/deployments/info</p>
<p>hello from app/dashboard/deployments/info</p>
</>
)
}
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/dashboard/index/page.server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function DashboardIndexPage() {
return (
<>
<p>hello from root/dashboard/index</p>
<p>hello from app/dashboard/index</p>
</>
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function IntegrationsPage(props) {
return (
<>
<p>hello from root/dashboard/integrations</p>
<p>hello from app/dashboard/integrations</p>
</>
)
}
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/dashboard/page.server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function DashboardPage(props) {
return (
<>
<p>hello from root/dashboard</p>
<p>hello from app/dashboard</p>
</>
)
}
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/partial-match-[id]/page.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function getServerSideProps({ params }) {
export default function DeploymentsPage(props) {
return (
<>
<p>hello from root/partial-match-[id]. ID is: {props.id}</p>
<p>hello from app/partial-match-[id]. ID is: {props.id}</p>
</>
)
}
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/shared-component-route/page.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function SharedComponentRoute() {
return (
<>
<p>hello from root/shared-component-route</p>
<p>hello from app/shared-component-route</p>
</>
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function ShouldNotServeClientDotJs(props) {
return (
<>
<p>hello from root/should-not-serve-client</p>
<p>hello from app/should-not-serve-client</p>
</>
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function ShouldNotServeServerDotJs(props) {
return (
<>
<p>hello from root/should-not-serve-server</p>
<p>hello from app/should-not-serve-server</p>
</>
)
}
30 changes: 15 additions & 15 deletions test/e2e/app-dir/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ describe('views dir', () => {

it('should serve from app', async () => {
const html = await renderViaHTTP(next.url, '/dashboard')
expect(html).toContain('hello from root/dashboard')
expect(html).toContain('hello from app/dashboard')
})

it('should serve /index as separate page', async () => {
const html = await renderViaHTTP(next.url, '/dashboard/index')
expect(html).toContain('hello from root/dashboard/index')
expect(html).toContain('hello from app/dashboard/index')
})

it('should include layouts when no direct parent layout', async () => {
Expand All @@ -68,7 +68,7 @@ describe('views dir', () => {
// Should not be nested in dashboard
expect($('h1').text()).toBe('Dashboard')
// Should include the page text
expect($('p').text()).toBe('hello from root/dashboard/integrations')
expect($('p').text()).toBe('hello from app/dashboard/integrations')
})

it('should not include parent when not in parent directory with route in directory', async () => {
Expand All @@ -86,7 +86,7 @@ describe('views dir', () => {
expect($('h1').text()).toBeFalsy()

// Should render the page text
expect($('p').text()).toBe('hello from root/dashboard/rootonly/hello')
expect($('p').text()).toBe('hello from app/dashboard/rootonly/hello')
})

it('should use new root layout when provided', async () => {
Expand Down Expand Up @@ -123,7 +123,7 @@ describe('views dir', () => {

// Should render the page text
expect($('p').text()).toBe(
'hello from root/dashboard/(custom)/deployments/breakdown'
'hello from app/dashboard/(custom)/deployments/breakdown'
)
})

Expand All @@ -141,7 +141,7 @@ describe('views dir', () => {
// Should not be nested in dashboard
expect($('h1').text()).toBeFalsy()
// Should include the page text
expect($('p').text()).toBe('hello from root/dashboard/changelog')
expect($('p').text()).toBe('hello from app/dashboard/changelog')
})

it('should serve nested parent', async () => {
Expand All @@ -158,7 +158,7 @@ describe('views dir', () => {
const $ = cheerio.load(html)
// Should include the page text with the parameter
expect($('p').text()).toBe(
'hello from root/dashboard/deployments/[id]. ID is: 123'
'hello from app/dashboard/deployments/[id]. ID is: 123'
)
})

Expand All @@ -180,7 +180,7 @@ describe('views dir', () => {
// to work for /pages as well?
it.skip('should match partial parameters', async () => {
const html = await renderViaHTTP(next.url, '/partial-match-123')
expect(html).toContain('hello from root/partial-match-[id]. ID is: 123')
expect(html).toContain('hello from app/partial-match-[id]. ID is: 123')
})

describe('server components', () => {
Expand All @@ -189,7 +189,7 @@ describe('views dir', () => {
it('should not serve .server.js as a path', async () => {
// Without .server.js should serve
const html = await renderViaHTTP(next.url, '/should-not-serve-server')
expect(html).toContain('hello from root/should-not-serve-server')
expect(html).toContain('hello from app/should-not-serve-server')

// Should not serve `.server`
const res = await fetchViaHTTP(
Expand All @@ -211,7 +211,7 @@ describe('views dir', () => {
it('should not serve .client.js as a path', async () => {
// Without .client.js should serve
const html = await renderViaHTTP(next.url, '/should-not-serve-client')
expect(html).toContain('hello from root/should-not-serve-client')
expect(html).toContain('hello from app/should-not-serve-client')

// Should not serve `.client`
const res = await fetchViaHTTP(
Expand All @@ -233,15 +233,15 @@ describe('views dir', () => {
it('should serve shared component', async () => {
// Without .client.js should serve
const html = await renderViaHTTP(next.url, '/shared-component-route')
expect(html).toContain('hello from root/shared-component-route')
expect(html).toContain('hello from app/shared-component-route')
})

describe('should serve client component', () => {
it('should serve server-side', async () => {
const html = await renderViaHTTP(next.url, '/client-component-route')
const $ = cheerio.load(html)
expect($('p').text()).toBe(
'hello from root/client-component-route. count: 0'
'hello from app/client-component-route. count: 0'
)
})

Expand All @@ -250,7 +250,7 @@ describe('views dir', () => {

// After hydration count should be 1
expect(await browser.elementByCss('p').text()).toBe(
'hello from root/client-component-route. count: 1'
'hello from app/client-component-route. count: 1'
)
})
})
Expand All @@ -262,7 +262,7 @@ describe('views dir', () => {
// Should not be nested in dashboard
expect($('h1').text()).toBe('Client Nested. Count: 0')
// Should include the page text
expect($('p').text()).toBe('hello from root/client-nested')
expect($('p').text()).toBe('hello from app/client-nested')
})

it('should include it client-side', async () => {
Expand All @@ -275,7 +275,7 @@ describe('views dir', () => {

// After hydration count should be 1
expect(await browser.elementByCss('p').text()).toBe(
'hello from root/client-nested'
'hello from app/client-nested'
)
})
})
Expand Down