mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Selecting a server that doesn't support login now fails instead of letting you continue to a failure later. (#3342)
* Fail configuration of the authentication service if the homeserver doesn't support login. * Move the ServerSelectionCoordinator logic into the ViewModel. - Handle the new login alert. - Add more tests
This commit is contained in:
+31
-4
@@ -91,11 +91,38 @@ struct ServerSelectionScreen: View {
|
||||
// MARK: - Previews
|
||||
|
||||
struct ServerSelection_Previews: PreviewProvider, TestablePreview {
|
||||
static let matrixViewModel = makeViewModel(for: "https://matrix.org")
|
||||
static let emptyViewModel = makeViewModel(for: "")
|
||||
static let invalidViewModel = makeViewModel(for: "thisisbad")
|
||||
|
||||
static var previews: some View {
|
||||
ForEach(MockServerSelectionScreenState.allCases, id: \.self) { state in
|
||||
NavigationStack {
|
||||
ServerSelectionScreen(context: state.viewModel.context)
|
||||
}
|
||||
NavigationStack {
|
||||
ServerSelectionScreen(context: matrixViewModel.context)
|
||||
}
|
||||
|
||||
NavigationStack {
|
||||
ServerSelectionScreen(context: emptyViewModel.context)
|
||||
}
|
||||
|
||||
NavigationStack {
|
||||
ServerSelectionScreen(context: invalidViewModel.context)
|
||||
}
|
||||
.snapshotPreferences(delay: 0.25)
|
||||
}
|
||||
|
||||
static func makeViewModel(for homeserverAddress: String) -> ServerSelectionScreenViewModel {
|
||||
let authenticationService = AuthenticationService.mock
|
||||
|
||||
let slidingSyncLearnMoreURL = ServiceLocator.shared.settings.slidingSyncLearnMoreURL
|
||||
|
||||
let viewModel = ServerSelectionScreenViewModel(authenticationService: authenticationService,
|
||||
authenticationFlow: .login,
|
||||
slidingSyncLearnMoreURL: slidingSyncLearnMoreURL,
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
viewModel.context.homeserverAddress = homeserverAddress
|
||||
if homeserverAddress == "thisisbad" {
|
||||
viewModel.context.send(viewAction: .confirm)
|
||||
}
|
||||
return viewModel
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user