mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
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:
@@ -36,26 +36,27 @@ 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"]
|
||||||
if savePasswordButton.waitForExistence(timeout: 10.0) {
|
if savePasswordButton.waitForExistence(timeout: 10.0) {
|
||||||
@@ -64,6 +65,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]
|
||||||
@@ -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))
|
||||||
|
|||||||
Reference in New Issue
Block a user