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,67 @@
|
||||
import { fireEvent, screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import heroContent from '@/content/heroContent';
|
||||
import siteContent from '@/content/siteContent';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import Hero from './Hero';
|
||||
|
||||
describe('Hero', () => {
|
||||
it('toont alleen geldige socials, met melding over het nieuwe tabblad', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
<Hero
|
||||
content={heroContent}
|
||||
socials={[
|
||||
...siteContent.socials,
|
||||
{ platform: 'facebook', href: 'javascript:alert(1)' },
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
const links = screen.getAllByRole('link', {
|
||||
name: /opent in nieuw tabblad/,
|
||||
});
|
||||
expect(links).toHaveLength(2);
|
||||
expect(links[0]).toHaveAccessibleName(
|
||||
'Facebook (opent in nieuw tabblad)',
|
||||
);
|
||||
expect(links[0]).toHaveAttribute('rel', 'noopener noreferrer');
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('laadt eerst de eerste foto, daarna alleen de volgende en vorige', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
<Hero content={heroContent} socials={siteContent.socials} />,
|
||||
);
|
||||
const sources = () =>
|
||||
[...container.querySelectorAll('img')].map((img) =>
|
||||
img.getAttribute('src'),
|
||||
);
|
||||
const slide = (i: number) => heroContent.slides[i].src;
|
||||
const last = heroContent.slides.length - 1;
|
||||
|
||||
expect(sources()).toEqual([slide(0)]);
|
||||
fireEvent.load(container.querySelector('img')!);
|
||||
// Vanaf de eerste foto is de vorige de laatste
|
||||
await waitFor(() =>
|
||||
expect(sources()).toEqual([slide(0), slide(1), slide(last)]),
|
||||
);
|
||||
|
||||
await userEvent.click(
|
||||
screen.getByRole('button', { name: 'Volgende foto' }),
|
||||
);
|
||||
expect(sources()).toEqual([slide(0), slide(1), slide(2)]);
|
||||
});
|
||||
|
||||
it('heeft pijlen met een toegankelijke naam', async () => {
|
||||
await renderWithProviders(
|
||||
<Hero content={heroContent} socials={siteContent.socials} />,
|
||||
);
|
||||
expect(
|
||||
screen.getByRole('button', { name: 'Vorige foto' }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('button', { name: 'Volgende foto' }),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user