diff --git a/iosApp/CaseraTests/DataLayerTests.swift b/iosApp/CaseraTests/DataLayerTests.swift index b0bcf41..5a9e022 100644 --- a/iosApp/CaseraTests/DataLayerTests.swift +++ b/iosApp/CaseraTests/DataLayerTests.swift @@ -24,19 +24,19 @@ struct DataLayerTests { @Suite struct CacheValidationTests { @Test func cacheTimeZeroIsInvalid() { - #expect(DataManager.shared.isCacheValid(cacheTime: 0) == false) + #expect(DataManager.shared.isCacheValid(cacheTime: 0, ttlMs: DataManager.shared.CACHE_TIMEOUT_MS) == false) } @Test func recentCacheTimeIsValid() { // 5 minutes ago should be valid (well within the 1-hour timeout) let fiveMinutesAgo = Int64(Date().timeIntervalSince1970 * 1000) - (5 * 60 * 1000) - #expect(DataManager.shared.isCacheValid(cacheTime: fiveMinutesAgo) == true) + #expect(DataManager.shared.isCacheValid(cacheTime: fiveMinutesAgo, ttlMs: DataManager.shared.CACHE_TIMEOUT_MS) == true) } @Test func expiredCacheTimeIsInvalid() { // 2 hours ago should be invalid (past the 1-hour timeout) let twoHoursAgo = Int64(Date().timeIntervalSince1970 * 1000) - (2 * 60 * 60 * 1000) - #expect(DataManager.shared.isCacheValid(cacheTime: twoHoursAgo) == false) + #expect(DataManager.shared.isCacheValid(cacheTime: twoHoursAgo, ttlMs: DataManager.shared.CACHE_TIMEOUT_MS) == false) } @Test func cacheTimeoutConstantIsOneHour() { diff --git a/iosApp/CaseraUITests/Framework/RebuildSupport.swift b/iosApp/CaseraUITests/Framework/RebuildSupport.swift index 65d4093..322c026 100644 --- a/iosApp/CaseraUITests/Framework/RebuildSupport.swift +++ b/iosApp/CaseraUITests/Framework/RebuildSupport.swift @@ -67,7 +67,7 @@ struct VerificationScreen { } } -struct MainTabScreen { +struct MainTabScreenObject { let app: XCUIApplication var tabBar: XCUIElement { app.tabBars.firstMatch } @@ -160,13 +160,13 @@ struct ResidenceFormScreen { enum RebuildSessionAssertions { static func assertOnLogin(_ app: XCUIApplication, timeout: TimeInterval = 15, file: StaticString = #filePath, line: UInt = #line) { - let login = LoginScreen(app: app) + let login = LoginScreenObject(app: app) login.waitForLoad(timeout: timeout) XCTAssertTrue(app.textFields[UITestID.Auth.usernameField].exists, "Expected login state", file: file, line: line) } static func assertOnMainApp(_ app: XCUIApplication, timeout: TimeInterval = 15, file: StaticString = #filePath, line: UInt = #line) { - let main = MainTabScreen(app: app) + let main = MainTabScreenObject(app: app) main.waitForLoad(timeout: timeout) XCTAssertTrue( app.otherElements[UITestID.Root.mainTabs].exists || main.tabBar.exists, diff --git a/iosApp/CaseraUITests/Framework/ScreenObjects.swift b/iosApp/CaseraUITests/Framework/ScreenObjects.swift index 17721e8..5324577 100644 --- a/iosApp/CaseraUITests/Framework/ScreenObjects.swift +++ b/iosApp/CaseraUITests/Framework/ScreenObjects.swift @@ -179,7 +179,7 @@ struct OnboardingCreateAccountScreen { } } -struct LoginScreen { +struct LoginScreenObject { let app: XCUIApplication private var usernameField: XCUIElement { app.textFields[UITestID.Auth.usernameField] } @@ -227,7 +227,7 @@ struct LoginScreen { } } -struct RegisterScreen { +struct RegisterScreenObject { let app: XCUIApplication private var usernameField: XCUIElement { app.textFields[UITestID.Auth.registerUsernameField] } diff --git a/iosApp/CaseraUITests/Framework/TestFlows.swift b/iosApp/CaseraUITests/Framework/TestFlows.swift index 414cf5a..716fcd7 100644 --- a/iosApp/CaseraUITests/Framework/TestFlows.swift +++ b/iosApp/CaseraUITests/Framework/TestFlows.swift @@ -2,12 +2,12 @@ import XCTest enum TestFlows { @discardableResult - static func navigateToLoginFromOnboarding(app: XCUIApplication) -> LoginScreen { + static func navigateToLoginFromOnboarding(app: XCUIApplication) -> LoginScreenObject { let welcome = OnboardingWelcomeScreen(app: app) welcome.waitForLoad() welcome.tapAlreadyHaveAccount() - let login = LoginScreen(app: app) + let login = LoginScreenObject(app: app) login.waitForLoad() return login } @@ -38,7 +38,7 @@ enum TestFlows { /// Type credentials into the login screen and tap login. /// Assumes the app is already showing the login screen. static func loginWithCredentials(app: XCUIApplication, username: String, password: String) { - let login = LoginScreen(app: app) + let login = LoginScreenObject(app: app) login.waitForLoad() login.enterUsername(username) login.enterPassword(password) @@ -77,18 +77,18 @@ enum TestFlows { } @discardableResult - static func openRegisterFromLogin(app: XCUIApplication) -> RegisterScreen { - let login: LoginScreen + static func openRegisterFromLogin(app: XCUIApplication) -> RegisterScreenObject { + let login: LoginScreenObject let loginRoot = app.otherElements[UITestID.Root.login] if loginRoot.exists || app.textFields[UITestID.Auth.usernameField].exists { - login = LoginScreen(app: app) + login = LoginScreenObject(app: app) login.waitForLoad() } else { login = navigateToLoginFromOnboarding(app: app) } login.tapSignUp() - let register = RegisterScreen(app: app) + let register = RegisterScreenObject(app: app) register.waitForLoad() return register } diff --git a/iosApp/CaseraUITests/Tests/AuthenticationTests.swift b/iosApp/CaseraUITests/Tests/AuthenticationTests.swift index e333698..a140410 100644 --- a/iosApp/CaseraUITests/Tests/AuthenticationTests.swift +++ b/iosApp/CaseraUITests/Tests/AuthenticationTests.swift @@ -18,7 +18,7 @@ final class AuthenticationTests: BaseUITestCase { let register = TestFlows.openRegisterFromLogin(app: app) register.tapCancel() - let login = LoginScreen(app: app) + let login = LoginScreenObject(app: app) login.waitForLoad(timeout: defaultTimeout) } diff --git a/iosApp/CaseraUITests/Tests/OnboardingTests.swift b/iosApp/CaseraUITests/Tests/OnboardingTests.swift index 45ebaa7..04eb53f 100644 --- a/iosApp/CaseraUITests/Tests/OnboardingTests.swift +++ b/iosApp/CaseraUITests/Tests/OnboardingTests.swift @@ -198,7 +198,7 @@ final class OnboardingTests: BaseUITestCase { welcome.tapAlreadyHaveAccount() // Log in with the seeded account to complete onboarding and reach main tabs - let login = LoginScreen(app: app) + let login = LoginScreenObject(app: app) login.waitForLoad(timeout: defaultTimeout) login.enterUsername("admin") login.enterPassword("test1234") diff --git a/iosApp/CaseraUITests/Tests/Rebuild/Suite0_OnboardingRebuildTests.swift b/iosApp/CaseraUITests/Tests/Rebuild/Suite0_OnboardingRebuildTests.swift index 3bee227..d7bd0c8 100644 --- a/iosApp/CaseraUITests/Tests/Rebuild/Suite0_OnboardingRebuildTests.swift +++ b/iosApp/CaseraUITests/Tests/Rebuild/Suite0_OnboardingRebuildTests.swift @@ -8,7 +8,7 @@ final class Suite0_OnboardingRebuildTests: BaseUITestCase { welcome.waitForLoad(timeout: defaultTimeout) welcome.tapAlreadyHaveAccount() - let login = LoginScreen(app: app) + let login = LoginScreenObject(app: app) login.waitForLoad(timeout: defaultTimeout) } diff --git a/iosApp/CaseraUITests/Tests/Rebuild/Suite2_AuthenticationRebuildTests.swift b/iosApp/CaseraUITests/Tests/Rebuild/Suite2_AuthenticationRebuildTests.swift index 31bee75..cfce359 100644 --- a/iosApp/CaseraUITests/Tests/Rebuild/Suite2_AuthenticationRebuildTests.swift +++ b/iosApp/CaseraUITests/Tests/Rebuild/Suite2_AuthenticationRebuildTests.swift @@ -20,7 +20,7 @@ final class Suite2_AuthenticationRebuildTests: BaseUITestCase { private func loginFromLoginScreen(user: RebuildTestUser = RebuildTestUserFactory.seeded) { UITestHelpers.ensureOnLoginScreen(app: app) - let login = LoginScreen(app: app) + let login = LoginScreenObject(app: app) login.waitForLoad(timeout: defaultTimeout) login.enterUsername(user.username) login.enterPassword(user.password) @@ -65,13 +65,13 @@ final class Suite2_AuthenticationRebuildTests: BaseUITestCase { func testR201_loginScreenLoadsFromOnboardingEntry() { UITestHelpers.ensureOnLoginScreen(app: app) - let login = LoginScreen(app: app) + let login = LoginScreenObject(app: app) login.waitForLoad(timeout: defaultTimeout) } func testR202_validCredentialsSubmitFromLogin() { UITestHelpers.ensureOnLoginScreen(app: app) - let login = LoginScreen(app: app) + let login = LoginScreenObject(app: app) login.waitForLoad(timeout: defaultTimeout) login.enterUsername(validUser.username) diff --git a/iosApp/CaseraUITests/Tests/Rebuild/Suite3_ResidenceRebuildTests.swift b/iosApp/CaseraUITests/Tests/Rebuild/Suite3_ResidenceRebuildTests.swift index 9dd312e..51feca4 100644 --- a/iosApp/CaseraUITests/Tests/Rebuild/Suite3_ResidenceRebuildTests.swift +++ b/iosApp/CaseraUITests/Tests/Rebuild/Suite3_ResidenceRebuildTests.swift @@ -19,13 +19,13 @@ final class Suite3_ResidenceRebuildTests: BaseUITestCase { private func loginAndOpenResidences() { UITestHelpers.ensureOnLoginScreen(app: app) - let login = LoginScreen(app: app) + let login = LoginScreenObject(app: app) login.waitForLoad(timeout: defaultTimeout) login.enterUsername("testuser") login.enterPassword("TestPass123!") app.buttons[AccessibilityIdentifiers.Authentication.loginButton].waitForExistenceOrFail(timeout: defaultTimeout).forceTap() - let main = MainTabScreen(app: app) + let main = MainTabScreenObject(app: app) main.waitForLoad(timeout: longTimeout) main.goToResidences() } diff --git a/iosApp/CaseraUITests/Tests/StabilityTests.swift b/iosApp/CaseraUITests/Tests/StabilityTests.swift index 4a16651..0132c05 100644 --- a/iosApp/CaseraUITests/Tests/StabilityTests.swift +++ b/iosApp/CaseraUITests/Tests/StabilityTests.swift @@ -115,7 +115,7 @@ final class StabilityTests: BaseUITestCase { welcome.waitForLoad(timeout: defaultTimeout) welcome.tapAlreadyHaveAccount() - let login = LoginScreen(app: app) + let login = LoginScreenObject(app: app) login.waitForLoad(timeout: defaultTimeout) // Attempt login with intentionally wrong credentials to trigger an error state