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

ref(e2e): Make Next.js app dir tests more thorough #7336

Merged
merged 7 commits into from
Mar 6, 2023
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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use client';

export default function Error({ error, reset }: { error: Error; reset: () => void }) {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Error (/client-component)</h2>
<button onClick={() => reset()}>Reset</button>
Error: {error.toString()}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use client';

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h1>Layout (/client-component)</h1>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Loading() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Loading (/client-component)</h2>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function NotFound() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Not found (/client-component)</h2>;
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use client';

import { ClientErrorDebugTools } from '../../components/client-error-debug-tools';

export default function Page() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Page (/client-component)</h2>
<ClientErrorDebugTools />
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use client';

export default function Error({ error, reset }: { error: Error; reset: () => void }) {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Error (/client-component/[...parameters])</h2>
<button onClick={() => reset()}>Reset</button>
Error: {error.toString()}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use client';

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h1>Layout (/client-component/[...parameters])</h1>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Loading() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Loading (/client-component/parameter/[...parameters])</h2>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function NotFound() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Not found (/client-component/[...parameters])</h2>;
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ClientErrorDebugTools } from '../../../../components/client-error-debug-tools';

export default function Page({ params }: { params: Record<string, string> }) {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Page (/client-component/[...parameters])</h2>
<p>Params: {JSON.stringify(params['parameters'])}</p>
<ClientErrorDebugTools />
</div>
);
}

export async function generateStaticParams() {
return [{ parameters: ['foo', 'bar', 'baz'] }];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use client';

export default function Error({ error, reset }: { error: Error; reset: () => void }) {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Error (/client-component/[parameter])</h2>
<button onClick={() => reset()}>Reset</button>
Error: {error.toString()}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use client';

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h1>Layout (/client-component/[parameter])</h1>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Loading() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Loading (/client-component/[parameter])</h2>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function NotFound() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Not found (/client-component/[parameter])</h2>;
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ClientErrorDebugTools } from '../../../../components/client-error-debug-tools';

export default function Page({ params }: { params: Record<string, string> }) {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Page (/client-component/[parameter])</h2>
<p>Parameter: {JSON.stringify(params['parameter'])}</p>
<ClientErrorDebugTools />
</div>
);
}

export async function generateStaticParams() {
return [{ parameter: '42' }];
}
11 changes: 11 additions & 0 deletions packages/e2e-tests/test-applications/nextjs-app-dir/app/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use client';

export default function Error({ error, reset }: { error: Error; reset: () => void }) {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Error (/)</h2>
<button onClick={() => reset()}>Reset</button>
Error: {error.toString()}
</div>
);
}
38 changes: 38 additions & 0 deletions packages/e2e-tests/test-applications/nextjs-app-dir/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { TransactionContextProvider } from '../components/transaction-context';
import Link from 'next/link';

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h1>Layout (/)</h1>
<ul>
<li>
<Link href="/">/</Link>
</li>
<li>
<Link href="/client-component">/client-component</Link>
</li>
<li>
<Link href="/client-component/parameter/42">/client-component/parameter/42</Link>
</li>
<li>
<Link href="/client-component/parameter/foo/bar/baz">/client-component/parameter/foo/bar/baz</Link>
</li>
<li>
<Link href="/server-component">/server-component</Link>
</li>
<li>
<Link href="/server-component/parameter/42">/server-component/parameter/42</Link>
</li>
<li>
<Link href="/server-component/parameter/foo/bar/baz">/server-component/parameter/foo/bar/baz</Link>
</li>
</ul>
<TransactionContextProvider>{children}</TransactionContextProvider>
</div>
</body>
</html>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Loading() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Loading (/)</h2>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function NotFound() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Not found (/)</h2>;
</div>
);
}
10 changes: 10 additions & 0 deletions packages/e2e-tests/test-applications/nextjs-app-dir/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ClientErrorDebugTools } from '../components/client-error-debug-tools';

export default function Page() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Page (/)</h2>
<ClientErrorDebugTools />
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use client';

export default function Error({ error, reset }: { error: Error; reset: () => void }) {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Error (/server-component)</h2>
<button onClick={() => reset()}>Reset</button>
Error: {error.toString()}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default async function Layout({ children }: { children: React.ReactNode }) {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h1>Layout (/server-component)</h1>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default async function Loading() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Loading (/server-component)</h2>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function NotFound() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Not found (/server-component)</h2>;
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ClientErrorDebugTools } from '../../components/client-error-debug-tools';

export const dynamic = 'force-dynamic';

export default function Page() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Page (/server-component)</h2>
<ClientErrorDebugTools />
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use client';

export default function Error({ error, reset }: { error: Error; reset: () => void }) {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Error (/server-component/[...parameters])</h2>
<button onClick={() => reset()}>Reset</button>
Error: {error.toString()}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default async function Layout({ children }: { children: React.ReactNode }) {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h1>Layout (/server-component/[...parameters])</h1>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default async function Loading() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Loading (/server-component/[...parameters])</h2>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function NotFound() {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Not found (/server-component/[...parameters])</h2>;
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ClientErrorDebugTools } from '../../../../components/client-error-debug-tools';

export const dynamic = 'force-dynamic';

export default async function Page({ params }: { params: Record<string, string> }) {
return (
<div style={{ border: '1px solid lightgrey', padding: '12px' }}>
<h2>Page (/server-component/[...parameters])</h2>
<p>Params: {JSON.stringify(params['parameters'])}</p>
<ClientErrorDebugTools />
</div>
);
}
Loading