Skip to content

test(CustomizeTypes): add theme contrast tests#5743

Merged
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
ArchiGajera:test/customizetypes-theme-contrast
Jun 15, 2026
Merged

test(CustomizeTypes): add theme contrast tests#5743
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
ArchiGajera:test/customizetypes-theme-contrast

Conversation

@ArchiGajera

@ArchiGajera ArchiGajera commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds a dedicated Vitest test suite for app/customize/types.ts to verify Dark and Light Prefers-Color-Scheme Visual Cohesion. The implementation includes five isolated and deterministic test cases that validate theme configuration consistency across light and dark modes, ensure expected color-related properties remain intact, verify fallback behavior for optional or missing theme values, and confirm that styling mappings preserve visual cohesion without introducing runtime issues. The production code remains unchanged, no unnecessary mocks were introduced, and the tests are designed to be stable and CI-friendly while satisfying the requirements of verify Dark and Light Prefers-Color-Scheme Visual Cohesion.

Fixes #4458

Pillar

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

Visual Preview

N/A

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.

Copilot AI review requested due to automatic review settings June 15, 2026 07:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a Vitest suite to validate structural correctness and basic visual-contrast invariants for the dark, light, and auto-theme mappings used by the Customize UI/theme system.

Changes:

  • Introduces tests for required theme tokens, hex formatting, and minimum contrast ratios.
  • Adds checks for theme key presence/absence (auto, random) and optional negative handling.
  • Verifies auto-theme light/dark constants align with canonical presets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +115 to +116
expect(AUTO_THEME_LIGHT).toBe(themes.light);
expect(AUTO_THEME_DARK).toBe(themes.dark);
Comment on lines +84 to +95
const partial: Partial<BadgeTheme> = {
bg: 'aabbcc' as HexColor,
text: '112233' as HexColor,
accent: 'ff5500' as HexColor,
// negative intentionally omitted
};

expect(partial.negative).toBeUndefined();

// Accessing the optional property and falling back mirrors production usage
const negativeColor = partial.negative ?? 'ff0000';
expect(negativeColor).toBe('ff0000');
Comment on lines +99 to +100
expect(themes['auto' as string]).toBeUndefined();
expect(themes['random' as string]).toBeUndefined();
Comment on lines +27 to +37
it('dark and light theme presets expose all required color properties and are structurally valid', () => {
for (const key of ['dark', 'light'] as ThemeKey[]) {
const theme = themes[key];
expect(theme).toBeDefined();

// Every required token must be a non-empty string
for (const token of REQUIRED_COLOR_TOKENS) {
expect(theme[token]).toBeDefined();
expect(typeof theme[token]).toBe('string');
expect((theme[token] as string).length).toBeGreaterThan(0);
}
// ────────────────────────────────────────────────────────────────────────
// 2. Minimum contrast between text/accent and background
// ────────────────────────────────────────────────────────────────────────
it('dark and light themes maintain sufficient text-on-background contrast and no required color tokens are missing', () => {
Comment on lines +64 to +67
// No required token may be missing
for (const token of REQUIRED_COLOR_TOKENS) {
expect(theme[token]).toBeDefined();
}
@github-actions

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

✨ No significant bundle size changes detected.

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 3433.84 KB 3433.84 KB 0 B
Total CSS 258.05 KB 258.05 KB 0 B

@ArchiGajera

Copy link
Copy Markdown
Contributor Author

hi ,@JhaSourav07,
I have created a PR and you have accepted it but it has not been merged yet and I cannot claim another issue because of that. please check.

@Aamod007 Aamod007 added level:intermediate Moderate complexity tasks quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:testing Adding, updating, or fixing tests type:design UI designs, styling, SVG icons, and themes mentor:Aamod007 gssoc:approved PR has been reviewed and accepted for valid contribution points labels Jun 15, 2026
@github-actions github-actions Bot added this to the GSSoC 2026 milestone Jun 15, 2026

@Aamod007 Aamod007 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.

Nice focused test coverage. The assertions in app/customize/types.theme-contrast.test.ts line up well with the actual theme helpers: structural checks for themes.dark/themes.light, contrast validation through getLuminance, fallback coverage for optional fields, and the AUTO_THEME_LIGHT/AUTO_THEME_DARK mapping check all make the theme contract clearer without touching production code.

@JhaSourav07 JhaSourav07 merged commit bbbb78f into JhaSourav07:main Jun 15, 2026
18 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Congratulations @ArchiGajera! 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! 💻✨

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:intermediate Moderate complexity tasks mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:design UI designs, styling, SVG icons, and themes type:testing Adding, updating, or fixing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants