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>
This commit is contained in:
@@ -264,22 +264,19 @@ final class IdentifyPlantOnDeviceUseCaseTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
// Configure mock to throw
|
||||
let service = mockClassificationService!
|
||||
Task {
|
||||
service.shouldThrowOnClassify = true
|
||||
service.errorToThrow = PlantClassificationError.modelLoadFailed
|
||||
// Configure mock to throw via actor-isolated method
|
||||
await mockClassificationService.setThrowBehavior(
|
||||
shouldThrow: true,
|
||||
error: PlantClassificationError.modelLoadFailed
|
||||
)
|
||||
|
||||
// Verify the error propagates
|
||||
do {
|
||||
_ = try await sut.execute(image: testImage)
|
||||
XCTFail("Expected classification error to be thrown")
|
||||
} catch {
|
||||
XCTAssertNotNil(error)
|
||||
}
|
||||
|
||||
// Give time for the configuration to apply
|
||||
try? await Task.sleep(nanoseconds: 10_000_000) // 10ms
|
||||
|
||||
// Note: Due to actor isolation, we need to check this differently
|
||||
// For now, verify the normal path works
|
||||
await mockClassificationService.configureDefaultPredictions()
|
||||
|
||||
let result = try? await sut.execute(image: testImage)
|
||||
XCTAssertNotNil(result)
|
||||
}
|
||||
|
||||
// MARK: - Error Description Tests
|
||||
|
||||
Reference in New Issue
Block a user