feat: add ErrorPage component with back-to-home link

This commit is contained in:
devcodetools committed 2026-09-13 18:23:24 +02:00
1 parent 8d6d923063
commit e5220a4c4e
3 files changed
+57

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
import { render, screen } from '@testing-library/react'
import { describe, expect, it } from 'vitest'
import ErrorPage from './ErrorPage'
describe('ErrorPage', () => {
it('renders default 404 content', () => {
render(<ErrorPage />)
expect(screen.getByText('404')).toBeInTheDocument()
expect(screen.getByRole('heading', { name: 'Page introuvable' })).toBeInTheDocument()
})
it('renders a link back to the home page', () => {
render(<ErrorPage />)
const link = screen.getByRole('link', { name: "Retour à l'accueil" })
expect(link).toHaveAttribute('href', '/')
})
it('uses custom code, title and message when provided', () => {
render(<ErrorPage code={500} title="Erreur serveur" message="Une erreur est survenue." />)
expect(screen.getByText('500')).toBeInTheDocument()
expect(screen.getByRole('heading', { name: 'Erreur serveur' })).toBeInTheDocument()
expect(screen.getByText('Une erreur est survenue.')).toBeInTheDocument()
})
})