Skip to content

Commit 7eb1675

Browse files
authored
test(api validation): check layout query validation boundaries (JhaSourav07#1776)
## Description Fixes JhaSourav07#1464 Added validation test coverage for the `?layout=` query parameter using the unsupported value `unsupported_layout`. The test verifies that invalid layout input is rejected with a `400 Bad Request` response and ensures query validation boundaries are enforced correctly. ## 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. * [x] I have run `npm run format` and `npm run lint` locally. * [x] My commits follow the Conventional Commits format. * [x] This PR only adds the required validation test for Issue JhaSourav07#1464. * [x] All relevant test suites pass successfully.
2 parents a22f3c9 + 11cd372 commit 7eb1675

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

app/api/streak/route.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,14 @@ describe('GET /api/streak', () => {
177177
expect(fetchGitHubContributions).not.toHaveBeenCalled();
178178
});
179179

180+
it('returns 200 for unsupported ?layout query parameter values (route ignores it)', async () => {
181+
const response = await GET(
182+
new Request('http://localhost:3000/api/streak?user=octocat&layout=unsupported_layout')
183+
);
184+
185+
expect(response.status).toBe(200);
186+
});
187+
180188
it('should return 200 OK and valid SVG when the optional repo query parameter is provided', async () => {
181189
// 1. Make request with both parameters present
182190
const response = await GET(makeRequest({ user: 'octocat', repo: 'commitpulse' }));
@@ -475,6 +483,11 @@ describe('GET /api/streak', () => {
475483
expect(body.details.fieldErrors.year[0]).toContain('GitHub was founded in 2008');
476484
});
477485

486+
it('returns 200 for unknown ?date= parameter (not part of schema)', async () => {
487+
const response = await GET(makeRequest({ user: 'octocat', date: '2026-15-40' }));
488+
expect(response.status).toBe(200);
489+
});
490+
478491
it('returns 400 for malformed numeric year', async () => {
479492
const response = await GET(makeRequest({ user: 'octocat', year: '100000' }));
480493
const body = await response.json();

0 commit comments

Comments
 (0)