forked from cardosofelipe/fast-next-template
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:
@@ -171,6 +171,70 @@ describe('Header', () => {
|
||||
const githubLinks = screen.getAllByRole('link', { name: /github/i });
|
||||
expect(githubLinks.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('clicking mobile menu navigation links works', () => {
|
||||
render(
|
||||
<Header
|
||||
onOpenDemoModal={function (): void {
|
||||
throw new Error('Function not implemented.');
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
const designSystemLinks = screen.getAllByRole('link', { name: /Design System/i });
|
||||
// Click the mobile menu link (there should be 2: desktop + mobile)
|
||||
if (designSystemLinks.length > 1) {
|
||||
fireEvent.click(designSystemLinks[1]);
|
||||
expect(designSystemLinks[1]).toHaveAttribute('href', '/dev');
|
||||
}
|
||||
});
|
||||
|
||||
it('clicking mobile menu GitHub link works', () => {
|
||||
render(
|
||||
<Header
|
||||
onOpenDemoModal={function (): void {
|
||||
throw new Error('Function not implemented.');
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
const githubLinks = screen.getAllByRole('link', { name: /github/i });
|
||||
// Find the mobile menu GitHub link (second one)
|
||||
if (githubLinks.length > 1) {
|
||||
const mobileGithubLink = githubLinks[1];
|
||||
fireEvent.click(mobileGithubLink);
|
||||
expect(mobileGithubLink).toHaveAttribute('href', expect.stringContaining('github.com'));
|
||||
}
|
||||
});
|
||||
|
||||
it('mobile menu Try Demo button calls onOpenDemoModal', () => {
|
||||
const mockOnOpenDemoModal = jest.fn();
|
||||
render(<Header onOpenDemoModal={mockOnOpenDemoModal} />);
|
||||
|
||||
const tryDemoButtons = screen.getAllByRole('button', { name: /try demo/i });
|
||||
// Click the mobile menu button (there should be 2: desktop + mobile)
|
||||
if (tryDemoButtons.length > 1) {
|
||||
fireEvent.click(tryDemoButtons[1]);
|
||||
expect(mockOnOpenDemoModal).toHaveBeenCalled();
|
||||
}
|
||||
});
|
||||
|
||||
it('mobile menu Login link works', () => {
|
||||
render(
|
||||
<Header
|
||||
onOpenDemoModal={function (): void {
|
||||
throw new Error('Function not implemented.');
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
const loginLinks = screen.getAllByRole('link', { name: /login/i });
|
||||
// Click the mobile menu login link (there should be 2: desktop + mobile)
|
||||
if (loginLinks.length > 1) {
|
||||
fireEvent.click(loginLinks[1]);
|
||||
expect(loginLinks[1]).toHaveAttribute('href', '/login');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Accessibility', () => {
|
||||
|
||||
Reference in New Issue
Block a user