Fix test build errors: isCacheValid ttlMs parameter and screen object name conflicts
SKIE doesn't expose Kotlin default parameters to Swift, so isCacheValid calls need explicit ttlMs argument. Renamed struct-based screen objects to avoid ambiguity with class-based PageObjects (LoginScreenObject, RegisterScreenObject, MainTabScreenObject). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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] }
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user