test(api-compare): verify dark and light prefers-color-scheme visual cohesion #4431 - #5746
Conversation
|
@Rakshak05 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
📦 Next.js Bundle Size Report (Gzipped Sizes)✨ No significant bundle size changes detected. 📊 Summary of Totals
|
Aamod007
left a comment
There was a problem hiding this comment.
I reviewed the PR title/description, linked issue #4431, checks, and the diff before labeling.
Labels applied:
level:intermediate: the newapp/api/compare/route.theme-contrast.test.tsfile is a fairly large 208-line route test suite covering multiple success and error branches.quality:clean: the test cases are organized by concern and thegetFullDashboardDatamock keeps the route behavior isolated.type:testing: the PR is dedicated test coverage for the compare route.type:design: the assertions are explicitly about theme contrast, style tokens, and client-hint-driven visual cohesion.
I’m leaving this as a neutral comment rather than approving because the repo checks are green but the PR still carries a failing Vercel status context. That looks like a deployment integration/auth issue rather than a code failure.
To unblock it, the Vercel GitHub integration for the repo/team needs to be re-authorized or the status needs to be marked non-blocking by maintainers. Once the Vercel context is green, this can be reviewed normally.
Aamod007
left a comment
There was a problem hiding this comment.
This test file is doing useful work for �pp/api/compare/route.theme-contrast.test.ts. The mocked theme paths, error-status coverage, and payload equality checks give the route a clear guardrail against theme-sensitive regressions.
|
🎉 Congratulations @Rakshak05! Your PR has been successfully merged. 🚀 Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.
Keep building! 💻✨ |
…visual cohesion JhaSourav07#4431 (JhaSourav07#5746) Closes JhaSourav07#4431 ## Description This PR introduces isolated unit and integration testing targeting **Dark and Light Prefers-Color-Scheme Visual Cohesion** for the comparison API route (`app/api/compare/route.ts`). Specifically, it creates the new test file `app/api/compare/route.theme-contrast.test.ts` implementing the following 5 test cases: 1. **Dual-theme environment mock**: Mocks `window.matchMedia` for both dark and light settings to verify that the JSON response payload carries no hardcoded color tokens (hex values, rgb/rgba, or Tailwind color classes). 2. **Color contrast validation**: Asserts that all simulated API error responses (404, 403, 500, 502) contain only plain text and do not smuggle presentation-level styles (such as ANSI escape codes, style/class attributes, or zero-width characters) that would break client-side contrast enforcement. 3. **Tailwind/stylesheet class checks**: Checks that the response headers carry no custom presentational headers (e.g., `X-Theme` or `X-Color-Scheme`) and that Content-Type is strictly `application/json`, leaving theme styling controls fully to the client. 4. **Background overlay check**: Verifies that successful API payloads return fully populated user objects to prevent consuming UI cards from rendering as empty, background-colored overlay containers. 5. **Visual cohesion headers check**: Passes dark and light `Sec-CH-Prefers-Color-Scheme` client headers to verify that the API returns structurally identical payloads in both modes. ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs, testing) ## Visual Preview N/A (Backend / API Tests) ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [ ] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [ ] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have starred the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [ ] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [ ] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
Closes #4431
Description
This PR introduces isolated unit and integration testing targeting Dark and Light Prefers-Color-Scheme Visual Cohesion for the comparison API route (
app/api/compare/route.ts).Specifically, it creates the new test file
app/api/compare/route.theme-contrast.test.tsimplementing the following 5 test cases:window.matchMediafor both dark and light settings to verify that the JSON response payload carries no hardcoded color tokens (hex values, rgb/rgba, or Tailwind color classes).X-ThemeorX-Color-Scheme) and that Content-Type is strictlyapplication/json, leaving theme styling controls fully to the client.Sec-CH-Prefers-Color-Schemeclient headers to verify that the API returns structurally identical payloads in both modes.Pillar
Visual Preview
N/A (Backend / API Tests)
Checklist before requesting a review:
CONTRIBUTING.mdfile.localhost:3000/api/streak?user=YOUR_USERNAME).npm run formatandnpm run lintlocally and resolved all errors (CI will fail otherwise).feat(themes): ...,fix(calculate): ...).README.mdif I added a new theme or URL parameter.