Update warranty status to use backend calculation and add comprehensive tests
Client-Side Changes: - Add WarrantyStatus data class to Document model for backend-calculated status - Update WarrantyCard to display backend status (statusText, statusColor) with client fallback - Fix document list refresh: call loadDocuments() after create/update operations Testing: - Add ComprehensiveDocumentWarrantyTests with 25+ XCUITest cases - Test document creation, update, delete, image upload - Test warranty-specific fields and property selection - Test both general documents and warranties - Includes helper methods for form interaction and cleanup Other: - Update ApiConfig and PushNotificationManager 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,12 @@ struct WarrantyCard: View {
|
||||
}
|
||||
|
||||
var statusColor: Color {
|
||||
// Use backend-calculated status color if available
|
||||
if let warrantyStatus = document.warrantyStatus {
|
||||
return Color(hex: warrantyStatus.statusColor) ?? Color.appPrimary
|
||||
}
|
||||
|
||||
// Fallback to client-side calculation (shouldn't happen with updated backend)
|
||||
if !document.isActive { return Color.appTextSecondary }
|
||||
if daysUntilExpiration < 0 { return Color.appError }
|
||||
if daysUntilExpiration < 30 { return Color.appAccent }
|
||||
@@ -17,6 +23,12 @@ struct WarrantyCard: View {
|
||||
}
|
||||
|
||||
var statusText: String {
|
||||
// Use backend-calculated status text if available
|
||||
if let warrantyStatus = document.warrantyStatus {
|
||||
return warrantyStatus.statusText
|
||||
}
|
||||
|
||||
// Fallback to client-side calculation (shouldn't happen with updated backend)
|
||||
if !document.isActive { return "Inactive" }
|
||||
if daysUntilExpiration < 0 { return "Expired" }
|
||||
if daysUntilExpiration < 30 { return "Expiring soon" }
|
||||
|
||||
@@ -470,6 +470,8 @@ struct DocumentFormView: View {
|
||||
) { success, error in
|
||||
isProcessing = false
|
||||
if success {
|
||||
// Reload documents to show updated item
|
||||
documentViewModel.loadDocuments(residenceId: residenceId)
|
||||
dismiss()
|
||||
} else {
|
||||
alertMessage = error ?? "Failed to update document"
|
||||
@@ -503,6 +505,8 @@ struct DocumentFormView: View {
|
||||
) { success, error in
|
||||
isProcessing = false
|
||||
if success {
|
||||
// Reload documents to show new item
|
||||
documentViewModel.loadDocuments(residenceId: actualResidenceId)
|
||||
isPresented = false
|
||||
} else {
|
||||
alertMessage = error ?? "Failed to create document"
|
||||
|
||||
@@ -199,11 +199,11 @@ class PushNotificationManager: NSObject, ObservableObject {
|
||||
// MARK: - Badge Management
|
||||
|
||||
func clearBadge() {
|
||||
UIApplication.shared.applicationIconBadgeNumber = 0
|
||||
UNUserNotificationCenter.current().setBadgeCount(0)
|
||||
}
|
||||
|
||||
func setBadge(count: Int) {
|
||||
UIApplication.shared.applicationIconBadgeNumber = count
|
||||
UNUserNotificationCenter.current().setBadgeCount(count)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user