Completes the front-end shell with footer, status pages and SEO
Adds the footer, back-to-top button, skip link, placeholder routes, 404 and error pages inside the shell, plus per-page SEO from a single page registry (canonical URLs, Open Graph image, JSON-LD, generated sitemap.xml and robots.txt). Theme tokens and recipes replace repeated styling, the hero loads only the active and neighbouring slides, and the e-mail address is joined in the browser to keep it out of the HTML and bundle. Adds Vitest with property-based (fast-check) and axe tests, ESLint, security headers for dev and preview, Lighthouse CI and a `pnpm check` script that runs all quality gates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
import { screen, within } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import siteContent from '@/content/siteContent';
|
||||
import type { SiteContent } from '@/content/types';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import Footer from './Footer';
|
||||
|
||||
const renderFooter = (content: SiteContent = siteContent, path = '/') =>
|
||||
renderWithProviders(<Footer content={content} />, { path });
|
||||
|
||||
describe('Footer', () => {
|
||||
it('toont merk, socials en contact met h2-koppen', async () => {
|
||||
const { container } = await renderFooter();
|
||||
expect(
|
||||
screen.getByRole('img', { name: 'Andrea Slop Fotografie' }),
|
||||
).toBeInTheDocument();
|
||||
// Regelafbreking uit de content blijft in de tekst staan
|
||||
expect(
|
||||
screen.getByText(siteContent.footerIntro, {
|
||||
normalizer: (text) => text,
|
||||
}),
|
||||
).toHaveStyle({ whiteSpace: 'pre-line' });
|
||||
const headings = screen.getAllByRole('heading', { level: 2 });
|
||||
// Naam in gewone schrijfwijze, los van de CSS-hoofdletters
|
||||
expect(headings.map((h) => h.getAttribute('aria-label'))).toEqual([
|
||||
'Socials',
|
||||
'Contact',
|
||||
]);
|
||||
expect(headings.map((h) => h.textContent)).toEqual([
|
||||
'Socials',
|
||||
'Contact',
|
||||
]);
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('opent socials veilig in een nieuw tabblad en meldt dat', async () => {
|
||||
await renderFooter();
|
||||
const link = screen.getByRole('link', {
|
||||
name: 'Facebook (opent in nieuw tabblad)',
|
||||
});
|
||||
expect(link).toHaveAttribute('target', '_blank');
|
||||
expect(link).toHaveAttribute('rel', 'noopener noreferrer');
|
||||
expect(link).toHaveAttribute('href', siteContent.socials[0].href);
|
||||
});
|
||||
|
||||
it('voegt het e-mailadres pas bij het tonen samen', async () => {
|
||||
await renderFooter();
|
||||
const link = screen.getByTestId('footer-email-link');
|
||||
expect(link).toHaveAttribute('href', 'mailto:info@andreaslop.nl');
|
||||
expect(link).toHaveTextContent('info@andreaslop.nl');
|
||||
});
|
||||
|
||||
it('toont het huidige jaar', async () => {
|
||||
await renderFooter();
|
||||
expect(
|
||||
screen.getByText(
|
||||
`© ${new Date().getFullYear()} Andrea Slop Fotografie`,
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('heeft een footermenu dat de actieve pagina markeert', async () => {
|
||||
await renderFooter(siteContent, '/portfolio');
|
||||
const nav = screen.getByRole('navigation', { name: 'Footermenu' });
|
||||
const links = within(nav).getAllByRole('link');
|
||||
expect(links.map((l) => l.textContent)).toEqual([
|
||||
'Portfolio',
|
||||
'Soorten fotoshoots',
|
||||
'Contact',
|
||||
'Privacyverklaring',
|
||||
]);
|
||||
expect(links[0]).toHaveAttribute('aria-current', 'page');
|
||||
expect(links[1]).not.toHaveAttribute('aria-current');
|
||||
});
|
||||
|
||||
it('laat lege kolommen weg', async () => {
|
||||
await renderFooter({
|
||||
...siteContent,
|
||||
socials: [{ platform: 'facebook', href: '' }],
|
||||
email: { user: '', domain: 'andreaslop.nl' },
|
||||
});
|
||||
expect(screen.queryByRole('heading', { name: 'Socials' })).toBeNull();
|
||||
expect(screen.queryByRole('heading', { name: 'Contact' })).toBeNull();
|
||||
expect(screen.queryByTestId('footer-email-link')).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user