Commit 831d28d
authored
test(utils): check rate limit TTL boundary robustness (JhaSourav07#1561) (JhaSourav07#1662)
## Description
Fixes JhaSourav07#1561
Added a boundary robustness test for the rate limit utility to verify
that keys expire exactly at the configured window limit when requests
occur across sliding time ranges.
## 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 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=YOUR_USERNAME`).
* [ ] 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 started 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 (not applicable for test-only changes).
* [ ] (Recommended) I joined the CommitPulse Discord community for
contributor discussions, mentorship, and faster PR support.
## Test Validation
Command executed:
```bash
npx vitest run lib/rate-limit.test.ts
```
Result:
```text
✓ lib/rate-limit.test.ts
Test Files 1 passed (1)
Tests 12 passed (12)
```
### Implementation Notes
* Updated `lib/rate-limit.test.ts`
* Added a boundary-focused test:
* `expires at the window boundary after sliding requests`
* Verified expiration behavior at the configured window limit for
sliding request timings.
* No production code changes were made.1 file changed
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
73 | 97 | | |
74 | 98 | | |
75 | 99 | | |
| |||
0 commit comments