Skip to content

Commit 46283be

Browse files
authored
test(validation): check query validation boundaries for theme param (JhaSourav07#1890)
## Description Fixes JhaSourav07#1455 Program: GSSoC 2026 This PR handles the implementation of validation boundary unit testing for the incoming `?theme=` query parameter under variation 4. Previously, normal custom color overrides and known presets were evaluated, but unknown string assignments required isolated boundary test coverage to guarantee system stability. ### 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 boundary validation layer processes the unknown string parameter safely without crashing, validating alignment with application defaults. ### Why this matters Secures internal configuration mapping engines against structural failures when handling undefined aesthetic descriptors, guaranteeing that arbitrary text payloads degrade gracefully to standard themes. --- ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) --- ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`npm run test`). - [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): ...`). - [x] 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. - [x] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [x] (Recommended) I joined the CommitPulse Discord server for faster collaboration, mentorship, and PR support.
2 parents a9b3c35 + ba9ce48 commit 46283be

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

lib/validations.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,15 @@ describe('ogParamsSchema', () => {
675675
const result = ogParamsSchema.parse({});
676676
expect(result.user).toBe('unknown');
677677
});
678+
679+
it('should fallback to "dark" when an invalid theme is provided', () => {
680+
const result = ogParamsSchema.safeParse({ theme: 'nonexistent_theme_name' });
681+
682+
expect(result.success).toBe(true);
683+
if (result.success) {
684+
expect(result.data.theme).toBe('dark');
685+
}
686+
});
678687
});
679688

680689
describe('streakParamsSchema — view fallback behavior', () => {

0 commit comments

Comments
 (0)