📌 Description
src/context/ThemeContext.tsx subscribes to
matchMedia('(prefers-color-scheme: dark)') and only auto-switches when the
user has not stored an explicit theme. The existing theme tests (per the title
list) cover persistence and attribute sync, but the OS-preference change
listener and its "respect manual override" guard are easy to regress and
deserve direct coverage.
This issue adds tests for the media-query listener.
🎯 Requirements and Context
- Mock
matchMedia with a controllable change dispatcher.
- With no stored theme, assert a system
change to dark updates the theme.
- With a stored theme, assert a system
change is ignored.
- Assert the listener is removed on unmount (no leak / no late updates).
🛠️ Suggested Execution
1. Fork the repo and create a branch
git checkout -b test/theme-context-system-listener
2. Implement changes
- Add
src/context/__tests__/ThemeContext.systemListener.test.tsx (or extend
the existing theme test).
- Provide a
matchMedia mock exposing addEventListener/removeEventListener.
3. Test and commit
- Run:
npm run test
- Edge cases: stored vs unstored theme, unmount before change, repeated changes.
Example commit message
test: cover ThemeContext system-preference change listener
✅ Guidelines
- Minimum 95% test coverage on the touched lines.
- No regressions in theme auto-switching.
- Keep the diff small and reviewer-friendly.
- Timeframe: 96 hours.
🏷️ Labels
type-testing · area-frontend · MAYBE REWARDED · GRANTFOX OSS · OFFICIAL CAMPAIGN
💬 Community & Support
- Join the contributor Discord to coordinate, ask questions, and get unblocked
fast: https://discord.gg/xvNAvMJf
- Please introduce yourself in the channel before you start so we can avoid
duplicate work, pair you with a reviewer, and get your PR merged quickly.
- Maintainers actively triage this channel and aim for fast, clear, respectful
reviews — reach out any time you're blocked.
📌 Description
src/context/ThemeContext.tsxsubscribes tomatchMedia('(prefers-color-scheme: dark)')and only auto-switches when theuser has not stored an explicit theme. The existing theme tests (per the title
list) cover persistence and attribute sync, but the OS-preference change
listener and its "respect manual override" guard are easy to regress and
deserve direct coverage.
This issue adds tests for the media-query listener.
🎯 Requirements and Context
matchMediawith a controllablechangedispatcher.changeto dark updates the theme.changeis ignored.🛠️ Suggested Execution
1. Fork the repo and create a branch
2. Implement changes
src/context/__tests__/ThemeContext.systemListener.test.tsx(or extendthe existing theme test).
matchMediamock exposingaddEventListener/removeEventListener.3. Test and commit
npm run testExample commit message
✅ Guidelines
🏷️ Labels
type-testing·area-frontend·MAYBE REWARDED·GRANTFOX OSS·OFFICIAL CAMPAIGN💬 Community & Support
fast: https://discord.gg/xvNAvMJf
duplicate work, pair you with a reviewer, and get your PR merged quickly.
reviews — reach out any time you're blocked.