test(validation): check query validation boundaries for grace param#1949
test(validation): check query validation boundaries for grace param#1949ashishraj1504 wants to merge 1 commit into
Conversation
|
@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. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a test verifying that streakParamsSchema sanitizes a negative grace input to 0 when parsed via safeParse.
Changes:
- New test case for negative
gracevalue handled throughsafeParse.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| it('sanitizes negative grace input when parsed through the schema', () => { | ||
| const result = streakParamsSchema.safeParse({ | ||
| user: 'octocat', | ||
| grace: '-1', | ||
| }); | ||
|
|
||
| expect(result.success).toBe(true); | ||
|
|
||
| if (result.success) { | ||
| expect(result.data.grace).toBe(0); | ||
| } | ||
| }); |
Aamod007
left a comment
There was a problem hiding this comment.
This test duplicates the existing clamps "-1" to 0 at line 17. Both test grace: '-1' and assert it clamps to 0. The only difference is using safeParse vs the parse() helper — no new coverage is added.
Please either remove this test or add a boundary case that isn't already covered (e.g., testing grace: '0' via safeParse, or testing a negative non-integer value).
698cccf to
cdf8d4e
Compare
|
@Aamod007 , Thank you for the guidance! You're completely right—the third test case duplicated line 17. I have removed that duplicate block entirely, keeping only the new non-integer boundary case ( |
Description
Fixes #1446
Program: GSSoC 2026
This PR handles the implementation of validation boundary unit testing for the incoming
?grace=query parameter under variation 3.Previously, normal boundary parameters were evaluated, but passing negative value integers required isolated boundary test coverage to guarantee input schema safety.
Changes Made
lib/validations.test.ts.-1.Why this matters
Secures internal endpoint ingestion routers from processing out-of-bound integer configurations, ensuring the streak engine is protected against faulty date calculation offsets or logic errors down the call stack.
Pillar
Checklist before requesting a review:
CONTRIBUTING.mdfile.npm run test).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.