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:
@@ -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)
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user