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>
41 lines
1017 B
Swift
41 lines
1017 B
Swift
//
|
|
// TodayScreen.swift
|
|
// PlantGuideUITests
|
|
//
|
|
// Screen object for the Today tab (care tasks dashboard).
|
|
//
|
|
|
|
import XCTest
|
|
|
|
struct TodayScreen {
|
|
let app: XCUIApplication
|
|
|
|
// MARK: - Elements
|
|
|
|
/// The Today view uses a dynamic greeting as navigation title.
|
|
/// We check for the nav bar existence rather than a fixed title.
|
|
var navigationBar: XCUIElement {
|
|
app.navigationBars.firstMatch
|
|
}
|
|
|
|
var todaySection: XCUIElement {
|
|
app.otherElements[UITestID.CareSchedule.todaySection]
|
|
}
|
|
|
|
var overdueSection: XCUIElement {
|
|
app.otherElements[UITestID.CareSchedule.overdueSection]
|
|
}
|
|
|
|
var emptyStateView: XCUIElement {
|
|
app.otherElements[UITestID.CareSchedule.emptyStateView]
|
|
}
|
|
|
|
// MARK: - State Checks
|
|
|
|
@discardableResult
|
|
func waitForLoad(timeout: TimeInterval = 10) -> Bool {
|
|
// The Today view has a dynamic nav title (greeting) so we just wait for any nav bar
|
|
navigationBar.waitForExistence(timeout: timeout)
|
|
}
|
|
}
|