-
Notifications
You must be signed in to change notification settings - Fork 5
Add tests for the theme helper and ThemeToggle component #16
Copy link
Copy link
Labels
GRANTFOX OSSGrantFox open-source campaign taskGrantFox open-source campaign taskMAYBE REWARDEDMay be rewarded under the GrantFox campaignMay be rewarded under the GrantFox campaignOFFICIAL CAMPAIGNOfficial GrantFox campaign issueOfficial GrantFox campaign issuearea:testingtestingtestingpriority:mediumMedium priorityMedium prioritystack:reactReactReactstack:typescriptTypeScriptTypeScripttype:testTest coverage workTest coverage work
Metadata
Metadata
Assignees
Labels
GRANTFOX OSSGrantFox open-source campaign taskGrantFox open-source campaign taskMAYBE REWARDEDMay be rewarded under the GrantFox campaignMay be rewarded under the GrantFox campaignOFFICIAL CAMPAIGNOfficial GrantFox campaign issueOfficial GrantFox campaign issuearea:testingtestingtestingpriority:mediumMedium priorityMedium prioritystack:reactReactReactstack:typescriptTypeScriptTypeScripttype:testTest coverage workTest coverage work
Type
Fields
Give feedbackNo fields configured for Feature.
Test the theme helpers and ThemeToggle behaviour
Description
src/lib/theme.ts(read/write/effective theme withmatchMedia) andsrc/components/ThemeToggle.tsx(which toggles thedarkclass ondocumentElement) have no tests. Regressions here silently break dark mode across every page. This issue adds coverage for both.Requirements and context
Agentpay-Org/Agentpay-frontendonly.theme.ts: assertreadThemevalidates the stored value,writeThemepersists, andeffectiveTheme("system")follows a mockedmatchMedia.ThemeToggle: mocklocalStorageandmatchMedia, assert the three buttons render,aria-pressedreflects the active theme, and clicking togglesdocumentElement.classList.window.matchMediain the test setup since jsdom lacks it.Suggested execution
git checkout -b test/testing-17-themesrc/lib/__tests__/theme.test.tsandsrc/components/__tests__/ThemeToggle.test.tsx.matchMediapolyfill, note it injest.setup.ts.role="group"witharia-label="Theme"is reachable.Test and commit
npm run lint,npm run typecheck, andnpm test.system, SSR guards (typeof window === "undefined"), and dark-preference media query.npm testoutput and coverage for the two modules.Example commit message
test(theme): cover theme helpers and ThemeToggle dark-mode wiringGuidelines
Community & contribution rewards