From e024c1f2646535b09314e17f406a565ad4f5f28c Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Mon, 28 Apr 2025 15:11:06 +0200 Subject: [PATCH] possible fix for flaky UI tests - increased the time for the oidc selection alert check - for the poll screen creation, in the test only we reduced the number of options to 10 --- .../Screens/CreatePollScreen/PollFormScreenCoordinator.swift | 4 ++-- .../Screens/CreatePollScreen/PollFormScreenModels.swift | 2 +- .../Screens/CreatePollScreen/PollFormScreenViewModel.swift | 4 ++-- UITests/Sources/PollFormScreenTests.swift | 2 +- .../pollFormScreen.testMaxOptions-iPad-18-4-en-GB.png | 4 ++-- .../pollFormScreen.testMaxOptions-iPhone-18-4-en-GB.png | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenCoordinator.swift b/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenCoordinator.swift index b80cac0dd..927efb9cb 100644 --- a/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenCoordinator.swift +++ b/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenCoordinator.swift @@ -10,8 +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 + /// The max number of allowed options, if no value provided the default value of the view model will be used. + var maxNumberOfOptions: Int? } enum PollFormScreenCoordinatorAction { diff --git a/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenModels.swift b/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenModels.swift index 77d702a05..e4343cb30 100644 --- a/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenModels.swift +++ b/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenModels.swift @@ -15,7 +15,7 @@ enum PollFormScreenViewModelAction: Equatable { struct PollFormScreenViewState: BindableState { let mode: PollFormMode - var maxNumberOfOptions: Int + let maxNumberOfOptions: Int var bindings: PollFormScreenViewStateBindings = .init() init(mode: PollFormMode, maxNumberOfOptions: Int) { diff --git a/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenViewModel.swift b/ElementX/Sources/Screens/CreatePollScreen/PollFormScreenViewModel.swift index 213c652a3..a8734ab67 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, maxNumberOfOptions: Int) { - super.init(initialViewState: .init(mode: mode, maxNumberOfOptions: maxNumberOfOptions)) + init(mode: PollFormMode, maxNumberOfOptions: Int? = nil) { + super.init(initialViewState: .init(mode: mode, maxNumberOfOptions: maxNumberOfOptions ?? 20)) } // MARK: - Public diff --git a/UITests/Sources/PollFormScreenTests.swift b/UITests/Sources/PollFormScreenTests.swift index 055f74926..5093c71c2 100644 --- a/UITests/Sources/PollFormScreenTests.swift +++ b/UITests/Sources/PollFormScreenTests.swift @@ -42,7 +42,7 @@ class PollFormScreenUITests: XCTestCase { let createButton = app.buttons[A11yIdentifiers.pollFormScreen.submit] let addOption = app.buttons[A11yIdentifiers.pollFormScreen.addOption] - for _ in 1...18 { + for _ in 1...8 { // Use the frame as a fallback to fix the button being obscured by the home indicator. if !addOption.isHittable || addOption.frame.maxY > (app.frame.maxY - 20) { app.swipeUp() diff --git a/UITests/Sources/__Snapshots__/Application/pollFormScreen.testMaxOptions-iPad-18-4-en-GB.png b/UITests/Sources/__Snapshots__/Application/pollFormScreen.testMaxOptions-iPad-18-4-en-GB.png index 3e5389b64..42fc68192 100644 --- a/UITests/Sources/__Snapshots__/Application/pollFormScreen.testMaxOptions-iPad-18-4-en-GB.png +++ b/UITests/Sources/__Snapshots__/Application/pollFormScreen.testMaxOptions-iPad-18-4-en-GB.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f917c5025edb6d96857a824a4686eafee33aed4759b0427f488cde8b0e4a0214 -size 195197 +oid sha256:1141531136024258cb952d4a078d43e168258350e0afa8e048d3a12849dc7291 +size 133124 diff --git a/UITests/Sources/__Snapshots__/Application/pollFormScreen.testMaxOptions-iPhone-18-4-en-GB.png b/UITests/Sources/__Snapshots__/Application/pollFormScreen.testMaxOptions-iPhone-18-4-en-GB.png index 42707f410..4f35d5892 100644 --- a/UITests/Sources/__Snapshots__/Application/pollFormScreen.testMaxOptions-iPhone-18-4-en-GB.png +++ b/UITests/Sources/__Snapshots__/Application/pollFormScreen.testMaxOptions-iPhone-18-4-en-GB.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:860ce4ca442b8c5b5936aa0da77d9efa885e1ec86f9e12f02c4d828e918e8f47 -size 299469 +oid sha256:3692a76bba54ff6c9896df27208aa6866428a979b0030653f15d93bfe680ff72 +size 239255