UI test fixes (#2309)

* Fix settings screen screenshots

* Fix user session test snapshots

* Fix poll creation form UI test after moving to textViews instead of textFields

* Add missing room member details snapshot

* Update the home screen avatar snapshot as the badge is not shown anymore

* Dismiss the keyboard on the poll form when inserting a new line on a poll option
This commit is contained in:
Stefan Ceriu 2024-01-08 18:02:29 +02:00 committed by GitHub
parent 08d0e785d6
commit 90eb426832
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 88 additions and 72 deletions

View File

@ -74,9 +74,16 @@ struct PollFormScreen: View {
}
.focused($focus, equals: .option(index: index))
.accessibilityIdentifier(A11yIdentifiers.pollFormScreen.optionID(index))
.onSubmit {
let nextOptionIndex = index == context.options.endIndex - 1 ? nil : index + 1
focus = nextOptionIndex.map { .option(index: $0) }
.onChange(of: context.options[index].text) { optionText in
guard let lastCharacter = optionText.last, lastCharacter.isNewline else {
return
}
context.options[index].text.removeLast()
submitOption(at: index)
}
.onSubmit { // onSubmit is still called when using the return key on a hardware keyboard
submitOption(at: index)
}
.submitLabel(index == context.options.endIndex - 1 ? .done : .next)
}
@ -98,6 +105,11 @@ struct PollFormScreen: View {
.animation(.noAnimation, value: UUID())
}
private func submitOption(at index: Array<PollFormScreenViewStateBindings.Option>.Index) {
let nextOptionIndex = index == context.options.endIndex - 1 ? nil : index + 1
focus = nextOptionIndex.map { .option(index: $0) }
}
private var showResultsSection: some View {
Section {
ListRow(label: .plain(title: L10n.screenCreatePollAnonymousDesc),

View File

@ -42,7 +42,7 @@ class MockClientProxy: ClientProxyProtocol {
lazy var secureBackupController: SecureBackupControllerProtocol = {
let secureBackupController = SecureBackupControllerMock()
secureBackupController.underlyingRecoveryKeyState = .init(CurrentValueSubject<SecureBackupRecoveryKeyState, Never>(.disabled))
secureBackupController.underlyingRecoveryKeyState = .init(CurrentValueSubject<SecureBackupRecoveryKeyState, Never>(.enabled))
secureBackupController.underlyingKeyBackupState = .init(CurrentValueSubject<SecureBackupKeyBackupState, Never>(.enabled))
secureBackupController.isLastSessionReturnValue = .success(false)
return secureBackupController

View File

@ -29,13 +29,16 @@ class PollFormScreenUITests: XCTestCase {
questionTextField.coordinate(withNormalizedOffset: .init(dx: 0.5, dy: 0.5)).tap() // Tap isn't registered without the offset.
questionTextField.typeText("Do you like polls?")
let option1TextField = app.textFields[A11yIdentifiers.pollFormScreen.optionID(0)]
let option1TextField = app.textViews[A11yIdentifiers.pollFormScreen.optionID(0)]
option1TextField.tap()
option1TextField.typeText("Yes")
let option2TextField = app.textFields[A11yIdentifiers.pollFormScreen.optionID(1)]
let option2TextField = app.textViews[A11yIdentifiers.pollFormScreen.optionID(1)]
option2TextField.tap()
option2TextField.typeText("No\n")
option2TextField.typeText("No")
// Dismiss the keyboard
app.swipeDown()
let createButton = app.buttons[A11yIdentifiers.pollFormScreen.submit]
XCTAssertTrue(createButton.isEnabled)
@ -56,9 +59,7 @@ class PollFormScreenUITests: XCTestCase {
addOption.tap()
}
if app.hasFocus {
app.typeText("\n") // Dismiss the keyboard so the Add button is always visible.
}
app.swipeUp() // Dismiss the keyboard so the Add button is always visible.
app.swipeUp() // Ensures that the bottom is shown.

Binary file not shown.