Fix UI tests and Release builds. (#2248)

* Fix PollFormScreen UI tests.

* Fix compilation error on release builds.
This commit is contained in:
Doug 2023-12-14 15:09:29 +00:00 committed by GitHub
parent ea5b154d6e
commit 669141b119
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 12 deletions

View File

@ -53,10 +53,6 @@ struct PollFormScreen: View {
kind: .textField(text: $context.question, axis: .vertical)) kind: .textField(text: $context.question, axis: .vertical))
.focused($focus, equals: .question) .focused($focus, equals: .question)
.accessibilityIdentifier(A11yIdentifiers.pollFormScreen.question) .accessibilityIdentifier(A11yIdentifiers.pollFormScreen.question)
.onSubmit {
focus = context.options.indices.first.map { .option(index: $0) }
}
.submitLabel(.next)
} header: { } header: {
Text(L10n.screenCreatePollQuestionDesc) Text(L10n.screenCreatePollQuestionDesc)
.compoundListSectionHeader() .compoundListSectionHeader()

View File

@ -40,6 +40,8 @@ enum HomeScreenCoordinatorAction {
final class HomeScreenCoordinator: CoordinatorProtocol { final class HomeScreenCoordinator: CoordinatorProtocol {
private var viewModel: HomeScreenViewModelProtocol private var viewModel: HomeScreenViewModelProtocol
// periphery:ignore - only used in release builds
private let bugReportService: BugReportServiceProtocol
private let actionsSubject: PassthroughSubject<HomeScreenCoordinatorAction, Never> = .init() private let actionsSubject: PassthroughSubject<HomeScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>() private var cancellables = Set<AnyCancellable>()
@ -53,6 +55,7 @@ final class HomeScreenCoordinator: CoordinatorProtocol {
selectedRoomPublisher: parameters.selectedRoomPublisher, selectedRoomPublisher: parameters.selectedRoomPublisher,
appSettings: ServiceLocator.shared.settings, appSettings: ServiceLocator.shared.settings,
userIndicatorController: ServiceLocator.shared.userIndicatorController) userIndicatorController: ServiceLocator.shared.userIndicatorController)
bugReportService = parameters.bugReportService
viewModel.actions viewModel.actions
.sink { [weak self] action in .sink { [weak self] action in
@ -88,7 +91,7 @@ final class HomeScreenCoordinator: CoordinatorProtocol {
func start() { func start() {
#if !DEBUG #if !DEBUG
if parameters.bugReportService.crashedLastRun { if bugReportService.crashedLastRun {
viewModel.presentCrashedLastRunAlert() viewModel.presentCrashedLastRunAlert()
} }
#endif #endif

View File

@ -25,8 +25,8 @@ class PollFormScreenUITests: XCTestCase {
func testFilledPoll() async throws { func testFilledPoll() async throws {
let app = Application.launch(.createPoll) let app = Application.launch(.createPoll)
let questionTextField = app.textFields[A11yIdentifiers.pollFormScreen.question] let questionTextField = app.textViews[A11yIdentifiers.pollFormScreen.question]
questionTextField.tap() questionTextField.coordinate(withNormalizedOffset: .init(dx: 0.5, dy: 0.5)).tap() // Tap isn't registered without the offset.
questionTextField.typeText("Do you like polls?") questionTextField.typeText("Do you like polls?")
let option1TextField = app.textFields[A11yIdentifiers.pollFormScreen.optionID(0)] let option1TextField = app.textFields[A11yIdentifiers.pollFormScreen.optionID(0)]
@ -54,12 +54,9 @@ class PollFormScreenUITests: XCTestCase {
app.swipeUp() app.swipeUp()
} }
addOption.tap() addOption.tap()
app.typeText("\n") // Dismiss the keyboard so the Add button is always visible.
} }
if app.keyboards.count > 0 {
app.typeText("\n")
}
app.swipeUp() // Dismisses the keyboard.
app.swipeUp() // Ensures that the bottom is shown. app.swipeUp() // Ensures that the bottom is shown.
XCTAssertFalse(addOption.exists) XCTAssertFalse(addOption.exists)