-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ensure router cache updates reference the latest cache values
- Loading branch information
Showing
23 changed files
with
168 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
test/e2e/app-dir/app-client-cache/client-cache.experimental.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
test/e2e/app-dir/app-client-cache/client-cache.parallel-routes.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
import { check } from 'next-test-utils' | ||
import { BrowserInterface } from 'next-webdriver' | ||
import { | ||
browserConfigWithFixedTime, | ||
createRequestsListener, | ||
fastForwardTo, | ||
getPathname, | ||
} from './test-utils' | ||
import path from 'path' | ||
|
||
describe('app dir client cache with parallel routes', () => { | ||
const { next } = nextTestSetup({ | ||
files: path.join(__dirname, 'fixtures', 'parallel-routes'), | ||
}) | ||
|
||
describe('prefetch={true}', () => { | ||
let browser: BrowserInterface | ||
|
||
beforeEach(async () => { | ||
browser = (await next.browser( | ||
'/', | ||
browserConfigWithFixedTime | ||
)) as BrowserInterface | ||
}) | ||
|
||
it('should prefetch the full page', async () => { | ||
const { getRequests, clearRequests } = | ||
await createRequestsListener(browser) | ||
await check(() => { | ||
return getRequests().some( | ||
([url, didPartialPrefetch]) => | ||
getPathname(url) === '/0' && !didPartialPrefetch | ||
) | ||
? 'success' | ||
: 'fail' | ||
}, 'success') | ||
|
||
clearRequests() | ||
|
||
await browser | ||
.elementByCss('[href="/0"]') | ||
.click() | ||
.waitForElementByCss('#random-number') | ||
|
||
expect(getRequests().every(([url]) => getPathname(url) !== '/0')).toEqual( | ||
true | ||
) | ||
}) | ||
|
||
it('should re-use the cache for the full page, only for 5 mins', async () => { | ||
const randomNumber = await browser | ||
.elementByCss('[href="/0"]') | ||
.click() | ||
.waitForElementByCss('#random-number') | ||
.text() | ||
|
||
await browser.elementByCss('[href="/"]').click() | ||
|
||
const number = await browser | ||
.elementByCss('[href="/0"]') | ||
.click() | ||
.waitForElementByCss('#random-number') | ||
.text() | ||
|
||
expect(number).toBe(randomNumber) | ||
|
||
await browser.eval(fastForwardTo, 5 * 60 * 1000) | ||
|
||
await browser.elementByCss('[href="/"]').click() | ||
|
||
const newNumber = await browser | ||
.elementByCss('[href="/0"]') | ||
.click() | ||
.waitForElementByCss('#random-number') | ||
.text() | ||
|
||
expect(newNumber).not.toBe(randomNumber) | ||
}) | ||
}) | ||
}) |
7 changes: 7 additions & 0 deletions
7
test/e2e/app-dir/app-client-cache/fixtures/parallel-routes/app/@breadcrumbs/[id]/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Page({ params }) { | ||
return ( | ||
<div> | ||
Catchall <pre>{JSON.stringify(params)}</pre>{' '} | ||
</div> | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/app-client-cache/fixtures/parallel-routes/app/@breadcrumbs/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return <div>Root Breadcrumb</div> | ||
} |
18 changes: 18 additions & 0 deletions
18
test/e2e/app-dir/app-client-cache/fixtures/parallel-routes/app/[id]/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Link from 'next/link' | ||
|
||
export default async function Page() { | ||
const randomNumber = await new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve(Math.random()) | ||
}, 1000) | ||
}) | ||
|
||
return ( | ||
<> | ||
<div> | ||
<Link href="/">Back to Home</Link> | ||
</div> | ||
<div id="random-number">{randomNumber}</div> | ||
</> | ||
) | ||
} |
12 changes: 12 additions & 0 deletions
12
test/e2e/app-dir/app-client-cache/fixtures/parallel-routes/app/layout.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export default function Root({ children, breadcrumbs }) { | ||
return ( | ||
<html> | ||
<head></head> | ||
<body> | ||
<div>{breadcrumbs}</div> | ||
<div id="root-layout">Root Layout</div> | ||
<div>{children}</div> | ||
</body> | ||
</html> | ||
) | ||
} |
11 changes: 11 additions & 0 deletions
11
test/e2e/app-dir/app-client-cache/fixtures/parallel-routes/app/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Link from 'next/link' | ||
|
||
export default function Page() { | ||
return ( | ||
<div> | ||
<Link href="/0" prefetch={true}> | ||
To Dynamic Page | ||
</Link> | ||
</div> | ||
) | ||
} |
5 changes: 5 additions & 0 deletions
5
test/e2e/app-dir/app-client-cache/fixtures/regular/app/[id]/client.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use client' | ||
|
||
export function ClientComponent() { | ||
return <div>Client Component</div> | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
...e/app-dir/app-client-cache/fixtures/regular/app/without-loading/@breadcrumbs/[id]/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Page({ params }) { | ||
return ( | ||
<div> | ||
Catchall <pre>{JSON.stringify(params)}</pre>{' '} | ||
</div> | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/app-client-cache/fixtures/regular/app/without-loading/@breadcrumbs/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page({ params }) { | ||
return <div>Root Breadcrumb</div> | ||
} |
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
test/e2e/app-dir/app-client-cache/fixtures/regular/app/without-loading/layout.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default function Page({ children, breadcrumbs }) { | ||
return ( | ||
<> | ||
<div>{breadcrumbs}</div> | ||
<div>{children}</div> | ||
</> | ||
) | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = { productionBrowserSourceMaps: true } |