Announces manual hero slide changes and adds a pause button
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:
@@ -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} />,
|
||||
|
||||
Reference in New Issue
Block a user