feat(ios): add error handling and integration tests

Implement comprehensive error handling and integration test suite:

Error Handling (Section 8):
- Add iOS-specific error codes to DailyNotificationErrorCodes:
  - NOTIFICATION_PERMISSION_DENIED
  - PENDING_NOTIFICATION_LIMIT_EXCEEDED
  - BG_TASK_NOT_REGISTERED
  - BG_TASK_EXECUTION_FAILED
  - BACKGROUND_REFRESH_DISABLED
- Add helper methods for iOS-specific error responses
- Enhance error handling in ReactivationManager:
  - Database errors handled gracefully (non-fatal)
  - Notification center errors handled gracefully (non-fatal)
  - Scheduling errors handled gracefully (non-fatal)
  - All errors logged, app continues normally
  - Partial results returned when operations fail
- Update plugin methods to use iOS-specific error codes:
  - getNotificationPermissionStatus uses NOTIFICATION_PERMISSION_DENIED

Integration Tests (Section 9.2):
- Add DailyNotificationRecoveryIntegrationTests:
  - Full recovery flow tests (cold start, termination)
  - Error handling tests (database, notification center, scheduling)
  - App stability tests (no crashes, concurrent operations)
  - Partial recovery tests
  - Timeout handling tests
- Test coverage:
  - 10 integration tests covering recovery scenarios
  - Error handling verification
  - App stability verification
  - Concurrent operation safety

Completes sections 8.1, 8.2, and 9.2 of iOS implementation checklist.
This commit is contained in:
Matthew
2025-12-09 02:46:13 -08:00
parent 12d8536588
commit 3649e76c49
5 changed files with 650 additions and 29 deletions

View File

@@ -381,22 +381,22 @@ Complete checklist of iOS code that needs to be implemented for feature parity w
### 8.1 Recovery Error Handling
- [ ] Ensure all recovery methods catch errors:
- [ ] Database errors (non-fatal)
- [ ] Notification center errors (non-fatal)
- [ ] Scheduling errors (non-fatal)
- [ ] Log errors but don't crash app
- [ ] Return partial results if some operations fail
- [x] Ensure all recovery methods catch errors:
- [x] Database errors (non-fatal) - handled in detectScenario, detectMissedNotifications, verifyFutureNotifications
- [x] Notification center errors (non-fatal) - handled in detectScenario, verifyFutureNotifications
- [x] Scheduling errors (non-fatal) - handled in rescheduleMissingNotification
- [x] Log errors but don't crash app - all errors logged with NSLog, app continues
- [x] Return partial results if some operations fail - RecoveryResult includes error count
### 8.2 Error Types
- [ ] Define iOS-specific error codes:
- [ ] `NOTIFICATION_PERMISSION_DENIED`
- [ ] `BACKGROUND_REFRESH_DISABLED`
- [ ] `PENDING_NOTIFICATION_LIMIT_EXCEEDED`
- [ ] `BG_TASK_NOT_REGISTERED`
- [ ] `BG_TASK_EXECUTION_FAILED`
- [ ] Map to error responses in plugin methods
- [x] Define iOS-specific error codes:
- [x] `NOTIFICATION_PERMISSION_DENIED`
- [x] `BACKGROUND_REFRESH_DISABLED`
- [x] `PENDING_NOTIFICATION_LIMIT_EXCEEDED`
- [x] `BG_TASK_NOT_REGISTERED`
- [x] `BG_TASK_EXECUTION_FAILED`
- [x] Map to error responses in plugin methods - getNotificationPermissionStatus uses NOTIFICATION_PERMISSION_DENIED
---
@@ -420,16 +420,16 @@ Complete checklist of iOS code that needs to be implemented for feature parity w
### 9.2 Integration Tests
- [ ] Test full recovery flow:
- [ ] Schedule notification
- [ ] Terminate app
- [ ] Launch app
- [ ] Verify recovery executed
- [ ] Verify notifications rescheduled
- [ ] Test error handling:
- [ ] Test database errors
- [ ] Test notification center errors
- [ ] Verify app doesn't crash
- [x] Test full recovery flow:
- [x] Schedule notification
- [x] Terminate app (simulated by clearing notifications)
- [x] Launch app (simulated by calling performRecovery)
- [x] Verify recovery executed
- [x] Verify notifications rescheduled (DailyNotificationRecoveryIntegrationTests)
- [x] Test error handling:
- [x] Test database errors (testErrorHandling_DatabaseError)
- [x] Test notification center errors (testErrorHandling_NotificationCenterError)
- [x] Verify app doesn't crash (all stability tests)
### 9.3 Manual Testing