From 42f2ce5f570165661c34d4c48d69c2273e4e62b6 Mon Sep 17 00:00:00 2001 From: manuroe Date: Wed, 22 Apr 2026 14:21:09 +0200 Subject: [PATCH] Fix testUserFlow integration tests, at least locally (#5352) * Fix testUserFlow integration tests - Use 'Close' instead of 'Cancel' button label when dismissing location picker - Scroll up to make the People button visible before tapping it Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fixup! Fix testUserFlow integration tests * Integration tests: Add logout handling for MAS authentication It is useful when relaunching tests locally. It avoids them to fail because the MAS webview is already logged it from a previous session. * Swipe until the People button is hittable. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Doug --- IntegrationTests/Sources/Common.swift | 12 ++++++++++-- IntegrationTests/Sources/UserFlowTests.swift | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/IntegrationTests/Sources/Common.swift b/IntegrationTests/Sources/Common.swift index 625e53964..5f417a5e7 100644 --- a/IntegrationTests/Sources/Common.swift +++ b/IntegrationTests/Sources/Common.swift @@ -74,6 +74,14 @@ extension XCUIApplication { let webAuthenticationView = XCUIApplication(bundleIdentifier: "com.apple.SafariViewService") XCTAssertTrue(webAuthenticationView.waitForExistence(timeout: 10.0)) webAuthenticationView.tap(.top) // Tap the web view to properly focus the app again. + + // The user may already be authenticated on MAS. Sign them out. + // The button label varies by MAS version: "Sign out" or "Use another account". + let webLogoutPredicate = NSPredicate(format: "label == 'Sign out' OR label == 'Use another account'") + let webLogoutButton = webAuthenticationView.buttons.matching(webLogoutPredicate).firstMatch + if webLogoutButton.waitForExistence(timeout: 2.0) { + webLogoutButton.tap(.center) + } let webUsernameTextField = textFields["Username or Email"] XCTAssertTrue(webUsernameTextField.waitForExistence(timeout: 10.0)) @@ -130,8 +138,8 @@ extension XCUIApplication { XCTAssertTrue(logoutButton.waitForExistence(timeout: 10.0)) logoutButton.tap(.center) - // Confirm logout - let alertLogoutButton = alerts.firstMatch.buttons["Sign out"].firstMatch + // Confirm logout (Remove this device) + let alertLogoutButton = alerts.firstMatch.buttons[A11yIdentifiers.alertInfo.primaryButton].firstMatch XCTAssertTrue(alertLogoutButton.waitForExistence(timeout: 10.0)) alertLogoutButton.tap(.center) diff --git a/IntegrationTests/Sources/UserFlowTests.swift b/IntegrationTests/Sources/UserFlowTests.swift index b9f6fc18b..8f22a7cfe 100644 --- a/IntegrationTests/Sources/UserFlowTests.swift +++ b/IntegrationTests/Sources/UserFlowTests.swift @@ -145,7 +145,7 @@ class UserFlowTests: XCTestCase { allowLocationPermissionOnce() - tapOnButton("Cancel", waitForDisappearance: true) + tapOnButton("Close", waitForDisappearance: true) } private func allowLocationPermissionOnce() { @@ -190,7 +190,17 @@ class UserFlowTests: XCTestCase { XCTAssertTrue(roomHeader.waitForExistence(timeout: 10.0)) roomHeader.tap(.center) - // Open the room member details + // Swipe until the People button is hittable + let peopleButton = app.buttons[A11yIdentifiers.roomDetailsScreen.people] + if !peopleButton.isHittable { + var attempts = 0 + while !peopleButton.isHittable, attempts < 5 { + app.swipeUp() + attempts += 1 + } + } + + // Open the room members list. tapOnButton(A11yIdentifiers.roomDetailsScreen.people) // Open the first member's details. Loading members for big rooms can take a while.