Skip to content

Commit 809f37e

Browse files
committed
Add App Router pages to dev-indicator test app
1 parent f90a780 commit 809f37e

File tree

13 files changed

+96
-65
lines changed

13 files changed

+96
-65
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { connection } from 'next/server'
2+
import { setTimeout } from 'timers/promises'
3+
4+
export default async function Page() {
5+
await connection()
6+
await setTimeout(100)
7+
8+
return <p>This is a dynamic app router page.</p>
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Page() {
2+
return <p>This is a static app router page.</p>
3+
}

test/development/dev-indicator/app/layout.js

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Suspense } from 'react'
2+
import { Nav } from '../components/nav'
3+
4+
export default function Root({ children }: { children: React.ReactNode }) {
5+
return (
6+
<html>
7+
<body>
8+
<Nav />
9+
<main>
10+
<Suspense fallback={<p>Loading...</p>}>{children}</Suspense>
11+
</main>
12+
</body>
13+
</html>
14+
)
15+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import Link from 'next/link'
2+
3+
export function Nav() {
4+
return (
5+
<nav>
6+
<p>
7+
<Link href="/app/static-indicator/dynamic">App Router Dynamic</Link>
8+
</p>
9+
<p>
10+
<Link href="/app/static-indicator/static">App Router Static</Link>
11+
</p>
12+
<p>
13+
<Link href="/pages">Pages Router Static</Link>
14+
</p>
15+
<p>
16+
<Link href="/pages/gssp">Pages Router getServerSideProps</Link>
17+
</p>
18+
<p>
19+
<Link href="/pages/pregenerated">Pages Router getStaticPaths</Link>
20+
</p>
21+
<p>
22+
<Link href="/pages/gip">Pages Router getInitialProps</Link>
23+
</p>
24+
</nav>
25+
)
26+
}

test/development/dev-indicator/dev-indicator.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,37 @@ describe('dev indicator - route type', () => {
88

99
describe('getServerSideProps', () => {
1010
it('should update when going from dynamic -> static', async () => {
11-
const browser = await next.browser('/gssp')
11+
const browser = await next.browser('/pages/gssp')
1212

1313
await retry(async () => {
1414
expect(await getRouteTypeFromDevToolsIndicator(browser)).toBe('Dynamic')
1515
})
1616

1717
// validate static -> dynamic updates
18-
await browser.elementByCss("[href='/']").click()
18+
await browser.elementByCss("[href='/pages']").click()
1919

2020
await retry(async () => {
2121
expect(await getRouteTypeFromDevToolsIndicator(browser)).toBe('Static')
2222
})
2323
})
2424

2525
it('should update when going from static -> dynamic', async () => {
26-
const browser = await next.browser('/')
26+
const browser = await next.browser('/pages')
2727

2828
await retry(async () => {
2929
expect(await getRouteTypeFromDevToolsIndicator(browser)).toBe('Static')
3030
})
3131

3232
// validate static -> dynamic updates
33-
await browser.elementByCss("[href='/gssp']").click()
33+
await browser.elementByCss("[href='/pages/gssp']").click()
3434

3535
await retry(async () => {
3636
expect(await getRouteTypeFromDevToolsIndicator(browser)).toBe('Dynamic')
3737
})
3838
})
3939

4040
it('should be marked dynamic on first load', async () => {
41-
const browser = await next.browser('/gssp')
41+
const browser = await next.browser('/pages/gssp')
4242

4343
await retry(async () => {
4444
expect(await getRouteTypeFromDevToolsIndicator(browser)).toBe('Dynamic')
@@ -48,35 +48,35 @@ describe('dev indicator - route type', () => {
4848

4949
describe('getInitialProps', () => {
5050
it('should be marked dynamic on first load', async () => {
51-
const browser = await next.browser('/gip')
51+
const browser = await next.browser('/pages/gip')
5252

5353
await retry(async () => {
5454
expect(await getRouteTypeFromDevToolsIndicator(browser)).toBe('Dynamic')
5555
})
5656
})
5757

5858
it('should update when going from dynamic -> static', async () => {
59-
const browser = await next.browser('/gip')
59+
const browser = await next.browser('/pages/gip')
6060

6161
await retry(async () => {
6262
expect(await getRouteTypeFromDevToolsIndicator(browser)).toBe('Dynamic')
6363
})
6464

65-
await browser.elementByCss("[href='/']").click()
65+
await browser.elementByCss("[href='/pages']").click()
6666

6767
await retry(async () => {
6868
expect(await getRouteTypeFromDevToolsIndicator(browser)).toBe('Static')
6969
})
7070
})
7171

7272
it('should update when going from static -> dynamic', async () => {
73-
const browser = await next.browser('/')
73+
const browser = await next.browser('/pages')
7474

7575
await retry(async () => {
7676
expect(await getRouteTypeFromDevToolsIndicator(browser)).toBe('Static')
7777
})
7878

79-
await browser.elementByCss("[href='/gip']").click()
79+
await browser.elementByCss("[href='/pages/gip']").click()
8080

8181
await retry(async () => {
8282
expect(await getRouteTypeFromDevToolsIndicator(browser)).toBe('Dynamic')
@@ -86,21 +86,21 @@ describe('dev indicator - route type', () => {
8686

8787
describe('getStaticPaths', () => {
8888
it('should be marked static on first load', async () => {
89-
const browser = await next.browser('/pregenerated')
89+
const browser = await next.browser('/pages/pregenerated')
9090

9191
await retry(async () => {
9292
expect(await getRouteTypeFromDevToolsIndicator(browser)).toBe('Static')
9393
})
9494
})
9595

9696
it('should update when going from dynamic -> static', async () => {
97-
const browser = await next.browser('/gssp')
97+
const browser = await next.browser('/pages/gssp')
9898

9999
await retry(async () => {
100100
expect(await getRouteTypeFromDevToolsIndicator(browser)).toBe('Dynamic')
101101
})
102102

103-
await browser.elementByCss("[href='/pregenerated']").click()
103+
await browser.elementByCss("[href='/pages/pregenerated']").click()
104104

105105
await retry(async () => {
106106
expect(await getRouteTypeFromDevToolsIndicator(browser)).toBe('Static')
@@ -109,7 +109,7 @@ describe('dev indicator - route type', () => {
109109
})
110110

111111
it('should have route type as static by default for static page', async () => {
112-
const browser = await next.browser('/')
112+
const browser = await next.browser('/pages')
113113

114114
await retry(async () => {
115115
expect(await getRouteTypeFromDevToolsIndicator(browser)).toBe('Static')
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { AppProps } from 'next/app'
2+
import { Nav } from '../components/nav'
3+
4+
export default function MyApp({ Component, pageProps }: AppProps) {
5+
return (
6+
<>
7+
<Nav />
8+
<main>
9+
<Component {...pageProps} />
10+
</main>
11+
</>
12+
)
13+
}

test/development/dev-indicator/pages/gssp.tsx

Lines changed: 0 additions & 18 deletions
This file was deleted.

test/development/dev-indicator/pages/index.tsx

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/development/dev-indicator/pages/[slug]/index.tsx renamed to test/development/dev-indicator/pages/pages/[slug]/index.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
import Link from 'next/link'
2-
31
export default function Page({ slug }: { slug: string }) {
4-
return (
5-
<p>
6-
hello world {slug} <Link href="/gssp">to /gssp</Link>
7-
<Link href="/">to /</Link>
8-
</p>
9-
)
2+
return <p>hello world {slug}</p>
103
}
114

125
export const getStaticPaths = async () => {

0 commit comments

Comments
 (0)