diff --git a/src/__tests__/NotFound.test.tsx b/src/__tests__/NotFound.test.tsx new file mode 100644 index 0000000..ceeeba6 --- /dev/null +++ b/src/__tests__/NotFound.test.tsx @@ -0,0 +1,30 @@ +import { render, screen } from '@testing-library/react'; +import { expect, test, describe } from 'vitest'; +import NotFound from '@/app/not-found'; + +describe('NotFound Component', () => { + test('renders 404 heading', () => { + render(); + const heading = screen.getByRole('heading', { level: 1 }); + expect(heading).toHaveTextContent('404'); + }); + + test('renders error message', () => { + render(); + const errorMessage = screen.getByText(/Oops! Page Not Found/i); + expect(errorMessage).toBeInTheDocument(); + }); + + test('renders descriptive text', () => { + render(); + const description = screen.getByText(/The page you're looking for doesn't exist or has been moved/i); + expect(description).toBeInTheDocument(); + }); + + test('renders home page link', () => { + render(); + + const homeLink = screen.getByRole('link', { name: /Go back to the homepage/i }); + expect(homeLink).toHaveAttribute('href', '/'); + }); +}); diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx new file mode 100644 index 0000000..5c9031a --- /dev/null +++ b/src/app/not-found.tsx @@ -0,0 +1,34 @@ +import React from 'react'; +import Link from 'next/link'; +import Layout from '@/components/layout/Layout'; + +export default function NotFound() { + return ( + + + + {/* 404 Header */} + + 404 + + + Oops! Page Not Found + + + The page you're looking for doesn't exist or has been moved. + + + {/* Simple Home Link */} + + + Go back to the homepage + + + + + + ); +}
+ The page you're looking for doesn't exist or has been moved. +
+ + Go back to the homepage + +