* Fix logging/alerts during OIDC cancellation. - Cancelling from within the web view wasn't being handled since moving the UserIndicatorController into the presenter. - The WAS canceledLogin error code is also used when the system cancels the login. When the system cancels there's a failure reason included in the error. * Allow UI tests to tap on any point within a view. * Make the homeserver optional in integration tests. * Dismiss the keyboard after entering a username to reveal the password text field. Do the same after entering the password field too, just in case. * Add a loop while waiting for the WAS prompt to be shown.
49 lines
1.6 KiB
Swift
49 lines
1.6 KiB
Swift
//
|
|
// Copyright 2022-2024 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import SwiftUI
|
|
import XCTest
|
|
|
|
extension XCUIElement {
|
|
func clearAndTypeText(_ text: String, app: XCUIApplication) {
|
|
tap(.center)
|
|
|
|
app.showKeyboardIfNeeded()
|
|
|
|
guard let currentValue = value as? String else {
|
|
XCTFail("Tried to clear and type text into a non string value")
|
|
return
|
|
}
|
|
|
|
let deleteString = String(repeating: XCUIKeyboardKey.delete.rawValue, count: currentValue.count)
|
|
typeText(deleteString)
|
|
|
|
for character in text {
|
|
typeText(String(character))
|
|
}
|
|
}
|
|
|
|
func tap(_ point: UnitPoint) {
|
|
let coordinate = coordinate(withNormalizedOffset: .init(dx: point.x, dy: point.y))
|
|
coordinate.tap()
|
|
}
|
|
}
|
|
|
|
extension XCUIApplication {
|
|
/// Ensures the software keyboard is shown on an iPad when a text field is focussed.
|
|
///
|
|
/// Note: Whilst this could be added on XCUIElement to more closely tie it to a text field, it requires the
|
|
/// app instance anyway, and some of our tests assert that a default focus has been set on the text field,
|
|
/// so having a method that would set the focus and show the keyboard isn't always desirable.
|
|
func showKeyboardIfNeeded() {
|
|
if UIDevice.current.userInterfaceIdiom == .pad, keyboards.count == 0 {
|
|
buttons["Keyboard"].tap()
|
|
buttons["Show Keyboard"].tap()
|
|
}
|
|
}
|
|
}
|