-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Failing test for client navigation to layout with
React.Suspense
- Loading branch information
Showing
6 changed files
with
79 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function RootLayout({ children }) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
31 changes: 31 additions & 0 deletions
31
test/e2e/app-dir/navigation-layout-suspense/app/nested/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,31 @@ | ||
import { Suspense } from 'react' | ||
import Link from 'next/link' | ||
|
||
export const dynamic = 'force-dynamic' | ||
|
||
async function LoadData(props) { | ||
await fetch('https://next-data-api-endpoint.vercel.app/api/random?b').then( | ||
(res) => res.text() | ||
) | ||
return ( | ||
<> | ||
{props.children} | ||
<div>Got API Response </div> | ||
</> | ||
) | ||
} | ||
|
||
export default async function Layout(props) { | ||
return ( | ||
<> | ||
<div> | ||
<Link href={`/`} className="text-blue-500"> | ||
Home Page | ||
</Link> | ||
</div> | ||
<Suspense fallback={<h1>Loading...</h1>}> | ||
<LoadData>{props.children}</LoadData> | ||
</Suspense> | ||
</> | ||
) | ||
} |
7 changes: 7 additions & 0 deletions
7
test/e2e/app-dir/navigation-layout-suspense/app/nested/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 NestedPage() { | ||
return ( | ||
<> | ||
<h1 data-testid="nested-resolved">This is the nested Page</h1> | ||
</> | ||
) | ||
} |
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,14 @@ | ||
import Link from 'next/link' | ||
|
||
export default function Home() { | ||
return ( | ||
<> | ||
<div> | ||
<Link href={`/nested`} className="text-blue-500"> | ||
nested Page | ||
</Link> | ||
</div> | ||
<h1>This is the Home Page</h1> | ||
</> | ||
) | ||
} |
19 changes: 19 additions & 0 deletions
19
test/e2e/app-dir/navigation-layout-suspense/navigation-layout-suspense.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,19 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
|
||
describe('app dir - navigation with Suspense in nested layout', () => { | ||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
}) | ||
|
||
it('resolves data after client navigation to a nested layout with Suspense', async () => { | ||
const browser = await next.browser('/nested') | ||
|
||
await browser.waitForElementByCss('[data-testid="nested-resolved"]') | ||
|
||
await browser.waitForElementByCss('a[href="/"]').click() | ||
|
||
await browser.waitForElementByCss('a[href="/nested"]').click() | ||
|
||
await browser.waitForElementByCss('[data-testid="nested-resolved"]') | ||
}) | ||
}) |
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 = {} |