mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-25 19:10:49 +02:00
Updates following self review.
This commit is contained in:
+3
-7
@@ -84,13 +84,8 @@ final class OnboardingDisplayNameCoordinator: Coordinator, Presentable {
|
||||
waitingIndicator = indicatorPresenter.present(.loading(label: VectorL10n.saving, isInteractionBlocking: true))
|
||||
}
|
||||
|
||||
private func stopWaiting(error: Error? = nil) {
|
||||
waitingIndicator?.cancel()
|
||||
private func stopWaiting() {
|
||||
waitingIndicator = nil
|
||||
|
||||
if let error = error {
|
||||
onboardingDisplayNameViewModel.update(with: error)
|
||||
}
|
||||
}
|
||||
|
||||
private func setDisplayName(_ displayName: String) {
|
||||
@@ -102,7 +97,8 @@ final class OnboardingDisplayNameCoordinator: Coordinator, Presentable {
|
||||
self.completion?(self.parameters.userSession)
|
||||
} failure: { [weak self] error in
|
||||
guard let self = self else { return }
|
||||
self.stopWaiting(error: error)
|
||||
self.stopWaiting()
|
||||
self.onboardingDisplayNameViewModel.processError(error as NSError?)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,14 +52,13 @@ class OnboardingDisplayNameViewModel: OnboardingDisplayNameViewModelType, Onboar
|
||||
}
|
||||
}
|
||||
|
||||
func update(with error: Error) {
|
||||
if let error = error as NSError? {
|
||||
state.bindings.alertInfo = AlertInfo(error: error)
|
||||
}
|
||||
func processError(_ error: NSError?) {
|
||||
state.bindings.alertInfo = AlertInfo(error: error)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
/// Checks for a display name that exceeds 256 characters and updates the footer error if needed.
|
||||
private func validateDisplayName() {
|
||||
if state.bindings.displayName.count > 256 {
|
||||
guard state.validationErrorMessage == nil else { return }
|
||||
|
||||
+3
-1
@@ -22,5 +22,7 @@ protocol OnboardingDisplayNameViewModelProtocol {
|
||||
@available(iOS 14, *)
|
||||
var context: OnboardingDisplayNameViewModelType.Context { get }
|
||||
|
||||
func update(with error: Error)
|
||||
/// Update the view model to show that an error has occurred.
|
||||
/// - Parameter error: The error to be displayed or `nil` to display a generic alert.
|
||||
func processError(_ error: NSError?)
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ class OnboardingDisplayNameUITests: MockScreenTest {
|
||||
let footer = app.staticTexts["textFieldFooter"]
|
||||
XCTAssertTrue(footer.exists, "The textfield's footer should always be shown.")
|
||||
XCTAssertEqual(footer.label, VectorL10n.onboardingDisplayNameHint, "The footer should display a hint when no text is set.")
|
||||
|
||||
let saveButton = app.buttons["saveButton"]
|
||||
XCTAssertTrue(saveButton.exists, "There should be a save button.")
|
||||
XCTAssertFalse(saveButton.isEnabled, "The save button should not be enabled.")
|
||||
}
|
||||
|
||||
func verifyDisplayName(displayName: String) {
|
||||
@@ -57,6 +61,10 @@ class OnboardingDisplayNameUITests: MockScreenTest {
|
||||
XCTAssertEqual(textField.value as? String, displayName, "When a name has been set, it should show in the textfield.")
|
||||
XCTAssertEqual(textField.placeholderValue, VectorL10n.onboardingDisplayNamePlaceholder, "The textfield's placeholder should be set.")
|
||||
|
||||
let saveButton = app.buttons["saveButton"]
|
||||
XCTAssertTrue(saveButton.exists, "There should be a save button.")
|
||||
XCTAssertTrue(saveButton.isEnabled, "The save button should be enabled.")
|
||||
|
||||
let footer = app.staticTexts["textFieldFooter"]
|
||||
XCTAssertTrue(footer.exists, "The textfield's footer should always be shown.")
|
||||
XCTAssertEqual(footer.label, VectorL10n.onboardingDisplayNameHint, "The footer should display a hint when an acceptable name is entered.")
|
||||
@@ -71,5 +79,9 @@ class OnboardingDisplayNameUITests: MockScreenTest {
|
||||
let footer = app.staticTexts["textFieldFooter"]
|
||||
XCTAssertTrue(footer.exists, "The textfield's footer should always be shown.")
|
||||
XCTAssertEqual(footer.label, VectorL10n.onboardingDisplayNameMaxLength, "The footer should display an error when the display name is too long.")
|
||||
|
||||
let saveButton = app.buttons["saveButton"]
|
||||
XCTAssertTrue(saveButton.exists, "There should be a save button.")
|
||||
XCTAssertFalse(saveButton.isEnabled, "The save button should not be enabled.")
|
||||
}
|
||||
}
|
||||
|
||||
-4
@@ -21,10 +21,6 @@ import Combine
|
||||
|
||||
@available(iOS 14.0, *)
|
||||
class OnboardingDisplayNameViewModelTests: XCTestCase {
|
||||
private enum Constants {
|
||||
static let displayName = "Alice"
|
||||
}
|
||||
|
||||
var viewModel: OnboardingDisplayNameViewModel!
|
||||
var context: OnboardingDisplayNameViewModelType.Context!
|
||||
|
||||
|
||||
@@ -111,7 +111,8 @@ struct OnboardingDisplayNameScreen: View {
|
||||
viewModel.send(viewAction: .save)
|
||||
}
|
||||
.buttonStyle(PrimaryActionButtonStyle())
|
||||
.disabled(viewModel.displayName.isEmpty)
|
||||
.disabled(viewModel.displayName.isEmpty || viewModel.viewState.validationErrorMessage != nil)
|
||||
.accessibilityIdentifier("saveButton")
|
||||
|
||||
Button { viewModel.send(viewAction: .skip) } label: {
|
||||
Text(VectorL10n.onboardingPersonalizationSkip)
|
||||
|
||||
Reference in New Issue
Block a user