Files
PlantGuide/PlantGuideUITests/Screens/SettingsScreen.swift
Trey t 1ae9c884c8 Rebuild UI test foundation with page objects, wait helpers, and screen objects
Replace brittle localized-string selectors and broken wait helpers with a
robust, identifier-first UI test infrastructure. All 41 UI tests pass on
iOS 26.2 simulator (iPhone 17).

Foundation:
- BaseUITestCase with deterministic launch helpers (launchClean, launchOffline)
- WaitHelpers (waitUntilHittable, waitUntilGone, tapWhenReady) replacing sleep()
- UITestID enum mirroring AccessibilityIdentifiers from the app target
- Screen objects: TabBarScreen, CameraScreen, CollectionScreen, TodayScreen,
  SettingsScreen, PlantDetailScreen

Key fixes:
- Tab navigation uses waitForExistence+tap instead of isHittable (unreliable
  in iOS 26 simulator)
- Tests handle real app state (empty collection, no camera permission)
- Increased timeouts for parallel clone execution
- Added NetworkMonitorProtocol and protocol-typed DI for testability
- Fixed actor-isolation issues in unit test mocks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 10:36:54 -06:00

45 lines
1.0 KiB
Swift

//
// SettingsScreen.swift
// PlantGuideUITests
//
// Screen object for the Settings tab.
//
import XCTest
struct SettingsScreen {
let app: XCUIApplication
// MARK: - Elements
var navigationBar: XCUIElement { app.navigationBars["Settings"] }
var notificationsToggle: XCUIElement {
app.switches[UITestID.Settings.notificationsToggle]
}
var clearCacheButton: XCUIElement {
app.buttons[UITestID.Settings.clearCacheButton]
}
var versionInfo: XCUIElement {
app.staticTexts[UITestID.Settings.versionInfo]
}
/// The settings form container SwiftUI Form renders as a table or collection view.
var formContainer: XCUIElement {
if app.tables.firstMatch.waitForExistence(timeout: 3) {
return app.tables.firstMatch
} else {
return app.collectionViews.firstMatch
}
}
// MARK: - State Checks
@discardableResult
func waitForLoad(timeout: TimeInterval = 10) -> Bool {
navigationBar.waitForExistence(timeout: timeout)
}
}