-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
115 additions
and
1 deletion.
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
5 changes: 5 additions & 0 deletions
5
test/e2e/app-dir/ppr-navigations/simple/app/[locale]/about/page.jsx
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 @@ | ||
import { TestPage } from '../../../components/page' | ||
|
||
export default function Page({ params: { locale } }) { | ||
return <TestPage pathname={`/${locale}/about`} /> | ||
} |
13 changes: 13 additions & 0 deletions
13
test/e2e/app-dir/ppr-navigations/simple/app/[locale]/layout.jsx
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,13 @@ | ||
import { locales } from '../../components/page' | ||
|
||
export async function generateStaticParams() { | ||
return locales.map((locale) => ({ locale })) | ||
} | ||
|
||
export default function Layout({ children, params: { locale } }) { | ||
return ( | ||
<html lang={locale}> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
5 changes: 5 additions & 0 deletions
5
test/e2e/app-dir/ppr-navigations/simple/app/[locale]/page.jsx
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 @@ | ||
import { TestPage } from '../../components/page' | ||
|
||
export default function Page({ params: { locale } }) { | ||
return <TestPage pathname={`/${locale}`} /> | ||
} |
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 ({ children }) => { | ||
return children | ||
} |
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 @@ | ||
import { redirect } from 'next/navigation' | ||
import { locales } from '../components/page' | ||
|
||
export default () => { | ||
// Redirect to the default locale | ||
return redirect(`/${locales[0]}`) | ||
} |
40 changes: 40 additions & 0 deletions
40
test/e2e/app-dir/ppr-navigations/simple/components/page.jsx
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,40 @@ | ||
import { unstable_noStore } from 'next/cache' | ||
import Link from 'next/link' | ||
import { Suspense } from 'react' | ||
|
||
export const locales = ['en', 'fr'] | ||
|
||
export const links = [ | ||
{ href: '/', text: 'Home' }, | ||
...locales | ||
.map((locale) => { | ||
return [ | ||
{ href: `/${locale}`, text: locale }, | ||
{ href: `/${locale}/about`, text: `${locale} - About` }, | ||
] | ||
}) | ||
.flat(), | ||
] | ||
|
||
function Dynamic() { | ||
unstable_noStore() | ||
return <div id="dynamic">Dynamic</div> | ||
} | ||
|
||
export function TestPage({ pathname }) { | ||
return ( | ||
<div> | ||
<ul> | ||
{links.map(({ href, text }) => ( | ||
<li key={href}> | ||
<Link href={href}>{text}</Link> | ||
</li> | ||
))} | ||
</ul> | ||
<code data-value={pathname}>{pathname}</code> | ||
<Suspense fallback={<div>Loading...</div>}> | ||
<Dynamic /> | ||
</Suspense> | ||
</div> | ||
) | ||
} |
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 @@ | ||
module.exports = { | ||
experimental: { | ||
ppr: true, | ||
}, | ||
} |
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,31 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
import { links, locales } from './components/page' | ||
|
||
describe('ppr-navigations simple', () => { | ||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
}) | ||
|
||
it('can navigate between all the links and back', async () => { | ||
const browser = await next.browser('/') | ||
|
||
try { | ||
for (const { href } of links) { | ||
// Find the link element for the href and click it. | ||
await browser.elementByCss(`a[href="${href}"]`).click() | ||
|
||
// Wait for that page to load. | ||
if (href === '/') { | ||
// The root page redirects to the first locale. | ||
await browser.waitForElementByCss(`[data-value="/${locales[0]}"]`) | ||
} else { | ||
await browser.waitForElementByCss(`[data-value="${href}"]`) | ||
} | ||
|
||
await browser.elementByCss('#dynamic') | ||
} | ||
} finally { | ||
await browser.close() | ||
} | ||
}) | ||
}) |