Skip to content
Closed
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
14 changes: 2 additions & 12 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import { Toaster } from 'react-hot-toast';
import { createBrowserRouter, RouterProvider } from 'react-router';
import LandingPage from './pages/LandingPage';
import NotFoundPage from './pages/NotFoundPage';
import { routes } from './routes';

const router = createBrowserRouter([
{
path: '/',
element: <LandingPage />,
},
{
path: '*',
element: <NotFoundPage />,
},
]);
const router = createBrowserRouter(routes);

function App() {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/NotFoundPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function NotFoundPage() {
Access Layer
</p>
<h1 className="mt-4 max-w-3xl font-grotesque text-5xl font-black leading-none tracking-tight sm:text-6xl md:text-7xl">
This marketplace path is not live yet.
This marketplace path was not found.
</h1>
<p className="mt-6 max-w-2xl font-jakarta text-base leading-8 text-white/70 sm:text-lg">
The creator key route you opened does not exist. Return to the
Expand Down
36 changes: 26 additions & 10 deletions src/pages/__tests__/NotFoundPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
import { describe, expect, it } from 'vitest';
import { createMemoryRouter, MemoryRouter, RouterProvider } from 'react-router';
import { describe, expect, it, vi } from 'vitest';
import NotFoundPage from '@/pages/NotFoundPage';
import { routes } from '@/routes';

describe('NotFoundPage', () => {
it('points unknown routes back to the marketplace home', () => {
render(
<MemoryRouter initialEntries={['/missing-route']}>
<NotFoundPage />
</MemoryRouter>
);
vi.mock('@/pages/LandingPage', () => ({
default: () => <main>Marketplace home</main>,
}));

const UNKNOWN_ROUTE = '/creator/this-route-does-not-exist';

describe('NotFoundPage routing integration', () => {
it('renders NotFoundPage when the app navigates to an unknown route', () => {
const router = createMemoryRouter(routes, {
initialEntries: [UNKNOWN_ROUTE],
});

render(<RouterProvider router={router} />);

expect(
screen.getByRole('heading', {
name: /this marketplace path is not live yet/i,
name: /not found/i,
})
).toBeInTheDocument();
expect(screen.getByText(/route not found/i)).toBeInTheDocument();
});

it('provides link back to marketplace home', () => {
render(
<MemoryRouter>
<NotFoundPage />
</MemoryRouter>
);

expect(
screen.getByRole('link', { name: /back to marketplace/i })
Expand Down
14 changes: 14 additions & 0 deletions src/routes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { RouteObject } from 'react-router';
import LandingPage from './pages/LandingPage';
import NotFoundPage from './pages/NotFoundPage';

export const routes: RouteObject[] = [
{
path: '/',
element: <LandingPage />,
},
{
path: '*',
element: <NotFoundPage />,
},
];
Loading