Skip to content

Commit ef6f3f0

Browse files
authored
test(api): verify stale-while-revalidate=86400 in cache header (JhaSourav07#814)
## Description Fixes JhaSourav07#704 ## Pillar - [ ] 🎨 Pillar 1 β€” New Theme Design - [ ] πŸ“ Pillar 2 β€” Geometric SVG Improvement - [ ] πŸ• Pillar 3 β€” Timezone Logic Optimization - [x] πŸ› οΈ Other (Bug fix, refactoring, docs) ## Visual Preview N/A - Test only, no visual changes ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`localhost:3000/api/streak?user=sandesh-861`). - [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): ...`). - [ ] 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. - [ ] 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.
2 parents 5ad4bd2 + 2e7b313 commit ef6f3f0

3 files changed

Lines changed: 8195 additions & 0 deletions

File tree

β€Žapp/api/streak/route.test.tsβ€Ž

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,4 +826,18 @@ describe('GET /api/streak', () => {
826826
expect(body).toContain('</svg>');
827827
});
828828
});
829+
830+
describe('stale-while-revalidate cache header', () => {
831+
it('contains stale-while-revalidate=86400 for normal request', async () => {
832+
const response = await GET(makeRequest({ user: 'octocat' }));
833+
834+
expect(response.headers.get('Cache-Control')).toContain('stale-while-revalidate=86400');
835+
});
836+
837+
it('does NOT contain stale-while-revalidate when ?refresh=true', async () => {
838+
const response = await GET(makeRequest({ user: 'octocat', refresh: 'true' }));
839+
840+
expect(response.headers.get('Cache-Control')).not.toContain('stale-while-revalidate=86400');
841+
});
842+
});
829843
});

0 commit comments

Comments
Β (0)