test(ApiPr-insightsRoute-theme-contrast): verify Dark and Light Prefers-Color-Scheme Visual Cohesion#5340
Conversation
…rs-Color-Scheme Visual Cohesion
|
@souravjhahind pls review and add labels |
Aamod-Dev
left a comment
There was a problem hiding this comment.
Thanks for the PR. However, testing 'Visual Cohesion' and 'theme contrast' on a backend API route that only returns JSON data is not a meaningful use of unit tests. The sec-ch-prefers-color-scheme header has no effect on this API, so asserting that the JSON output is identical does not provide any real testing value. Please focus on testing actual business logic (like error handling, data parsing, or the actual GitHub API mock responses) rather than theme contrast for an API route. Please rewrite these tests to cover meaningful API logic.
Labels Applied:
- level:beginner: These are simple mock tests.
- type:testing: Testing PR.
- quality:clean: Code is syntactically fine, but conceptually flawed.
- gssoc:invalid: Conceptually invalid test scenario.
- mentor:Aamod007
Thanks for the feedback you are right, theme contrast doesn't make sense for a JSON API. |
Aamod-Dev
left a comment
There was a problem hiding this comment.
The updated tests now correctly test the business logic, error handling, and parameter validation. Thanks for updating it! Approving.
|
🎉 Congratulations @adityack477! 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! 💻✨ |
Description
Closes #4435
What changed
app/api/pr-insights/route.theme-contrast.test.tswith 5 test casesTest cases
How it works
Since
route.tsis a server-side API with no rendered UI, theme contrast is interpreted as the API being theme-agnostic: it must return identical, well-typed data regardless of the client's color scheme so the frontend can apply correct light/dark contrast styling.fetchPRInsightsto return a deterministic PR insights payloadTests
All 5 new tests pass. All existing tests pass.
Pillar
Visual Preview
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.