clone

a browser grid puzzle game where you push words around to rewrite the rules of each level

test(browser): verify mobile touch and reduced-motion fallback

Dami committed 1c8f65c
commit
1c8f65cc2214ccf3f77cd29e9f827a4c3e1872da
parent
d07ba6d1e88fd93c131bc3f198ba5df565a2f3ff
author
Dami <dami.etoile@gmail.com>
1 file changed, +31 -0
Mtests/browser/share-flow.mjs31++++++++++++++++++++++++++++++
M tests/browser/share-flow.mjs +31 -0
@@ -557,6 +557,37 @@ try {
557557 report('keyboard movement remains available at mobile width');558558 await mobilePage.close();559559 560+ const accessibilityContext = await browser.newContext({561+ viewport: { width: 390, height: 844 },562+ reducedMotion: 'reduce',563+ });564+ await accessibilityContext.route('**/audio/**', route => route.fulfill({ status: 404, body: 'audio unavailable' }));565+ const accessibilityPage = await accessibilityContext.newPage();566+ accessibilityPage.setDefaultTimeout(timeout);567+ const accessibilityErrors = [];568+ accessibilityPage.on('console', message => {569+ if (message.type() === 'error' && !/responded with a status of 404/i.test(message.text())) accessibilityErrors.push(message.text());570+ });571+ accessibilityPage.on('pageerror', error => accessibilityErrors.push(error.message));572+ await accessibilityPage.goto(playerUrl, { waitUntil: 'networkidle' });573+ assert.equal(await accessibilityPage.evaluate(() => matchMedia('(prefers-reduced-motion: reduce)').matches), true, 'reduced motion emulation should be active');574+ assert.equal(await accessibilityPage.locator('.stage-shell').getAttribute('data-scene'), 'title', 'mobile player should start at title');575+ await accessibilityPage.screenshot({ path: `${stageScreenshotDir}/mobile-title.png` });576+ await accessibilityPage.keyboard.press('ArrowRight');577+ assert.equal(await accessibilityPage.locator('.stage-shell').getAttribute('data-scene'), 'title', 'title should accept a single movement key without leaving title');578+ await accessibilityPage.keyboard.press('Enter');579+ await accessibilityPage.waitForFunction(() => document.querySelector('.stage-shell')?.dataset.scene === 'index');580+ await accessibilityPage.screenshot({ path: `${stageScreenshotDir}/mobile-index.png` });581+ const indexCanvas = accessibilityPage.locator('.stage-canvas');582+ const indexBox = await indexCanvas.boundingBox();583+ assert.ok(indexBox, 'mobile INDEX should expose a tappable canvas');584+ await accessibilityPage.mouse.click(indexBox.x + 64, indexBox.y + 374);585+ await accessibilityPage.waitForFunction(() => document.querySelector('.stage-shell')?.dataset.scene === 'proof');586+ report('mobile reduced-motion title key and INDEX touch entry work without audio');587+ assert.deepEqual(accessibilityErrors, [], 'missing audio should not produce browser errors');588+ await accessibilityPage.close();589+ await accessibilityContext.close();590+560591 if (consoleErrors.length) throw new Error(`browser console errors: ${consoleErrors.join('; ')}`);561592 report('no browser console errors');562593 } finally {