Files
fast-next-template/frontend/tests/app/forbidden/page.test.tsx
Felipe Cardoso c9f4772196 Add and enhance tests for mobile navigation, demo modal, and forbidden page metadata
- Added new test cases for mobile navigation links and buttons in `Header` component.
- Enhanced `Home` tests to verify demo modal behavior (open/close functionality).
- Added metadata validation test for the forbidden page.
- Introduced comprehensive test suite for the DemoTour page, covering structure, navigation, categories, accessibility, and CTAs.
2025-11-16 19:38:46 +01:00

69 lines
2.0 KiB
TypeScript

/**
* Tests for 403 Forbidden Page
* Verifies rendering of access forbidden message and navigation
*/
import { render, screen } from '@testing-library/react';
import ForbiddenPage, { metadata } from '@/app/forbidden/page';
describe('ForbiddenPage', () => {
it('has correct metadata', () => {
expect(metadata).toBeDefined();
expect(metadata.title).toBe('403 - Forbidden');
expect(metadata.description).toBe('You do not have permission to access this resource');
});
it('renders page heading', () => {
render(<ForbiddenPage />);
expect(screen.getByRole('heading', { name: /403 - Access Forbidden/i })).toBeInTheDocument();
});
it('renders permission denied message', () => {
render(<ForbiddenPage />);
expect(
screen.getByText(/You don't have permission to access this resource/)
).toBeInTheDocument();
});
it('renders admin privileges message', () => {
render(<ForbiddenPage />);
expect(screen.getByText(/This page requires administrator privileges/)).toBeInTheDocument();
});
it('renders link to dashboard', () => {
render(<ForbiddenPage />);
const dashboardLink = screen.getByRole('link', {
name: /Go to Dashboard/i,
});
expect(dashboardLink).toBeInTheDocument();
expect(dashboardLink).toHaveAttribute('href', '/dashboard');
});
it('renders link to home', () => {
render(<ForbiddenPage />);
const homeLink = screen.getByRole('link', { name: /Go to Home/i });
expect(homeLink).toBeInTheDocument();
expect(homeLink).toHaveAttribute('href', '/');
});
it('renders shield alert icon with aria-hidden', () => {
const { container } = render(<ForbiddenPage />);
const icon = container.querySelector('[aria-hidden="true"]');
expect(icon).toBeInTheDocument();
});
it('renders with proper container structure', () => {
const { container } = render(<ForbiddenPage />);
const containerDiv = container.querySelector('.container');
expect(containerDiv).toBeInTheDocument();
expect(containerDiv).toHaveClass('mx-auto', 'px-6', 'py-16');
});
});