Rearchitect UI test suite for complete, non-flaky coverage against live API
- Migrate Suite4-10, SmokeTests, NavigationCriticalPathTests to AuthenticatedTestCase with seeded admin account and real backend login - Add 34 accessibility identifiers across 11 app views (task completion, profile, notifications, theme, join residence, manage users, forms) - Create FeatureCoverageTests (14 tests) covering previously untested features: profile edit, theme selection, notification prefs, task completion, manage users, join residence, task templates - Create MultiUserSharingTests (18 API tests) and MultiUserSharingUITests (8 XCUI tests) for full cross-user residence sharing lifecycle - Add cleanup infrastructure: SuiteZZ_CleanupTests auto-wipes test data after runs, cleanup_test_data.sh script for manual reset via admin API - Add share code API methods to TestAccountAPIClient (generateShareCode, joinWithCode, getShareCode, listResidenceUsers, removeUser) - Fix app bugs found by tests: - ResidencesListView join callback now uses forceRefresh:true - APILayer invalidates task cache when residence count changes - AllTasksView auto-reloads tasks when residence list changes - Fix test quality: keyboard focus waits, Save/Add button label matching, Documents tab label (Docs), remove API verification from UI tests - DataLayerTests and PasswordResetTests now verify through UI, not API calls Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,24 +10,15 @@ import XCTest
|
||||
/// 4. Delete/remove tests (none currently)
|
||||
/// 5. Navigation/view tests
|
||||
/// 6. Performance tests
|
||||
final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
override var includeResetStateLaunchArgument: Bool { false }
|
||||
|
||||
final class Suite6_ComprehensiveTaskTests: AuthenticatedTestCase {
|
||||
override var useSeededAccount: Bool { true }
|
||||
|
||||
// Test data tracking
|
||||
var createdTaskTitles: [String] = []
|
||||
|
||||
override func setUpWithError() throws {
|
||||
try super.setUpWithError()
|
||||
|
||||
// Ensure user is logged in
|
||||
UITestHelpers.ensureLoggedIn(app: app)
|
||||
|
||||
// CRITICAL: Ensure at least one residence exists
|
||||
ensureResidenceExists()
|
||||
|
||||
// Navigate to Tasks tab
|
||||
navigateToTasksTab()
|
||||
navigateToTasks()
|
||||
}
|
||||
|
||||
override func tearDownWithError() throws {
|
||||
@@ -37,57 +28,6 @@ final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
|
||||
// MARK: - Helper Methods
|
||||
|
||||
/// Ensures at least one residence exists (required for tasks to work)
|
||||
private func ensureResidenceExists() {
|
||||
let residencesTab = app.tabBars.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Residences'")).firstMatch
|
||||
if residencesTab.waitForExistence(timeout: 5) {
|
||||
residencesTab.tap()
|
||||
sleep(2)
|
||||
|
||||
let emptyStateText = app.staticTexts.containing(NSPredicate(format: "label CONTAINS[c] 'No properties' OR label CONTAINS[c] 'No residences'")).firstMatch
|
||||
|
||||
if emptyStateText.exists {
|
||||
createTestResidence()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func createTestResidence() {
|
||||
let addButton = app.buttons[AccessibilityIdentifiers.Residence.addButton]
|
||||
guard addButton.waitForExistence(timeout: 5) else { return }
|
||||
addButton.tap()
|
||||
sleep(2)
|
||||
|
||||
let nameField = app.textFields.containing(NSPredicate(format: "placeholderValue CONTAINS[c] 'Name'")).firstMatch
|
||||
guard nameField.waitForExistence(timeout: 5) else { return }
|
||||
nameField.tap()
|
||||
nameField.typeText("Test Home for Comprehensive Tasks")
|
||||
|
||||
app.swipeUp()
|
||||
sleep(1)
|
||||
|
||||
fillField(placeholder: "Street", text: "123 Test St")
|
||||
fillField(placeholder: "City", text: "TestCity")
|
||||
fillField(placeholder: "State", text: "TS")
|
||||
fillField(placeholder: "Postal", text: "12345")
|
||||
|
||||
let saveButton = app.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Save'")).firstMatch
|
||||
if saveButton.exists {
|
||||
saveButton.tap()
|
||||
sleep(3)
|
||||
}
|
||||
}
|
||||
|
||||
private func navigateToTasksTab() {
|
||||
let tasksTab = app.tabBars.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Tasks'")).firstMatch
|
||||
if tasksTab.waitForExistence(timeout: 5) {
|
||||
if !tasksTab.isSelected {
|
||||
tasksTab.tap()
|
||||
sleep(3)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func openTaskForm() -> Bool {
|
||||
let addButton = findAddTaskButton()
|
||||
guard addButton.exists && addButton.isEnabled else { return false }
|
||||
@@ -124,6 +64,7 @@ final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
let field = app.textFields.containing(NSPredicate(format: "placeholderValue CONTAINS[c] '\(placeholder)'")).firstMatch
|
||||
if field.exists {
|
||||
field.tap()
|
||||
sleep(1) // Wait for keyboard to appear
|
||||
field.typeText(text)
|
||||
}
|
||||
}
|
||||
@@ -167,7 +108,7 @@ final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
app.swipeUp()
|
||||
sleep(1)
|
||||
|
||||
let saveButton = app.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Save'")).firstMatch
|
||||
let saveButton = app.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Save' OR label CONTAINS[c] 'Add'")).firstMatch
|
||||
guard saveButton.exists else { return false }
|
||||
saveButton.tap()
|
||||
|
||||
@@ -222,43 +163,14 @@ final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
return
|
||||
}
|
||||
|
||||
// Leave title empty but fill other required fields
|
||||
// Select category
|
||||
let categoryPicker = app.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Category'")).firstMatch
|
||||
if categoryPicker.exists {
|
||||
app.staticTexts["Appliances"].firstMatch.tap()
|
||||
app.buttons["Plumbing"].firstMatch.tap()
|
||||
}
|
||||
|
||||
// Select frequency
|
||||
let frequencyPicker = app.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Frequency'")).firstMatch
|
||||
if frequencyPicker.exists {
|
||||
app.staticTexts["Once"].firstMatch.tap()
|
||||
app.buttons["Once"].firstMatch.tap()
|
||||
}
|
||||
|
||||
// Select priority
|
||||
let priorityPicker = app.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Priority'")).firstMatch
|
||||
if priorityPicker.exists {
|
||||
app.staticTexts["High"].firstMatch.tap()
|
||||
app.buttons["Low"].firstMatch.tap()
|
||||
}
|
||||
|
||||
// Select status
|
||||
let statusPicker = app.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Status'")).firstMatch
|
||||
if statusPicker.exists {
|
||||
app.staticTexts["Pending"].firstMatch.tap()
|
||||
app.buttons["Pending"].firstMatch.tap()
|
||||
}
|
||||
|
||||
// Scroll to save button
|
||||
// Leave title empty - scroll to find the submit button
|
||||
app.swipeUp()
|
||||
sleep(1)
|
||||
|
||||
// Save button should be disabled when title is empty
|
||||
let saveButton = app.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Save'")).firstMatch
|
||||
XCTAssertTrue(saveButton.exists, "Save button should exist")
|
||||
XCTAssertFalse(saveButton.isEnabled, "Save button should be disabled when title is empty")
|
||||
// Save/Add button should be disabled when title is empty
|
||||
let saveButton = app.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Save' OR label CONTAINS[c] 'Add'")).firstMatch
|
||||
XCTAssertTrue(saveButton.exists, "Save/Add button should exist")
|
||||
XCTAssertFalse(saveButton.isEnabled, "Save/Add button should be disabled when title is empty")
|
||||
}
|
||||
|
||||
func test02_cancelTaskCreation() {
|
||||
@@ -320,7 +232,7 @@ final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
let success = createTask(title: taskTitle)
|
||||
XCTAssertTrue(success, "Should create task \(i)")
|
||||
|
||||
navigateToTasksTab()
|
||||
navigateToTasks()
|
||||
sleep(2)
|
||||
}
|
||||
|
||||
@@ -379,7 +291,7 @@ final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
return
|
||||
}
|
||||
|
||||
navigateToTasksTab()
|
||||
navigateToTasks()
|
||||
sleep(2)
|
||||
|
||||
// Find and tap task
|
||||
@@ -415,7 +327,7 @@ final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
createdTaskTitles.append(newTitle)
|
||||
|
||||
// Verify new title appears
|
||||
navigateToTasksTab()
|
||||
navigateToTasks()
|
||||
sleep(2)
|
||||
let updatedTask = findTask(title: newTitle)
|
||||
XCTAssertTrue(updatedTask.exists, "Task should show updated title")
|
||||
@@ -436,7 +348,7 @@ final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
return
|
||||
}
|
||||
|
||||
navigateToTasksTab()
|
||||
navigateToTasks()
|
||||
sleep(2)
|
||||
|
||||
// Find and tap task
|
||||
@@ -539,7 +451,7 @@ final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
createdTaskTitles.append(newTitle)
|
||||
|
||||
// Verify updated task appears in list with new title
|
||||
navigateToTasksTab()
|
||||
navigateToTasks()
|
||||
sleep(2)
|
||||
let updatedTask = findTask(title: newTitle)
|
||||
XCTAssertTrue(updatedTask.exists, "Task should show updated title in list")
|
||||
@@ -557,7 +469,7 @@ final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
|
||||
func test11_navigateFromTasksToOtherTabs() {
|
||||
// From Tasks tab
|
||||
navigateToTasksTab()
|
||||
navigateToTasks()
|
||||
|
||||
// Navigate to Residences
|
||||
let residencesTab = app.tabBars.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Residences'")).firstMatch
|
||||
@@ -586,7 +498,7 @@ final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
}
|
||||
|
||||
func test12_refreshTasksList() {
|
||||
navigateToTasksTab()
|
||||
navigateToTasks()
|
||||
sleep(2)
|
||||
|
||||
// Pull to refresh (if implemented) or use refresh button
|
||||
@@ -613,7 +525,7 @@ final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
return
|
||||
}
|
||||
|
||||
navigateToTasksTab()
|
||||
navigateToTasks()
|
||||
sleep(2)
|
||||
|
||||
// Verify task exists
|
||||
@@ -627,7 +539,7 @@ final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
sleep(3)
|
||||
|
||||
// Navigate back to tasks
|
||||
navigateToTasksTab()
|
||||
navigateToTasks()
|
||||
sleep(2)
|
||||
|
||||
// Verify task still exists
|
||||
@@ -639,7 +551,7 @@ final class Suite6_ComprehensiveTaskTests: BaseUITestCase {
|
||||
|
||||
func test14_taskListPerformance() {
|
||||
measure(metrics: [XCTClockMetric(), XCTMemoryMetric()]) {
|
||||
navigateToTasksTab()
|
||||
navigateToTasks()
|
||||
sleep(2)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user