Summary of What Needs to be Done:
Add a dedicated vitest test file for the pure helpers in src/lib/github-rate-limit.ts: getGitHubRateLimitDetails, throwIfGitHubRateLimited, and githubRateLimitResponse. The module is used across the app to translate GitHub rate-limit responses into typed errors and 429 Responses, but it has no test coverage. Tests must use a fake Response (a plain object with status and headers.get) so they remain fast and deterministic.
Changes that Need to be Made:
- Create
test/github-rate-limit.test.ts that imports from ../src/lib/github-rate-limit.
- Cover
getGitHubRateLimitDetails with cases:
- 200 with
x-ratelimit-remaining: 0 → returns null (only 403/429 trigger).
- 403 with
x-ratelimit-remaining: 0 and a valid x-ratelimit-reset epoch → returns full details with matching resetAt ISO and resetAtEpoch.
- 429 with
x-ratelimit-remaining: 0 but missing x-ratelimit-reset → returns resetAt: null and a generic message.
- 403 with
x-ratelimit-remaining: 1 (still has budget) → returns null.
- 404 → returns null.
- Cover
throwIfGitHubRateLimited with cases:
- 200 response → no throw.
- 403 with rate-limit headers → throws
GitHubRateLimitError whose details matches the values returned by getGitHubRateLimitDetails.
- Cover
githubRateLimitResponse with cases:
- Plain
Error instance → returns null.
new GitHubRateLimitError(...) → returns a Response with status 429 and JSON body { error, message, rateLimit: { resetAt, resetAtEpoch } }.
Impact that it would Provide:
Locks the contract between GitHub's rate-limit signal and DevTrack's user-facing 429 response. Stops accidental behaviour drift the next time the helper is touched, with no production code changes.
Hello @Priyanshu-byte-coder, please assign this issue to me (@tmdeveloper007) so I can open a focused PR with the new test file.
Summary of What Needs to be Done:
Add a dedicated vitest test file for the pure helpers in
src/lib/github-rate-limit.ts:getGitHubRateLimitDetails,throwIfGitHubRateLimited, andgithubRateLimitResponse. The module is used across the app to translate GitHub rate-limit responses into typed errors and 429 Responses, but it has no test coverage. Tests must use a fakeResponse(a plain object withstatusandheaders.get) so they remain fast and deterministic.Changes that Need to be Made:
test/github-rate-limit.test.tsthat imports from../src/lib/github-rate-limit.getGitHubRateLimitDetailswith cases:x-ratelimit-remaining: 0→ returns null (only 403/429 trigger).x-ratelimit-remaining: 0and a validx-ratelimit-resetepoch → returns full details with matchingresetAtISO andresetAtEpoch.x-ratelimit-remaining: 0but missingx-ratelimit-reset→ returnsresetAt: nulland a generic message.x-ratelimit-remaining: 1(still has budget) → returns null.throwIfGitHubRateLimitedwith cases:GitHubRateLimitErrorwhosedetailsmatches the values returned bygetGitHubRateLimitDetails.githubRateLimitResponsewith cases:Errorinstance → returns null.new GitHubRateLimitError(...)→ returns aResponsewith status 429 and JSON body{ error, message, rateLimit: { resetAt, resetAtEpoch } }.Impact that it would Provide:
Locks the contract between GitHub's rate-limit signal and DevTrack's user-facing 429 response. Stops accidental behaviour drift the next time the helper is touched, with no production code changes.
Hello @Priyanshu-byte-coder, please assign this issue to me (@tmdeveloper007) so I can open a focused PR with the new test file.