Announces manual hero slide changes and adds a pause button
Continuous Integration / check (pull_request) Successful in 59s
Continuous Integration / deploy-test (pull_request) Skipped
Continuous Integration / lighthouse (pull_request) Successful in 3m59s
Continuous Integration / deploy-production (pull_request) Skipped

Screen readers now hear the new photo after an arrow or swipe, while automatic
changes stay silent. A pause button bottom right lets visitors stop the slide
show, which hover and keyboard focus alone did not allow on touch screens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-19 19:31:31 +02:00
co-authored by Claude Opus 5.5
parent 8f0f32261c
commit 46fb2f6b5c
11 changed files with 424 additions and 7 deletions
+72
View File
@@ -53,6 +53,78 @@ describe('Hero', () => {
expect(sources()).toEqual([slide(0), slide(1), slide(2)]);
});
describe('meldingen voor schermlezers', () => {
const announcement = () =>
screen.getByTestId('hero-announcement').textContent;
it('meldt een wissel door de bezoeker met nummer en beschrijving', async () => {
await renderWithProviders(
<Hero content={heroContent} socials={siteContent.socials} />,
);
const region = screen.getByTestId('hero-announcement');
expect(region).toHaveAttribute('aria-live', 'polite');
expect(announcement()).toBe('');
await userEvent.click(
screen.getByRole('button', { name: 'Volgende foto' }),
);
expect(announcement()).toBe(
`Foto 2 van ${heroContent.slides.length}: ${heroContent.slides[1].alt}`,
);
await userEvent.click(
screen.getByRole('button', { name: 'Vorige foto' }),
);
expect(announcement()).toBe(
`Foto 1 van ${heroContent.slides.length}: ${heroContent.slides[0].alt}`,
);
});
// Stil blijven bij een automatische wissel: zie useHeroSlider.test.tsx
// (jsdom kent geen animationend voor React)
});
describe('pauzeknop', () => {
it('pauzeert en hervat de diavoorstelling', async () => {
const { container } = await renderWithProviders(
<Hero content={heroContent} socials={siteContent.socials} />,
);
const pause = screen.getByRole('button', {
name: 'Diavoorstelling pauzeren',
});
const progress = () => screen.getByTestId('hero-progress');
expect(progress()).toHaveAttribute('data-state', 'running');
await userEvent.click(pause);
expect(pause).toHaveAccessibleName('Diavoorstelling afspelen');
expect(progress()).toHaveAttribute('data-state', 'paused');
// Blijft gepauzeerd als de muis de hero verlaat
fireEvent.pointerLeave(container.querySelector('section')!);
expect(progress()).toHaveAttribute('data-state', 'paused');
await userEvent.click(pause);
expect(pause).toHaveAccessibleName('Diavoorstelling pauzeren');
expect(progress()).toHaveAttribute('data-state', 'running');
expect(await axeResults(container)).toHaveNoViolations();
});
it('ontbreekt als er niets automatisch wisselt', async () => {
await renderWithProviders(
<Hero
content={{
...heroContent,
slides: heroContent.slides.slice(0, 1),
}}
socials={siteContent.socials}
/>,
);
expect(
screen.queryByRole('button', { name: /Diavoorstelling/ }),
).not.toBeInTheDocument();
});
});
it('heeft pijlen met een toegankelijke naam', async () => {
await renderWithProviders(
<Hero content={heroContent} socials={siteContent.socials} />,