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 {
|
@Suite struct CacheValidationTests {
|
||||||
|
|
||||||
@Test func cacheTimeZeroIsInvalid() {
|
@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() {
|
@Test func recentCacheTimeIsValid() {
|
||||||
// 5 minutes ago should be valid (well within the 1-hour timeout)
|
// 5 minutes ago should be valid (well within the 1-hour timeout)
|
||||||
let fiveMinutesAgo = Int64(Date().timeIntervalSince1970 * 1000) - (5 * 60 * 1000)
|
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() {
|
@Test func expiredCacheTimeIsInvalid() {
|
||||||
// 2 hours ago should be invalid (past the 1-hour timeout)
|
// 2 hours ago should be invalid (past the 1-hour timeout)
|
||||||
let twoHoursAgo = Int64(Date().timeIntervalSince1970 * 1000) - (2 * 60 * 60 * 1000)
|
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() {
|
@Test func cacheTimeoutConstantIsOneHour() {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ struct VerificationScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MainTabScreen {
|
struct MainTabScreenObject {
|
||||||
let app: XCUIApplication
|
let app: XCUIApplication
|
||||||
|
|
||||||
var tabBar: XCUIElement { app.tabBars.firstMatch }
|
var tabBar: XCUIElement { app.tabBars.firstMatch }
|
||||||
@@ -160,13 +160,13 @@ struct ResidenceFormScreen {
|
|||||||
|
|
||||||
enum RebuildSessionAssertions {
|
enum RebuildSessionAssertions {
|
||||||
static func assertOnLogin(_ app: XCUIApplication, timeout: TimeInterval = 15, file: StaticString = #filePath, line: UInt = #line) {
|
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)
|
login.waitForLoad(timeout: timeout)
|
||||||
XCTAssertTrue(app.textFields[UITestID.Auth.usernameField].exists, "Expected login state", file: file, line: line)
|
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) {
|
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)
|
main.waitForLoad(timeout: timeout)
|
||||||
XCTAssertTrue(
|
XCTAssertTrue(
|
||||||
app.otherElements[UITestID.Root.mainTabs].exists || main.tabBar.exists,
|
app.otherElements[UITestID.Root.mainTabs].exists || main.tabBar.exists,
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ struct OnboardingCreateAccountScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct LoginScreen {
|
struct LoginScreenObject {
|
||||||
let app: XCUIApplication
|
let app: XCUIApplication
|
||||||
|
|
||||||
private var usernameField: XCUIElement { app.textFields[UITestID.Auth.usernameField] }
|
private var usernameField: XCUIElement { app.textFields[UITestID.Auth.usernameField] }
|
||||||
@@ -227,7 +227,7 @@ struct LoginScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RegisterScreen {
|
struct RegisterScreenObject {
|
||||||
let app: XCUIApplication
|
let app: XCUIApplication
|
||||||
|
|
||||||
private var usernameField: XCUIElement { app.textFields[UITestID.Auth.registerUsernameField] }
|
private var usernameField: XCUIElement { app.textFields[UITestID.Auth.registerUsernameField] }
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ import XCTest
|
|||||||
|
|
||||||
enum TestFlows {
|
enum TestFlows {
|
||||||
@discardableResult
|
@discardableResult
|
||||||
static func navigateToLoginFromOnboarding(app: XCUIApplication) -> LoginScreen {
|
static func navigateToLoginFromOnboarding(app: XCUIApplication) -> LoginScreenObject {
|
||||||
let welcome = OnboardingWelcomeScreen(app: app)
|
let welcome = OnboardingWelcomeScreen(app: app)
|
||||||
welcome.waitForLoad()
|
welcome.waitForLoad()
|
||||||
welcome.tapAlreadyHaveAccount()
|
welcome.tapAlreadyHaveAccount()
|
||||||
|
|
||||||
let login = LoginScreen(app: app)
|
let login = LoginScreenObject(app: app)
|
||||||
login.waitForLoad()
|
login.waitForLoad()
|
||||||
return login
|
return login
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ enum TestFlows {
|
|||||||
/// Type credentials into the login screen and tap login.
|
/// Type credentials into the login screen and tap login.
|
||||||
/// Assumes the app is already showing the login screen.
|
/// Assumes the app is already showing the login screen.
|
||||||
static func loginWithCredentials(app: XCUIApplication, username: String, password: String) {
|
static func loginWithCredentials(app: XCUIApplication, username: String, password: String) {
|
||||||
let login = LoginScreen(app: app)
|
let login = LoginScreenObject(app: app)
|
||||||
login.waitForLoad()
|
login.waitForLoad()
|
||||||
login.enterUsername(username)
|
login.enterUsername(username)
|
||||||
login.enterPassword(password)
|
login.enterPassword(password)
|
||||||
@@ -77,18 +77,18 @@ enum TestFlows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
static func openRegisterFromLogin(app: XCUIApplication) -> RegisterScreen {
|
static func openRegisterFromLogin(app: XCUIApplication) -> RegisterScreenObject {
|
||||||
let login: LoginScreen
|
let login: LoginScreenObject
|
||||||
let loginRoot = app.otherElements[UITestID.Root.login]
|
let loginRoot = app.otherElements[UITestID.Root.login]
|
||||||
if loginRoot.exists || app.textFields[UITestID.Auth.usernameField].exists {
|
if loginRoot.exists || app.textFields[UITestID.Auth.usernameField].exists {
|
||||||
login = LoginScreen(app: app)
|
login = LoginScreenObject(app: app)
|
||||||
login.waitForLoad()
|
login.waitForLoad()
|
||||||
} else {
|
} else {
|
||||||
login = navigateToLoginFromOnboarding(app: app)
|
login = navigateToLoginFromOnboarding(app: app)
|
||||||
}
|
}
|
||||||
login.tapSignUp()
|
login.tapSignUp()
|
||||||
|
|
||||||
let register = RegisterScreen(app: app)
|
let register = RegisterScreenObject(app: app)
|
||||||
register.waitForLoad()
|
register.waitForLoad()
|
||||||
return register
|
return register
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ final class AuthenticationTests: BaseUITestCase {
|
|||||||
let register = TestFlows.openRegisterFromLogin(app: app)
|
let register = TestFlows.openRegisterFromLogin(app: app)
|
||||||
register.tapCancel()
|
register.tapCancel()
|
||||||
|
|
||||||
let login = LoginScreen(app: app)
|
let login = LoginScreenObject(app: app)
|
||||||
login.waitForLoad(timeout: defaultTimeout)
|
login.waitForLoad(timeout: defaultTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ final class OnboardingTests: BaseUITestCase {
|
|||||||
welcome.tapAlreadyHaveAccount()
|
welcome.tapAlreadyHaveAccount()
|
||||||
|
|
||||||
// Log in with the seeded account to complete onboarding and reach main tabs
|
// 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.waitForLoad(timeout: defaultTimeout)
|
||||||
login.enterUsername("admin")
|
login.enterUsername("admin")
|
||||||
login.enterPassword("test1234")
|
login.enterPassword("test1234")
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ final class Suite0_OnboardingRebuildTests: BaseUITestCase {
|
|||||||
welcome.waitForLoad(timeout: defaultTimeout)
|
welcome.waitForLoad(timeout: defaultTimeout)
|
||||||
welcome.tapAlreadyHaveAccount()
|
welcome.tapAlreadyHaveAccount()
|
||||||
|
|
||||||
let login = LoginScreen(app: app)
|
let login = LoginScreenObject(app: app)
|
||||||
login.waitForLoad(timeout: defaultTimeout)
|
login.waitForLoad(timeout: defaultTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ final class Suite2_AuthenticationRebuildTests: BaseUITestCase {
|
|||||||
|
|
||||||
private func loginFromLoginScreen(user: RebuildTestUser = RebuildTestUserFactory.seeded) {
|
private func loginFromLoginScreen(user: RebuildTestUser = RebuildTestUserFactory.seeded) {
|
||||||
UITestHelpers.ensureOnLoginScreen(app: app)
|
UITestHelpers.ensureOnLoginScreen(app: app)
|
||||||
let login = LoginScreen(app: app)
|
let login = LoginScreenObject(app: app)
|
||||||
login.waitForLoad(timeout: defaultTimeout)
|
login.waitForLoad(timeout: defaultTimeout)
|
||||||
login.enterUsername(user.username)
|
login.enterUsername(user.username)
|
||||||
login.enterPassword(user.password)
|
login.enterPassword(user.password)
|
||||||
@@ -65,13 +65,13 @@ final class Suite2_AuthenticationRebuildTests: BaseUITestCase {
|
|||||||
|
|
||||||
func testR201_loginScreenLoadsFromOnboardingEntry() {
|
func testR201_loginScreenLoadsFromOnboardingEntry() {
|
||||||
UITestHelpers.ensureOnLoginScreen(app: app)
|
UITestHelpers.ensureOnLoginScreen(app: app)
|
||||||
let login = LoginScreen(app: app)
|
let login = LoginScreenObject(app: app)
|
||||||
login.waitForLoad(timeout: defaultTimeout)
|
login.waitForLoad(timeout: defaultTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testR202_validCredentialsSubmitFromLogin() {
|
func testR202_validCredentialsSubmitFromLogin() {
|
||||||
UITestHelpers.ensureOnLoginScreen(app: app)
|
UITestHelpers.ensureOnLoginScreen(app: app)
|
||||||
let login = LoginScreen(app: app)
|
let login = LoginScreenObject(app: app)
|
||||||
login.waitForLoad(timeout: defaultTimeout)
|
login.waitForLoad(timeout: defaultTimeout)
|
||||||
|
|
||||||
login.enterUsername(validUser.username)
|
login.enterUsername(validUser.username)
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ final class Suite3_ResidenceRebuildTests: BaseUITestCase {
|
|||||||
|
|
||||||
private func loginAndOpenResidences() {
|
private func loginAndOpenResidences() {
|
||||||
UITestHelpers.ensureOnLoginScreen(app: app)
|
UITestHelpers.ensureOnLoginScreen(app: app)
|
||||||
let login = LoginScreen(app: app)
|
let login = LoginScreenObject(app: app)
|
||||||
login.waitForLoad(timeout: defaultTimeout)
|
login.waitForLoad(timeout: defaultTimeout)
|
||||||
login.enterUsername("testuser")
|
login.enterUsername("testuser")
|
||||||
login.enterPassword("TestPass123!")
|
login.enterPassword("TestPass123!")
|
||||||
app.buttons[AccessibilityIdentifiers.Authentication.loginButton].waitForExistenceOrFail(timeout: defaultTimeout).forceTap()
|
app.buttons[AccessibilityIdentifiers.Authentication.loginButton].waitForExistenceOrFail(timeout: defaultTimeout).forceTap()
|
||||||
|
|
||||||
let main = MainTabScreen(app: app)
|
let main = MainTabScreenObject(app: app)
|
||||||
main.waitForLoad(timeout: longTimeout)
|
main.waitForLoad(timeout: longTimeout)
|
||||||
main.goToResidences()
|
main.goToResidences()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ final class StabilityTests: BaseUITestCase {
|
|||||||
welcome.waitForLoad(timeout: defaultTimeout)
|
welcome.waitForLoad(timeout: defaultTimeout)
|
||||||
welcome.tapAlreadyHaveAccount()
|
welcome.tapAlreadyHaveAccount()
|
||||||
|
|
||||||
let login = LoginScreen(app: app)
|
let login = LoginScreenObject(app: app)
|
||||||
login.waitForLoad(timeout: defaultTimeout)
|
login.waitForLoad(timeout: defaultTimeout)
|
||||||
|
|
||||||
// Attempt login with intentionally wrong credentials to trigger an error state
|
// Attempt login with intentionally wrong credentials to trigger an error state
|
||||||
|
|||||||
Reference in New Issue
Block a user