feat: enhance error handling in git-push and repo services#1406
feat: enhance error handling in git-push and repo services#1406dcoric wants to merge 7 commits intofinos:mainfrom
Conversation
… for error scenarios
- Add new test file for errors.ts utility functions (18 tests) - Expand git-push.test.ts to cover getPush and getPushes functions (13 tests total) - Expand repo.test.ts to cover getRepos, addRepo, deleteUser, and deleteRepo (21 tests total) - Add new test file for user.ts service functions (13 tests) - All tests verify both success and error handling scenarios - Total test count increased from 14 to 79 tests for UI services
✅ Deploy Preview for endearing-brigadeiros-63f9d0 canceled.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1406 +/- ##
==========================================
- Coverage 81.51% 81.37% -0.15%
==========================================
Files 66 67 +1
Lines 4713 4735 +22
Branches 814 819 +5
==========================================
+ Hits 3842 3853 +11
- Misses 856 867 +11
Partials 15 15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jescalada
left a comment
There was a problem hiding this comment.
Looks good so far, thanks for all the extra UI tests!
What I had in mind when I first made the error handling refactor ticket was some sort of wrapper component (context?) that would catch any errors happening in API calls and forward the error to a toast. I'm aware this would require a lot of extra refactoring, so I might have to clarify the details and we can deal with it in a separate PR.
Note that I haven't tested behavior yet - will complete the review later this week 👍🏼
kriswest
left a comment
There was a problem hiding this comment.
Very happy to see this being done (particularly redirects to login on 401s and use of the API's error messages) and would love it to go into 2.0 (as the current situation is awful). I only have a couple of minor comments to add to Juan's.
Summary
This PR fixes both:
Improve error handling and test coverage for UI services
This PR refactors error handling across the UI service layer and adds comprehensive test coverage. Error handling is now consistent, type-safe, and properly tested.
What's changed
Error handling improvements:
src/ui/services/errors.tswith reusable error utilities (getServiceError,errorResult,successResult)git-push.tsandrepo.tsservices to use the new error handling utilitiesPushDetails.tsx,RepoDetails.tsx, etc.) to properly handle and display error statesServiceResult<T>objects with success/failure statesTest coverage (14 → 79 tests):
test/ui/errors.test.ts- comprehensive tests for error utility functions (18 tests)test/ui/user.test.ts- tests for user service functions (13 tests)test/ui/git-push.test.ts- expanded coverage for all git-push functions (13 tests)test/ui/repo.test.ts- expanded coverage for all repo functions (21 tests)Tests cover success paths, HTTP errors (401/403/404/409/500), network failures, and edge cases.
Benefits