diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index 8b2f8ba..0346bcd 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -9,7 +9,7 @@ permissions: contents: read jobs: - experiment: + browser-check: runs-on: ubuntu-24.04 timeout-minutes: 10 steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index e64b277..177e580 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ * Expanded the synthetic corpus to six cases: blog 100, legacy 60, shop 45, settings 40, sign-in 80 and invoice 40; mean 60.8/100, 2/6 at the 80 threshold. Each fixture records the contract fields inference cannot establish. * Recorded a maintainer-run Codex CLI 0.145.0 protocol check with synthetic data; an independent outside report remains open. -* Audited the experiment by keyboard, fixed redundant live-region writes while preserving repeated error announcements, and added `npm run test:browser` with a Chrome CI workflow for tab order, focus, scene selection, approval, reduced motion and narrow layouts. +* Audited the experiment by keyboard, fixed redundant live-region writes while preserving repeated error announcements, and added `npm run test:browser` with a Chrome CI workflow for playground tab order, focus, experiment journeys, film playback, reduced motion and narrow layouts. * Inference now ignores inert template and textarea markup. The probe recognizes an equivalent root allow rule before capping a robots.txt disallow, and private-host screening rejects mapped, translated, NAT64, site-local and reserved IPv6 literals. * Added a daily maintainer guide, a scoped work queue and standalone coding assistant instructions. * Added `npm run dev` and `npm run check:quick`; full package and bundle verification remains required before merging. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 27e326e..8c1fd5c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -82,12 +82,13 @@ Inspect the actual request and result. Verify keyboard operation, mobile layout, reduced motion and no browser errors. Never connect these fixture approvals to real accounts or payment providers. -`npm run test:browser` runs those DOM primitives in headless Google Chrome: -tab order and focus outlines, scene selection, status writes, cancelled review, -all three action journeys, inspector focus and Escape, reduced motion, and -640/390px overflow. Set `CHROME_PATH` if Chrome is not in its default location. -It is a separate CI job because it needs a real browser. It does not replace the -manual checks or establish screen-reader behavior. +`npm run test:browser` runs the experiment and film DOM primitives in headless +Google Chrome: tab order and focus outlines, film playback and disclosure, +scene selection, status writes, cancelled review, all three experiment +journeys, inspector focus and Escape, reduced motion, and 640/390px overflow. +Set `CHROME_PATH` if Chrome is not in its default location. It is a separate CI +job because it needs a real browser. It does not replace the manual checks or +establish screen-reader behavior. ## Desktop distribution diff --git a/MAINTAINING.md b/MAINTAINING.md index a2a13ee..803627b 100644 --- a/MAINTAINING.md +++ b/MAINTAINING.md @@ -52,7 +52,7 @@ that order. | Types and approval declarations | `src/panel-schema.mjs`, `test/panel.test.mjs` | `node --test test/panel.test.mjs test/foundation.test.mjs` | | Corpus evidence | `examples/corpus/`, `src/score.mjs` | `node --test test/corpus.test.mjs test/score.test.mjs` | | Sign in, invoice, settings | `playground/comparison.mjs`, `playground/experiment-model.mjs` | `npm run experiment` and `node --test test/comparison.test.mjs test/experiment.test.mjs` | -| Visual experience | `playground/art.mjs`, `app.mjs`, `experiment.mjs`, CSS | `npm run dev`, then the checks in [CONTRIBUTING.md](CONTRIBUTING.md); `npm run test:browser` locks the experiment primitives in headless Chrome | +| Visual experience | `playground/art.mjs`, `app.mjs`, `experiment.mjs`, CSS | `npm run dev`, then the checks in [CONTRIBUTING.md](CONTRIBUTING.md); `npm run test:browser` locks the experiment and film primitives in headless Chrome | | MCP tools | `src/toolkit.mjs`, `src/mcp-server.mjs` | `npm run test:mcp` | | Distribution | `scripts/check-package.mjs`, `scripts/build-bundle.mjs`, workflows | `npm run check` | @@ -66,7 +66,7 @@ including fresh downloads, package installation and bundle extraction. Create a branch, keep the scope clear and commit the reviewed files. Push the branch and open a pull request using GitHub or `gh pr create`. Include the problem, new behavior, verification and the next task. Wait for all CI jobs: Linux with -Node 22 and 24, Windows with Node 24, and the headless Chrome experiment check. +Node 22 and 24, Windows with Node 24, and the headless Chrome playground check. Do not merge a failing job by reclassifying it as a local environment problem. After merging, GitHub Pages builds and deploys from main. Check the `playground` diff --git a/package.json b/package.json index cee7d0d..77156c7 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "mcp": "node src/mcp-server.mjs", "mcp:config": "node scripts/client-config.mjs", "test:mcp": "node scripts/check-mcp.mjs", - "test:browser": "node scripts/build-playground.mjs && node scripts/check-experiment-browser.mjs", + "test:browser": "node scripts/build-playground.mjs && node scripts/check-playground-browser.mjs", "release:prepare": "node scripts/prepare-release.mjs", "test:package": "node scripts/check-package.mjs", "test:unit": "node --test test/*.test.mjs", diff --git a/scripts/check-experiment-browser.mjs b/scripts/check-playground-browser.mjs similarity index 75% rename from scripts/check-experiment-browser.mjs rename to scripts/check-playground-browser.mjs index 36928e2..fb5626b 100644 --- a/scripts/check-experiment-browser.mjs +++ b/scripts/check-playground-browser.mjs @@ -44,10 +44,18 @@ const focus = page => page.evaluate(() => ({ insideDialog: Boolean(document.activeElement.closest?.('dialog')), })); const feedback = page => page.textContent('#feedback'); +const filmState = page => page.evaluate(() => ({ + label: document.querySelector('#playback').getAttribute('aria-label'), + phase: document.querySelector('#film').dataset.phase, + paused: document.querySelector('#film').classList.contains('paused'), + hidden: document.querySelector('#demo-details').hidden, + expanded: document.querySelector('#info').getAttribute('aria-expanded'), + scenes: document.querySelectorAll('#film .scene').length, + described: [...document.querySelectorAll('#film .scene')] + .every(figure => figure.getAttribute('role') === 'img' && (figure.getAttribute('aria-label') || '').length > 0), +})); const waitPhase = (page, phase) => page.waitForFunction( value => document.querySelector('#stage').dataset.phase === value, phase); -const waitFeedback = (page, message) => page.waitForFunction( - value => document.querySelector('#feedback').textContent === value, message); const waitIdle = page => page.waitForFunction( () => !document.querySelector('#run').disabled && !document.querySelector('#invalid').disabled); @@ -286,7 +294,81 @@ async function main() { } assert.deepEqual(pageErrors, []); - console.log('Browser experiment check passed: tab order, focus outlines, scene selection, status announcements, cancelled review, three action journeys, dialog focus, reduced motion and 640/390 layout.'); + + // Film playback, disclosure and reduced-motion primitives. + await page.setViewportSize({ width: 1280, height: 800 }); + await page.emulateMedia({ reducedMotion: 'no-preference' }); + const filmUrl = new URL('index.html', url).href; + await page.goto(filmUrl); + await page.waitForFunction(() => document.querySelectorAll('#film .scene').length === 3); + const initialFilm = await filmState(page); + assert.equal(initialFilm.scenes, 3); + assert.equal(initialFilm.described, true); + assert.equal(initialFilm.label, 'Pause animation'); + assert.equal(initialFilm.paused, false); + assert.equal(initialFilm.hidden, true); + assert.equal(initialFilm.expanded, 'false'); + + await page.locator('#playback').focus(); + await page.keyboard.press('Enter'); + assert.equal((await filmState(page)).label, 'Play animation'); + assert.equal((await filmState(page)).paused, true); + await page.keyboard.press('Enter'); + assert.equal((await filmState(page)).label, 'Pause animation'); + assert.equal((await filmState(page)).paused, false); + + await page.locator('#info').focus(); + await page.keyboard.press('Enter'); + assert.equal(await page.evaluate(() => document.querySelector('#demo-details').hidden), false); + assert.equal(await page.getAttribute('#info', 'aria-expanded'), 'true'); + await page.keyboard.press('Escape'); + assert.equal(await page.evaluate(() => document.querySelector('#demo-details').hidden), true); + assert.equal(await page.getAttribute('#info', 'aria-expanded'), 'false'); + assert.equal((await filmState(page)).paused, true); + + await page.locator('#replay').focus(); + await page.keyboard.press('Enter'); + const replayed = await filmState(page); + assert.equal(replayed.paused, false); + assert.equal(replayed.label, 'Pause animation'); + assert.equal(replayed.phase, '0'); + + // Film tab order and focus outlines. + await page.goto(filmUrl); + await page.waitForFunction(() => document.querySelectorAll('#film .scene').length === 3); + const filmTabOrder = []; + for (let index = 0; index < 6; index++) { + await page.keyboard.press('Tab'); + filmTabOrder.push(await page.evaluate(() => { + const element = document.activeElement; + const style = getComputedStyle(element); + return { + label: element.getAttribute('aria-label') || (element.textContent || '').trim() || element.id, + outline: `${style.outlineStyle} ${style.outlineWidth}`, + }; + })); + } + assert.deepEqual(filmTabOrder.map(entry => entry.label), [ + 'Hardwire home', 'Try it ↗', 'Pause animation', 'Replay animation', 'About this illustration', 'Hardwire on GitHub', + ]); + assert.ok(filmTabOrder.every(entry => entry.outline === 'solid 2px'), JSON.stringify(filmTabOrder)); + + // Reduced motion starts on the frozen result, and replay stays paused. + await page.emulateMedia({ reducedMotion: 'reduce' }); + await page.goto(filmUrl); + await page.waitForFunction(() => document.querySelectorAll('#film .scene').length === 3); + const reducedFilm = await filmState(page); + assert.equal(reducedFilm.label, 'Play animation'); + assert.equal(reducedFilm.paused, true); + assert.equal(reducedFilm.phase, '3'); + await page.locator('#replay').focus(); + await page.keyboard.press('Enter'); + const reducedReplay = await filmState(page); + assert.equal(reducedReplay.paused, true); + assert.equal(reducedReplay.phase, '3'); + + assert.deepEqual(pageErrors, []); + console.log('Browser playground check passed: tab order, focus, experiment journeys and dialog, film playback and disclosure, reduced motion and 640/390 layout.'); } finally { await browser?.close(); await new Promise(resolve => server.close(resolve));