Files
AndreaSlopFotografie/aidlc-docs/bugs/hero-carousel-announce-and-pause/hero-repro.mjs
T
SluijsensandClaude Opus 5.5 46fb2f6b5c
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
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>
2026-10-19 19:31:31 +02:00

60 lines
2.4 KiB
JavaScript

// Reproductie en verificatie (headless Chrome): meldt de Hero een wissel door
// de bezoeker, blijft hij stil bij een automatische wissel, en is er een
// pauzeknop die werkt?
// Gebruik: node hero-repro.mjs <file-URL van puppeteer-core.js> [url]
const { default: puppeteer } = await import(process.argv[2]);
const url = process.argv[3] ?? 'https://test.andreaslop.nl/';
const wait = (ms) => new Promise((r) => setTimeout(r, ms));
const browser = await puppeteer.launch({
executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe',
headless: true,
});
const page = await browser.newPage();
await page.goto(url, { waitUntil: 'networkidle0' });
// Muis buiten de hero, anders pauzeert hover de slider
await page.mouse.move(0, 0);
const live = () =>
page.$$eval('section[aria-roledescription="carousel"] [aria-live]', (els) =>
els.map((e) => `${e.getAttribute('aria-live')}: "${e.textContent.trim()}"`),
);
const slide = () =>
page.$eval(
'[aria-roledescription="slide"]:not([aria-hidden="true"])',
(e) => e.getAttribute('aria-label'),
);
const buttons = async () => {
const snap = await page.accessibility.snapshot({ interestingOnly: true });
const names = [];
(function walk(n) {
if (n.role === 'button') names.push(n.name);
(n.children || []).forEach(walk);
})(snap);
return names;
};
console.log('1. voor klik | slide:', await slide(), '| live:', JSON.stringify(await live()));
await page.click('[data-testid="hero-next-button"]');
await wait(500);
console.log('2. na pijlklik | slide:', await slide(), '| live:', JSON.stringify(await live()));
await page.mouse.move(0, 0);
await wait(7000);
console.log('3. na autoplay | slide:', await slide(), '| live:', JSON.stringify(await live()));
console.log('4. knoppen |', JSON.stringify(await buttons()));
const pause = await page.$('[data-testid="hero-pause-button"]');
if (pause) {
await pause.click();
await page.mouse.move(0, 0);
const before = await slide();
await wait(7000);
console.log('5. gepauzeerd | slide blijft:', before, '->', await slide(), '| knoppen:', JSON.stringify(await buttons()));
await pause.click();
await page.mouse.move(0, 0);
await wait(7000);
console.log('6. hervat | slide nu:', await slide(), '| knoppen:', JSON.stringify(await buttons()));
} else {
console.log('5. geen pauzeknop');
}
await browser.close();