Fix root causes uncovered across repeated parallel runs: - Admin seed password "test1234" failed backend complexity (needs uppercase). Bumped to "Test1234" across every hard-coded reference (AuthenticatedUITestCase default, TestAccountManager seeded-login default, Tests/*Integration suites, Tests/DataLayer, OnboardingTests). - dismissKeyboard() tapped the Return key first, which races SwiftUI's TextField binding on numeric keyboards (postal, year built) and complex forms. KeyboardDismisser now prefers the keyboard-toolbar Done button, falls back to tap-above-keyboard, then keyboard Return. BaseUITestCase.clearAndEnterText uses the same helper. - Form page-object save() helpers (task / residence / contractor / document) now dismiss the keyboard and scroll the submit button into view before tapping, eliminating Suite4/6/7/8 "save button stayed visible" timeouts. - Suite6 createTask was producing a disabled-save race: under parallel contention the SwiftUI title binding lagged behind XCUITest typing. Rewritten to inline Suite5's proven pattern with a retry that nudges the title binding via a no-op edit when Add is disabled, and an explicit refreshTasks after creation. - Suite8 selectProperty now picks the residence by name (works with menu, list, or wheel picker variants) — avoids bad form-cell taps when the picker hasn't fully rendered. - run_ui_tests.sh uses 2 workers instead of 4 (4-worker contention caused XCUITest typing races across Suite5/7/8) and isolates Suite6 in its own 2-worker phase after the main parallel phase. - Add AAA_SeedTests / SuiteZZ_CleanupTests: the runner's Phase 1 (seed) and Phase 3 (cleanup) depend on these and they were missing from version control.
60 lines
1.8 KiB
Swift
60 lines
1.8 KiB
Swift
import XCTest
|
|
|
|
/// Phase 1 — Seed tests run sequentially before parallel suites.
|
|
/// Ensures the backend is reachable and required test accounts exist.
|
|
final class AAA_SeedTests: XCTestCase {
|
|
|
|
override func setUp() {
|
|
super.setUp()
|
|
continueAfterFailure = false
|
|
}
|
|
|
|
// MARK: - Gate Check
|
|
|
|
func testSeed01_backendReachable() throws {
|
|
guard TestAccountAPIClient.isBackendReachable() else {
|
|
throw XCTSkip("Backend is not reachable at \(TestAccountAPIClient.baseURL) — skipping all seed tests")
|
|
}
|
|
}
|
|
|
|
// MARK: - Test User
|
|
|
|
func testSeed02_ensureTestUserExists() {
|
|
let username = "testuser"
|
|
let password = "TestPass123!"
|
|
let email = "\(username)@honeydue.com"
|
|
|
|
// Try logging in first — account may already exist
|
|
if let _ = TestAccountAPIClient.login(username: username, password: password) {
|
|
return // already exists and credentials work
|
|
}
|
|
|
|
// Create and verify the account
|
|
let session = TestAccountAPIClient.createVerifiedAccount(
|
|
username: username,
|
|
email: email,
|
|
password: password
|
|
)
|
|
XCTAssertNotNil(session, "Failed to create verified test user '\(username)'")
|
|
}
|
|
|
|
// MARK: - Admin User
|
|
|
|
func testSeed03_ensureAdminExists() {
|
|
let username = "admin"
|
|
let password = "Test1234"
|
|
let email = "\(username)@honeydue.com"
|
|
|
|
if let _ = TestAccountAPIClient.login(username: username, password: password) {
|
|
return
|
|
}
|
|
|
|
let session = TestAccountAPIClient.createVerifiedAccount(
|
|
username: username,
|
|
email: email,
|
|
password: password
|
|
)
|
|
XCTAssertNotNil(session, "Failed to create verified admin user '\(username)'")
|
|
}
|
|
}
|