From 07e2329aeb993cd8a890424425a7504897acc856 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Mon, 28 Apr 2025 15:00:04 +0200 Subject: [PATCH] UI tests fix --- .../Screens/CreatePollScreen/PollFormScreenCoordinator.swift | 4 +++- .../Screens/CreatePollScreen/PollFormScreenModels.swift | 5 +++-- .../Screens/CreatePollScreen/PollFormScreenViewModel.swift | 4 ++-- ElementX/Sources/UITests/UITestsAppCoordinator.swift | 2 +- UITests/Sources/AuthenticationFlowCoordinatorTests.swift | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenCoordinator.swift b/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenCoordinator.swift index f7fc20177..b80cac0dd 100644 --- a/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenCoordinator.swift +++ b/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenCoordinator.swift @@ -10,6 +10,8 @@ import SwiftUI struct PollFormScreenCoordinatorParameters { let mode: PollFormMode + /// The max number of allowed options, default is 20, but for faster UI tests we allow the value to be lower + var maxNumberOfOptions = 20 } enum PollFormScreenCoordinatorAction { @@ -28,7 +30,7 @@ final class PollFormScreenCoordinator: CoordinatorProtocol { } init(parameters: PollFormScreenCoordinatorParameters) { - viewModel = PollFormScreenViewModel(mode: parameters.mode) + viewModel = PollFormScreenViewModel(mode: parameters.mode, maxNumberOfOptions: parameters.maxNumberOfOptions) } func start() { diff --git a/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenModels.swift b/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenModels.swift index 10bcaf7ee..77d702a05 100644 --- a/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenModels.swift +++ b/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenModels.swift @@ -15,11 +15,12 @@ enum PollFormScreenViewModelAction: Equatable { struct PollFormScreenViewState: BindableState { let mode: PollFormMode - let maxNumberOfOptions = 20 + var maxNumberOfOptions: Int var bindings: PollFormScreenViewStateBindings = .init() - init(mode: PollFormMode) { + init(mode: PollFormMode, maxNumberOfOptions: Int) { self.mode = mode + self.maxNumberOfOptions = maxNumberOfOptions switch mode { case .new: diff --git a/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenViewModel.swift b/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenViewModel.swift index 456bc0aff..213c652a3 100644 --- a/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenViewModel.swift +++ b/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenViewModel.swift @@ -17,8 +17,8 @@ class PollFormScreenViewModel: PollFormScreenViewModelType, PollFormScreenViewMo actionsSubject.eraseToAnyPublisher() } - init(mode: PollFormMode) { - super.init(initialViewState: .init(mode: mode)) + init(mode: PollFormMode, maxNumberOfOptions: Int) { + super.init(initialViewState: .init(mode: mode, maxNumberOfOptions: maxNumberOfOptions)) } // MARK: - Public diff --git a/ElementX/Sources/UITests/UITestsAppCoordinator.swift b/ElementX/Sources/UITests/UITestsAppCoordinator.swift index 62a73efa3..152cf7384 100644 --- a/ElementX/Sources/UITests/UITestsAppCoordinator.swift +++ b/ElementX/Sources/UITests/UITestsAppCoordinator.swift @@ -647,7 +647,7 @@ class MockScreen: Identifiable { return navigationStackCoordinator case .createPoll: let navigationStackCoordinator = NavigationStackCoordinator() - let coordinator = PollFormScreenCoordinator(parameters: .init(mode: .new)) + let coordinator = PollFormScreenCoordinator(parameters: .init(mode: .new, maxNumberOfOptions: 10)) navigationStackCoordinator.setRootCoordinator(coordinator) return navigationStackCoordinator case .encryptionSettings, .encryptionSettingsOutOfSync: diff --git a/UITests/Sources/AuthenticationFlowCoordinatorTests.swift b/UITests/Sources/AuthenticationFlowCoordinatorTests.swift index 24b179ba1..70d61ade6 100644 --- a/UITests/Sources/AuthenticationFlowCoordinatorTests.swift +++ b/UITests/Sources/AuthenticationFlowCoordinatorTests.swift @@ -115,7 +115,7 @@ class AuthenticationFlowCoordinatorUITests: XCTestCase { app.buttons[A11yIdentifiers.serverConfirmationScreen.continue].tap() let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") - XCTAssertTrue(springboard.staticTexts["“ElementX” Wants to Use “company.com” to Sign In"].waitForExistence(timeout: 2), + XCTAssertTrue(springboard.staticTexts["“ElementX” Wants to Use “company.com” to Sign In"].waitForExistence(timeout: 4), "The web authentication prompt should be shown after selecting a homeserver with OIDC.") } }