From 56476f8bb53d216567816e9b48fff00a8b725302 Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Wed, 9 Apr 2025 08:57:31 +0100 Subject: [PATCH] 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 --- IntegrationTests/Sources/Common.swift | 42 +++++++++++++++++---------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/IntegrationTests/Sources/Common.swift b/IntegrationTests/Sources/Common.swift index 79dde2eb8..5ee087cf9 100644 --- a/IntegrationTests/Sources/Common.swift +++ b/IntegrationTests/Sources/Common.swift @@ -36,26 +36,27 @@ extension XCUIApplication { XCTAssertTrue(continueButton.waitForExistence(timeout: 30.0)) continueButton.tapCenter() - let usernameTextField = textFields[A11yIdentifiers.loginScreen.emailUsername] - XCTAssertTrue(usernameTextField.waitForExistence(timeout: 10.0)) + let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") + 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] - XCTAssertTrue(passwordTextField.waitForExistence(timeout: 10.0)) + let webUsernameTextField = textFields["Username"] + 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] - XCTAssertTrue(nextButton.waitForExistence(timeout: 10.0)) - XCTAssertTrue(nextButton.isEnabled) + let webLoginButton = webAuthenticationView.buttons["Continue"] + XCTAssertTrue(webLoginButton.waitForExistence(timeout: 10.0)) + 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 let savePasswordButton = buttons["Save Password"] if savePasswordButton.waitForExistence(timeout: 10.0) { @@ -64,6 +65,14 @@ extension XCUIApplication { 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. 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 profileButton.tapCenter() + // Make the logout button visible + swipeUp() + // Logout let logoutButton = buttons[A11yIdentifiers.settingsScreen.logout] XCTAssertTrue(logoutButton.waitForExistence(timeout: 10.0))