Add onboarding UI tests and improve app data management
- Add Suite0_OnboardingTests with fresh install and login test flows - Add accessibility identifiers to onboarding views for UI testing - Remove deprecated DataCache in favor of unified DataManager - Update API layer to support public upgrade-triggers endpoint - Improve onboarding first task view with better date handling - Update various views with accessibility identifiers for testing - Fix subscription feature comparison view layout - Update document detail view improvements 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ struct TaskFormView: View {
|
||||
let existingTask: TaskResponse? // nil for add mode, populated for edit mode
|
||||
@Binding var isPresented: Bool
|
||||
@StateObject private var viewModel = TaskViewModel()
|
||||
@ObservedObject private var dataManager = DataManagerObservable.shared
|
||||
@FocusState private var focusedField: TaskFormField?
|
||||
|
||||
private var isEditMode: Bool {
|
||||
@@ -32,12 +33,12 @@ struct TaskFormView: View {
|
||||
selectedStatus != nil
|
||||
}
|
||||
|
||||
// Lookups from DataCache
|
||||
@State private var taskCategories: [TaskCategory] = []
|
||||
@State private var taskFrequencies: [TaskFrequency] = []
|
||||
@State private var taskPriorities: [TaskPriority] = []
|
||||
@State private var taskStatuses: [TaskStatus] = []
|
||||
@State private var isLoadingLookups: Bool = true
|
||||
// Lookups from DataManagerObservable
|
||||
private var taskCategories: [TaskCategory] { dataManager.taskCategories }
|
||||
private var taskFrequencies: [TaskFrequency] { dataManager.taskFrequencies }
|
||||
private var taskPriorities: [TaskPriority] { dataManager.taskPriorities }
|
||||
private var taskStatuses: [TaskStatus] { dataManager.taskStatuses }
|
||||
private var isLoadingLookups: Bool { !dataManager.lookupsInitialized }
|
||||
|
||||
// Form fields
|
||||
@State private var selectedResidence: ResidenceResponse?
|
||||
@@ -254,8 +255,16 @@ struct TaskFormView: View {
|
||||
.disabled(!canSave || viewModel.isLoading || isLoadingLookups)
|
||||
}
|
||||
}
|
||||
.task {
|
||||
await loadLookups()
|
||||
.onAppear {
|
||||
// Set defaults when lookups are available
|
||||
if dataManager.lookupsInitialized {
|
||||
setDefaults()
|
||||
}
|
||||
}
|
||||
.onChange(of: dataManager.lookupsInitialized) { initialized in
|
||||
if initialized {
|
||||
setDefaults()
|
||||
}
|
||||
}
|
||||
.onChange(of: viewModel.taskCreated) { created in
|
||||
if created {
|
||||
@@ -280,37 +289,6 @@ struct TaskFormView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private func loadLookups() async {
|
||||
// Wait a bit for lookups to be initialized (they load on app launch or login)
|
||||
try? await Task.sleep(nanoseconds: 100_000_000) // 0.1 seconds
|
||||
|
||||
// Load lookups from DataCache
|
||||
await MainActor.run {
|
||||
if let categories = DataCache.shared.taskCategories.value as? [TaskCategory],
|
||||
let frequencies = DataCache.shared.taskFrequencies.value as? [TaskFrequency],
|
||||
let priorities = DataCache.shared.taskPriorities.value as? [TaskPriority],
|
||||
let statuses = DataCache.shared.taskStatuses.value as? [TaskStatus] {
|
||||
|
||||
self.taskCategories = categories
|
||||
self.taskFrequencies = frequencies
|
||||
self.taskPriorities = priorities
|
||||
self.taskStatuses = statuses
|
||||
|
||||
print("✅ TaskFormView: Loaded lookups - Categories: \(categories.count), Frequencies: \(frequencies.count), Priorities: \(priorities.count), Statuses: \(statuses.count)")
|
||||
|
||||
setDefaults()
|
||||
isLoadingLookups = false
|
||||
}
|
||||
}
|
||||
|
||||
// If lookups not loaded, retry
|
||||
if taskCategories.isEmpty {
|
||||
print("⏳ TaskFormView: Lookups not ready, retrying...")
|
||||
try? await Task.sleep(nanoseconds: 500_000_000) // 0.5 seconds
|
||||
await loadLookups()
|
||||
}
|
||||
}
|
||||
|
||||
private func setDefaults() {
|
||||
// Set default values if not already set
|
||||
if selectedCategory == nil && !taskCategories.isEmpty {
|
||||
|
||||
Reference in New Issue
Block a user