Disable broken UI Tests and remove navigation. (#577)

Add locale to signalling service name.
Type strings character by character.
Add a default test timeout of 1 minute.

* Directly set UI Tests screens as the root screen.

Speeds up test runs by removing scrolling and searching for buttons.

* Parallelise test runs from Xcode (not fastlane).

* Disable signalling based tests.
This commit is contained in:
Doug
2023-02-14 16:25:24 +00:00
committed by GitHub
parent 944660800a
commit 21154c7eef
25 changed files with 107 additions and 222 deletions
@@ -19,13 +19,12 @@ import UIKit
class UITestsAppCoordinator: AppCoordinatorProtocol {
private let navigationRootCoordinator: NavigationRootCoordinator
private var mockScreens: [MockScreen] = []
private var mockScreen: MockScreen?
var notificationManager: NotificationManagerProtocol?
init() {
UIView.setAnimationsEnabled(false)
navigationRootCoordinator = NavigationRootCoordinator()
mockScreens = UITestScreenIdentifier.allCases.map { MockScreen(id: $0, navigationRootCoordinator: navigationRootCoordinator) }
ServiceLocator.shared.register(userIndicatorController: MockUserIndicatorController())
@@ -35,15 +34,11 @@ class UITestsAppCoordinator: AppCoordinatorProtocol {
}
func start() {
let rootCoordinator = UITestsRootCoordinator(mockScreens: mockScreens) { id in
guard let screen = self.mockScreens.first(where: { $0.id == id }) else {
fatalError()
}
self.navigationRootCoordinator.setRootCoordinator(screen.coordinator)
}
guard let screenID = Tests.screenID else { fatalError("Unable to launch with unknown screen.") }
navigationRootCoordinator.setRootCoordinator(rootCoordinator)
let mockScreen = MockScreen(id: screenID)
navigationRootCoordinator.setRootCoordinator(mockScreen.coordinator)
self.mockScreen = mockScreen
Bundle.elementFallbackLanguage = "en"
}
@@ -55,14 +50,12 @@ class UITestsAppCoordinator: AppCoordinatorProtocol {
@MainActor
class MockScreen: Identifiable {
let id: UITestScreenIdentifier
let id: UITestsScreenIdentifier
private let navigationRootCoordinator: NavigationRootCoordinator
private var retainedState = [Any]()
init(id: UITestScreenIdentifier, navigationRootCoordinator: NavigationRootCoordinator) {
init(id: UITestsScreenIdentifier) {
self.id = id
self.navigationRootCoordinator = navigationRootCoordinator
}
lazy var coordinator: CoordinatorProtocol = {
@@ -1,42 +0,0 @@
//
// Copyright 2022 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import SwiftUI
class UITestsRootCoordinator: CoordinatorProtocol {
let mockScreens: [MockScreen]
var selectionCallback: ((UITestScreenIdentifier) -> Void)?
init(mockScreens: [MockScreen], selectionCallback: ((UITestScreenIdentifier) -> Void)? = nil) {
self.mockScreens = mockScreens
self.selectionCallback = selectionCallback
}
func toPresentable() -> AnyView {
AnyView(body)
}
private var body: some View {
List(mockScreens) { coordinator in
Button(coordinator.id.description) { [weak self] in
self?.selectionCallback?(coordinator.id)
}
.accessibilityIdentifier(coordinator.id.rawValue)
}
.padding(.top, 50) // Add some top padding so the iPad split screen button isn't tapped by mistake
.listStyle(.plain)
}
}
@@ -16,7 +16,7 @@
import Foundation
enum UITestScreenIdentifier: String {
enum UITestsScreenIdentifier: String {
case login
case serverSelection
case serverSelectionNonModal
@@ -45,14 +45,12 @@ enum UITestScreenIdentifier: String {
case roomMemberDetailsScreen
}
extension UITestScreenIdentifier: CustomStringConvertible {
extension UITestsScreenIdentifier: CustomStringConvertible {
var description: String {
rawValue.titlecased()
}
}
extension UITestScreenIdentifier: CaseIterable { }
private extension String {
func titlecased() -> String {
replacingOccurrences(of: "([A-Z])",
@@ -50,7 +50,7 @@ enum UITestsSignalError: Error {
enum UITestsSignalling {
/// The Bonjour service name used for the connection. The device name
/// is included to allow UI tests to run on multiple devices simultaneously.
private static let serviceName = "UITestsSignalling \(UIDevice.current.name)"
private static let serviceName = "UITestsSignalling \(UIDevice.current.name) (\(Locale.current.identifier))"
/// The Bonjour service type used for the connection.
private static let serviceType = "_signalling._udp."
/// The Bonjour domain used for the connection.