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.
This commit is contained in:
2025-11-16 19:38:46 +01:00
parent 14e5839476
commit c9f4772196
5 changed files with 377 additions and 4 deletions

View File

@@ -3,7 +3,7 @@
* Tests for the new FastNext Template landing page
*/
import { render, screen, within } from '@testing-library/react';
import { render, screen, within, fireEvent } from '@testing-library/react';
import Home from '@/app/page';
// Mock Next.js components
@@ -244,6 +244,36 @@ describe('HomePage', () => {
});
});
describe('Demo Modal', () => {
it('demo modal is initially closed', () => {
render(<Home />);
expect(screen.queryByTestId('demo-modal')).not.toBeInTheDocument();
});
it('opens demo modal when Try Demo button is clicked in header', () => {
render(<Home />);
const tryDemoButtons = screen.getAllByRole('button', { name: /try demo/i });
// Click the first Try Demo button (from header)
fireEvent.click(tryDemoButtons[0]);
expect(screen.getByTestId('demo-modal')).toBeInTheDocument();
});
it('closes demo modal when close button is clicked', () => {
render(<Home />);
// Open the modal
const tryDemoButtons = screen.getAllByRole('button', { name: /try demo/i });
fireEvent.click(tryDemoButtons[0]);
expect(screen.getByTestId('demo-modal')).toBeInTheDocument();
// Close the modal
const closeButtons = screen.getAllByRole('button', { name: /close/i });
const modalCloseButton = closeButtons.find(btn => btn.textContent === 'Close');
if (modalCloseButton) {
fireEvent.click(modalCloseButton);
}
});
});
describe('Accessibility', () => {
it('has proper heading hierarchy', () => {
render(<Home />);