mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00

* Disable image and document picker integration tests as they randomly fail to load and are flakey. * Delete any pre-existing log files * Various tracing tweaks and fixes: - delete the custom tracing log levels as we can't control their ouput - implement comparable on them - change default levels only if the new chosen level increases their verbosity * Make logging targets mandatory and fix their logging levels * Switch back to using the `run_tests` reset simulator flag as `fastlane snapshot reset_simulators` was too generic and slow * Switch all integration test taps to `tapCenter` (nee forceTap) after noticing missed taps on CI. * Make the logging file prefix explicit, let the main app not use one. * Rename tracing configuration `target` to `currentTarget`
99 lines
4.1 KiB
Swift
99 lines
4.1 KiB
Swift
//
|
|
// Copyright 2023, 2024 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
// Please see LICENSE in the repository root for full details.
|
|
//
|
|
|
|
import XCTest
|
|
|
|
extension XCUIApplication {
|
|
func login(currentTestCase: XCTestCase) {
|
|
let getStartedButton = buttons[A11yIdentifiers.authenticationStartScreen.signIn]
|
|
|
|
XCTAssertTrue(getStartedButton.waitForExistence(timeout: 10.0))
|
|
getStartedButton.tapCenter()
|
|
|
|
let changeHomeserverButton = buttons[A11yIdentifiers.serverConfirmationScreen.changeServer]
|
|
XCTAssertTrue(changeHomeserverButton.waitForExistence(timeout: 10.0))
|
|
changeHomeserverButton.tapCenter()
|
|
|
|
let homeserverTextField = textFields[A11yIdentifiers.changeServerScreen.server]
|
|
XCTAssertTrue(homeserverTextField.waitForExistence(timeout: 10.0))
|
|
|
|
homeserverTextField.clearAndTypeText(homeserver)
|
|
|
|
let confirmButton = buttons[A11yIdentifiers.changeServerScreen.continue]
|
|
XCTAssertTrue(confirmButton.waitForExistence(timeout: 10.0))
|
|
confirmButton.tapCenter()
|
|
|
|
// Wait for server confirmation to finish
|
|
let doesNotExistPredicate = NSPredicate(format: "exists == 0")
|
|
currentTestCase.expectation(for: doesNotExistPredicate, evaluatedWith: confirmButton)
|
|
currentTestCase.waitForExpectations(timeout: 300.0)
|
|
|
|
let continueButton = buttons[A11yIdentifiers.serverConfirmationScreen.continue]
|
|
XCTAssertTrue(continueButton.waitForExistence(timeout: 30.0))
|
|
continueButton.tapCenter()
|
|
|
|
let usernameTextField = textFields[A11yIdentifiers.loginScreen.emailUsername]
|
|
XCTAssertTrue(usernameTextField.waitForExistence(timeout: 10.0))
|
|
|
|
usernameTextField.clearAndTypeText(username)
|
|
|
|
let passwordTextField = secureTextFields[A11yIdentifiers.loginScreen.password]
|
|
XCTAssertTrue(passwordTextField.waitForExistence(timeout: 10.0))
|
|
|
|
passwordTextField.clearAndTypeText(password)
|
|
|
|
let nextButton = buttons[A11yIdentifiers.loginScreen.continue]
|
|
XCTAssertTrue(nextButton.waitForExistence(timeout: 10.0))
|
|
XCTAssertTrue(nextButton.isEnabled)
|
|
|
|
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) {
|
|
// Tapping the sheet button while animating upwards fails. Wait for it to settle
|
|
sleep(1)
|
|
|
|
savePasswordButton.tapCenter()
|
|
}
|
|
|
|
// Wait for the home screen to become visible.
|
|
let profileButton = buttons[A11yIdentifiers.homeScreen.userAvatar]
|
|
// Timeouts are huge because we're waiting for the server.
|
|
XCTAssertTrue(profileButton.waitForExistence(timeout: 300.0))
|
|
}
|
|
|
|
func logout() {
|
|
// On first login when multiple sheets get presented the profile button is not hittable
|
|
// Moving the scroll fixed it for some obscure reason
|
|
swipeDown()
|
|
|
|
let profileButton = buttons[A11yIdentifiers.homeScreen.userAvatar]
|
|
|
|
// `Failed to scroll to visible (by AX action) Button` https://stackoverflow.com/a/33534187/730924
|
|
profileButton.tapCenter()
|
|
|
|
// Logout
|
|
let logoutButton = buttons[A11yIdentifiers.settingsScreen.logout]
|
|
XCTAssertTrue(logoutButton.waitForExistence(timeout: 10.0))
|
|
logoutButton.tapCenter()
|
|
|
|
// Confirm logout
|
|
let alertLogoutButton = alerts.firstMatch.buttons["Sign out"]
|
|
XCTAssertTrue(alertLogoutButton.waitForExistence(timeout: 10.0))
|
|
alertLogoutButton.tapCenter()
|
|
|
|
// Check that we're back on the login screen
|
|
let getStartedButton = buttons[A11yIdentifiers.authenticationStartScreen.signIn]
|
|
XCTAssertTrue(getStartedButton.waitForExistence(timeout: 10.0))
|
|
}
|
|
}
|