Skip to content

test(ApiPr-insightsRoute-theme-contrast): verify Dark and Light Prefers-Color-Scheme Visual Cohesion#5340

Merged
JhaSourav07 merged 3 commits into
JhaSourav07:mainfrom
adityack477:test/api-pr-insights-theme-contrast
Jun 12, 2026
Merged

test(ApiPr-insightsRoute-theme-contrast): verify Dark and Light Prefers-Color-Scheme Visual Cohesion#5340
JhaSourav07 merged 3 commits into
JhaSourav07:mainfrom
adityack477:test/api-pr-insights-theme-contrast

Conversation

@adityack477

@adityack477 adityack477 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #4435

What changed

  • Created new file app/api/pr-insights/route.theme-contrast.test.ts with 5 test cases

Test cases

  1. Returns identical data structure regardless of dark or light prefers-color-scheme header
  2. Returns numeric stat fields suitable for color-coded badges in both themes
  3. Returns highlight fields with title and url required for accessible link contrast styling
  4. Returns consistent error response and Content-Type regardless of theme headers
  5. Returns repoPerformance array with mergeRate values usable for progress bar contrast styling in both themes

How it works

Since route.ts is 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.

  • Mocks fetchPRInsights to return a deterministic PR insights payload
  • Verifies dark vs light prefers-color-scheme headers produce identical JSON responses
  • Confirms numeric stat fields (mergeRate, totalPRs, etc.) used for color-coded badges
  • Checks highlight objects contain title/url needed for accessible link styling
  • Validates error responses are consistent across themes
  • Asserts repoPerformance mergeRate values stay within 0-100 for progress bar rendering

Tests

All 5 new tests pass. All existing tests pass.

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Visual Preview

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • 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.
  • I have started the repo.
  • 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.

@adityack477

Copy link
Copy Markdown
Contributor Author

@souravjhahind pls review and add labels

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Aamod-Dev Aamod-Dev added level:beginner Small changes Usually isolated fixes or simple UI/text updates. type:testing Adding, updating, or fixing tests quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. gssoc:invalid PR is invalid. mentor:Aamod007 labels Jun 12, 2026
@adityack477

Copy link
Copy Markdown
Contributor Author

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.
I have rewritten the test suite to focus on actual business logic in route.ts
Pls review now and let me know if there's anything else you would like adjusted.

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated tests now correctly test the business logic, error handling, and parameter validation. Thanks for updating it! Approving.

@Aamod-Dev Aamod-Dev removed the gssoc:invalid PR is invalid. label Jun 12, 2026
@JhaSourav07 JhaSourav07 added the gssoc:approved PR has been reviewed and accepted for valid contribution points label Jun 12, 2026
@JhaSourav07 JhaSourav07 merged commit 0753222 into JhaSourav07:main Jun 12, 2026
5 checks passed
@github-actions github-actions Bot added this to the GSSoC 2026 milestone Jun 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🎉 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.

⚠️ Important for GSSoC Contributors:
You are strictly advised to join our Discord Server as it is mandatory for all GSSoC participants. All important announcements, point claims, and community discussions happen there.

Keep building! 💻✨

@JhaSourav07 JhaSourav07 added gssoc:approved PR has been reviewed and accepted for valid contribution points and removed gssoc:approved PR has been reviewed and accepted for valid contribution points labels Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved PR has been reviewed and accepted for valid contribution points level:beginner Small changes Usually isolated fixes or simple UI/text updates. mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:testing Adding, updating, or fixing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(ApiPr-insightsRoute-theme-contrast): verify Dark and Light Prefers-Color-Scheme Visual Cohesion (Variation 3)

3 participants