Skip to content

test(validation): check query validation boundaries for theme param#1955

Open
ashishraj1504 wants to merge 1 commit into
JhaSourav07:mainfrom
ashishraj1504:fix/theme-validation-boundaries-1447
Open

test(validation): check query validation boundaries for theme param#1955
ashishraj1504 wants to merge 1 commit into
JhaSourav07:mainfrom
ashishraj1504:fix/theme-validation-boundaries-1447

Conversation

@ashishraj1504
Copy link
Copy Markdown
Contributor

Description

Fixes #1447
Program: GSSoC 2026

This PR handles the implementation of validation boundary unit testing for the incoming ?theme= query parameter under variation 3.

Previously, basic parameter checking was evaluated, but checking extreme bounds for incorrect color hex syntax combinations required isolated boundary test coverage to guarantee input schema safety.

Changes Made

  • Added 1 target schema validation boundary test case inside lib/validations.test.ts.
  • Mocked an invalid parameter payload passing a theme configuration value set to 'nonexistent_theme_name'.
  • Asserted that the system validation layer catches the hex syntax violation and processes it correctly according to the repository's parsing bounds.

Why this matters

Secures internal configuration mapping engines against structural failures when handling malformed custom color styles, guaranteeing that invalid hex inputs cannot compromise SVG output generation parameters.

Pillar

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

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (npm run test).
  • 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 starred 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 server for faster collaboration, mentorship, and PR support.

Copilot AI review requested due to automatic review settings May 31, 2026 05:09
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 31, 2026

@ashishraj1504 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 test verifying that an invalid theme value falls back to 'dark' in ogParamsSchema.

Changes:

  • New test case asserting fallback behavior for unrecognized theme values.

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

Comment thread lib/validations.test.ts Outdated
Comment on lines +700 to +704
it('should parse an invalid theme value back to dark', () => {
const result = ogParamsSchema.parse({ theme: 'nonexistent_theme_name' });

expect(result.theme).toBe('dark');
});
Copy link
Copy Markdown
Collaborator

@Aamod007 Aamod007 left a comment

Choose a reason for hiding this comment

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

This test duplicates the existing should fallback to "dark" when an invalid theme is provided at line 691. Both test theme: 'nonexistent_theme_name' falling back to 'dark', just using .parse() instead of .safeParse(). No new coverage is added.

Please either remove this test or add a theme boundary case that isn't already covered.

@ashishraj1504 ashishraj1504 force-pushed the fix/theme-validation-boundaries-1447 branch from 0a25f0a to 03913e9 Compare May 31, 2026 06:38
@ashishraj1504
Copy link
Copy Markdown
Contributor Author

@Aamod007 , Thank you for the guidance! You're completely right—testing 'nonexistent_theme_name' duplicated line 691.

I have repurposed the test case to target an empty string boundary (theme: '') instead to ensure it adds unique coverage while validating safe fallback behavior. I also updated the block to use .safeParse() for structural consistency with the surrounding test patterns. The suite passes green locally, and I've force-pushed the clean commit up!

@ashishraj1504 ashishraj1504 requested a review from Aamod007 May 31, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(api validation): check query validation boundaries for ?theme= parameter (Variation 3)

3 participants