Re-write integration test login for OIDC. (#3997)

* Re-write integration test login for OIDC.

* Fix integration test logout button not being visible.

---------

Co-authored-by: Stefan Ceriu <stefanc@matrix.org>
This commit is contained in:
Doug
2025-04-09 08:57:31 +01:00
committed by GitHub
parent 8344006ee0
commit 56476f8bb5
+27 -15
View File
@@ -36,25 +36,26 @@ extension XCUIApplication {
XCTAssertTrue(continueButton.waitForExistence(timeout: 30.0)) XCTAssertTrue(continueButton.waitForExistence(timeout: 30.0))
continueButton.tapCenter() continueButton.tapCenter()
let usernameTextField = textFields[A11yIdentifiers.loginScreen.emailUsername] let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
XCTAssertTrue(usernameTextField.waitForExistence(timeout: 10.0)) let webAuthenticationSessionAlertContinueButton = springboard.buttons["Continue"].firstMatch
XCTAssertTrue(webAuthenticationSessionAlertContinueButton.waitForExistence(timeout: 30.0))
webAuthenticationSessionAlertContinueButton.tapCenter()
usernameTextField.clearAndTypeText(username, app: self) let webAuthenticationView = webViews.firstMatch
XCTAssertTrue(webAuthenticationView.waitForExistence(timeout: 10.0))
webAuthenticationView.tap() // Tap the web view to properly focus the app again.
let passwordTextField = secureTextFields[A11yIdentifiers.loginScreen.password] let webUsernameTextField = textFields["Username"]
XCTAssertTrue(passwordTextField.waitForExistence(timeout: 10.0)) XCTAssertTrue(webUsernameTextField.waitForExistence(timeout: 10.0))
webUsernameTextField.clearAndTypeText(username, app: self)
passwordTextField.clearAndTypeText(password, app: self) let webPasswordTextField = secureTextFields["Password"]
XCTAssertTrue(webPasswordTextField.waitForExistence(timeout: 10.0))
webPasswordTextField.clearAndTypeText(password, app: self)
let nextButton = buttons[A11yIdentifiers.loginScreen.continue] let webLoginButton = webAuthenticationView.buttons["Continue"]
XCTAssertTrue(nextButton.waitForExistence(timeout: 10.0)) XCTAssertTrue(webLoginButton.waitForExistence(timeout: 10.0))
XCTAssertTrue(nextButton.isEnabled) webLoginButton.tapCenter()
nextButton.tapCenter()
// Wait for login to finish
currentTestCase.expectation(for: doesNotExistPredicate, evaluatedWith: usernameTextField)
currentTestCase.waitForExpectations(timeout: 300.0)
// Handle the password saving dialog // Handle the password saving dialog
let savePasswordButton = buttons["Save Password"] let savePasswordButton = buttons["Save Password"]
@@ -65,6 +66,14 @@ extension XCUIApplication {
savePasswordButton.tapCenter() savePasswordButton.tapCenter()
} }
let webConsentButton = webAuthenticationView.buttons["Continue"]
XCTAssertTrue(webConsentButton.waitForExistence(timeout: 10.0))
webConsentButton.tapCenter()
// Wait for login to finish
currentTestCase.expectation(for: doesNotExistPredicate, evaluatedWith: webUsernameTextField)
currentTestCase.waitForExpectations(timeout: 300.0)
// Wait for the home screen to become visible. // Wait for the home screen to become visible.
let profileButton = buttons[A11yIdentifiers.homeScreen.userAvatar] let profileButton = buttons[A11yIdentifiers.homeScreen.userAvatar]
// Timeouts are huge because we're waiting for the server. // Timeouts are huge because we're waiting for the server.
@@ -81,6 +90,9 @@ extension XCUIApplication {
// `Failed to scroll to visible (by AX action) Button` https://stackoverflow.com/a/33534187/730924 // `Failed to scroll to visible (by AX action) Button` https://stackoverflow.com/a/33534187/730924
profileButton.tapCenter() profileButton.tapCenter()
// Make the logout button visible
swipeUp()
// Logout // Logout
let logoutButton = buttons[A11yIdentifiers.settingsScreen.logout] let logoutButton = buttons[A11yIdentifiers.settingsScreen.logout]
XCTAssertTrue(logoutButton.waitForExistence(timeout: 10.0)) XCTAssertTrue(logoutButton.waitForExistence(timeout: 10.0))