Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/footer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,26 @@ test.describe('Site footer', () => {
await expect(footers).toContainText('Β©');
await expect(footers).toContainText(String(currentYear));
});

// The footer <nav aria-label="Footer"> exposes links whose accessible names
// (About/Contact/FAQ) collide with the navbar's, so scope to the footer landmark.
const footerLinks = [
{ name: 'About', path: '/about', heading: 'About Us' },
{ name: 'Contact', path: '/contact', heading: 'Contact Us' },
{ name: 'FAQ', path: '/faq', heading: 'Frequently Asked Questions' },
];

for (const { name, path, heading } of footerLinks) {
test(`footer ${name} link navigates to ${path}`, async ({ page }) => {
await page.goto('/');

const footerNav = page
.getByRole('contentinfo')
.getByRole('navigation', { name: 'Footer' });
await footerNav.getByRole('link', { name }).click();

await expect(page).toHaveURL(new RegExp(`${path}$`));
await expect(page.getByRole('heading', { name: heading, level: 1 })).toBeVisible();
});
}
});
9 changes: 9 additions & 0 deletions tests/specs/test-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ Sample Web App β€” a React application with React Router that provides routes su
Expectation: The same footer is still visible with the same current-year copyright text (confirms it renders globally, even on unmatched routes)
3. Step: Navigate to / and query the `contentinfo` landmark role
Expectation: Exactly one `contentinfo` landmark exists, and it contains both the `Β©` symbol and the current year (accessibility landmark uniqueness check)
15. **Footer navigation links route to About, Contact, and FAQ** β€” `tests/footer.spec.ts`
- Preconditions: None β€” the footer `<nav aria-label="Footer">` is a global component rendered on every route; nothing to create or clean up. Footer links are scoped to the `contentinfo` landmark because the navbar exposes links with the same accessible names (About/Contact/FAQ).
- Step/Expectation Pairs:
1. Step: Navigate to / and, within the footer nav (`getByRole('contentinfo').getByRole('navigation', { name: 'Footer' })`), click the "About" link
Expectation: URL changes to /about and the "About Us" heading (level 1) is visible
2. Step: Navigate to / and click the footer "Contact" link (same footer-scoped locator)
Expectation: URL changes to /contact and the "Contact Us" heading (level 1) is visible
3. Step: Navigate to / and click the footer "FAQ" link (same footer-scoped locator)
Expectation: URL changes to /faq and the "Frequently Asked Questions" heading (level 1) is visible


### Feedback
Expand Down