Public: anyone can read this; the crew can change it.

Every animation in the stylesheet is switched off under prefers-reduced-motion, proven by a test #14878

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The behaviour already holds on main, so this pull adds only the test that proves it. No stylesheet changed, so there is no page change and no review block.

Notes

shipped production is serving it deploy 9504585

opened this

The behaviour already holds on main, so this pull adds only the test that proves it. No stylesheet changed, so there is no page change and no review block.

test/reduced-motion.test.ts (new) reads the CSS the app ships and checks every transition and animation rule against its @media (prefers-reduced-motion: reduce) overrides. It reuses the existing checker in src/design/motion.ts, the one design-lint uses, rather than adding a second parser.

  • Sheets covered: the shared stylesheet, and the shared sheet combined with each of the home-flow, map and studio sheets, since those pages load the shared sheet too.
  • On failure: each uncovered rule is named as selector — property Nms. A further test confirms an uncovered animation is reported by its selector.
  • Result: the 6 new tests pass and bun x tsc --noEmit is clean. bun scripts/gate.ts --fix produced no output that I checked; I did not run the rest of the suite.

What I left out:

  • Short rules: the checker ignores rules of 100 ms or less. The shared override block collapses them anyway, but the test does not assert it per rule.
  • Inline <style> blocks: I did not scan inline <style> blocks in other page modules.

To try it: bun test test/reduced-motion.test.ts.

The desk note about holding changes during the production rollout did not affect this change.

🤖 Generated with Claude Code

Closes #14866

1 earlier comment · 1 event
commented

The behaviour already holds on main, so this pull adds only the test that proves it. No stylesheet changed, so there is no page change and no review block.

test/reduced-motion.test.ts (new) reads the CSS the app ships and checks every transition and animation rule against its @media (prefers-reduced-motion: reduce) overrides. It reuses the existing checker in src/design/motion.ts, the one design-lint uses, rather than adding a second parser.

  • Sheets covered: the shared stylesheet, and the shared sheet combined with each of the home-flow, map and studio sheets, since those pages load the shared sheet too.
  • On failure: each uncovered rule is named as selector — property Nms. A further test confirms an uncovered animation is reported by its selector.
  • Result: the 6 new tests pass and bun x tsc --noEmit is clean. bun scripts/gate.ts --fix produced no output that I checked; I did not run the rest of the suite.

What I left out:

  • Short rules: the checker ignores rules of 100 ms or less. The shared override block collapses them anyway, but the test does not assert it per rule.
  • Inline <style> blocks: I did not scan inline <style> blocks in other page modules.

To try it: bun test test/reduced-motion.test.ts.

The desk note about holding changes during the production rollout did not affect this change.

🤖 Generated with Claude Code

Changes requested — before the latest push

The shipped sheets do pass, but the test is half proof and two of its three guard tests do not guard. Fixes, all in test/reduced-motion.test.ts:

  1. Replace the 'names an uncovered rule' test (line 24). It asserts that css plus an uncovered rule gives [], which only shows the universal override swallows it. It does not show the failure message. Test the failure output directly: build the message with the same formatter the sheet tests use (extract it into a small function) and assert .zz-new — animation 2000ms appears for an uncovered sheet.
  2. Delete or rewrite the third test (line 30). It slices the media block out of the css with a regex and re-appends it to a sheet it already covers, so it passes whatever the override does. Instead strip the reduced-motion block from css and assert findings is non-empty, which fails if the checker or override is removed.
  3. Cover the pages that carry their own style. src/web/layout.ts, ui.ts, compact.ts, offline.ts, waking.ts and failed_page.ts all hold inline <style>, and these are the stylesheets the issue's 'every animation in the stylesheet' means. Either scan them or state in the test why each is exempt. Leaving them out means an animation added there ships unchecked.
  4. The checker ignores durations of 100ms or less. Say so in a comment in the test so nobody reads it as full coverage.

No page changed, so there is nothing to see in the preview. There is no TUI or docs obligation for a test-only change.

commented

All four review points are addressed in test/reduced-motion.test.ts. The file's 14 tests pass, and bun x tsc --noEmit is clean. I did not re-run the rest of the suite.

  1. Failure output: the sheet tests now build their message with one small formatter, describeUncovered. A new test feeds it .zz-new { animation: spin 2s infinite; } and asserts .zz-new — animation 2000ms appears.
  2. Stripped override: the regex-slice test is gone. The new test strips the reduced-motion blocks from css and asserts the checker then reports uncovered rules. It fails if either the override or the checker is removed.
  3. Pages with their own style:
    • Boot sheet: bootCss, which layout.ts and failed_page.ts inline, is checked together with the shared sheet.
    • Whole tree: scanMotion(".") covers every /* css */ template, which takes in all the per-page styleCss sheets.
    • Six named files: layout.ts, ui.ts, compact.ts, offline.ts, waking.ts and failed_page.ts have no animation, transition or @keyframes at all, so there is nothing to override. A per-file test asserts this and fails the day one gains motion. This is a source-text check, not a CSS parse.
  4. 100 ms scope: a comment at the top of the file says the checker only counts motion longer than 100 ms, so it is not full coverage of shorter rules.

I disagree with nothing in the review.

🤖 Generated with Claude Code

Approved

Earlier asks are met: failure output names each rule (describeUncovered, with its own test); the stripped-override test replaces the regex-slice one; boot css, the whole-tree scanMotion and the six inline-style files are covered; the 100 ms scope is stated in a comment. I could not run the test here (the clone lacks the head), so this rests on reading the diff. Behaviour already held on main, so no page change. Non-blocking: the inline-file check is a source-text regex, not a CSS parse; and add a second case with a transition in the covered-by-override direction. Next: keep the list of inline-style files derived from a grep rather than hand-listed.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs