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 <douglase@element.io>
This commit is contained in:
manuroe
2026-04-22 14:21:09 +02:00
committed by GitHub
parent e9fd29e100
commit 42f2ce5f57
2 changed files with 22 additions and 4 deletions

View File

@@ -75,6 +75,14 @@ extension XCUIApplication {
XCTAssertTrue(webAuthenticationView.waitForExistence(timeout: 10.0)) XCTAssertTrue(webAuthenticationView.waitForExistence(timeout: 10.0))
webAuthenticationView.tap(.top) // Tap the web view to properly focus the app again. 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"] let webUsernameTextField = textFields["Username or Email"]
XCTAssertTrue(webUsernameTextField.waitForExistence(timeout: 10.0)) XCTAssertTrue(webUsernameTextField.waitForExistence(timeout: 10.0))
webUsernameTextField.clearAndTypeText(username, app: self) webUsernameTextField.clearAndTypeText(username, app: self)
@@ -130,8 +138,8 @@ extension XCUIApplication {
XCTAssertTrue(logoutButton.waitForExistence(timeout: 10.0)) XCTAssertTrue(logoutButton.waitForExistence(timeout: 10.0))
logoutButton.tap(.center) logoutButton.tap(.center)
// Confirm logout // Confirm logout (Remove this device)
let alertLogoutButton = alerts.firstMatch.buttons["Sign out"].firstMatch let alertLogoutButton = alerts.firstMatch.buttons[A11yIdentifiers.alertInfo.primaryButton].firstMatch
XCTAssertTrue(alertLogoutButton.waitForExistence(timeout: 10.0)) XCTAssertTrue(alertLogoutButton.waitForExistence(timeout: 10.0))
alertLogoutButton.tap(.center) alertLogoutButton.tap(.center)

View File

@@ -145,7 +145,7 @@ class UserFlowTests: XCTestCase {
allowLocationPermissionOnce() allowLocationPermissionOnce()
tapOnButton("Cancel", waitForDisappearance: true) tapOnButton("Close", waitForDisappearance: true)
} }
private func allowLocationPermissionOnce() { private func allowLocationPermissionOnce() {
@@ -190,7 +190,17 @@ class UserFlowTests: XCTestCase {
XCTAssertTrue(roomHeader.waitForExistence(timeout: 10.0)) XCTAssertTrue(roomHeader.waitForExistence(timeout: 10.0))
roomHeader.tap(.center) 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) tapOnButton(A11yIdentifiers.roomDetailsScreen.people)
// Open the first member's details. Loading members for big rooms can take a while. // Open the first member's details. Loading members for big rooms can take a while.