test(api): unit tests for error mapping and Authorization header#562
test(api): unit tests for error mapping and Authorization header#562playmaker410 wants to merge 1 commit into
Conversation
- Assert ApiError with statusCode + details on 400 validation error - Assert ApiError with 404 status on not-found response - Assert generic ApiError on 500 plain-text response - Assert Authorization: Bearer header is sent when token is set Closes ritik4ever#259
|
@playmaker410 is attempting to deploy a commit to the ritik4ever's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR updates a single API service authentication test to align with the current request parameter shape, changing the ChangesAPI Service Test
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Extends
frontend/src/services/api.test.tswith explicit test coverage for error response mapping and request header construction, as specified in issue #259.Changes
ApiErroris thrown withstatusCode: 400, correct message, anddetailspayloadApiErrorwithstatusCode: 404and message from response bodyApiErrorwithstatusCode: 500; plain-text body is not leaked as structured detailsAuthorization: Bearer <token>is sent oncreateStreamwhen a token is set viasetAuthTokenAlso fixes the pre-existing payload shape bug in the auth test (
amount/asset/duration→totalAmount/assetCode/durationSeconds) that would have caused a TypeScript compile error.Test results
All 4 tests in
src/services/api.test.tspass. No other tests were affected.Closes #259
Summary by CodeRabbit
Release Notes
This update includes internal test improvements only. No user-facing features, bug fixes, or changes are included in this release.