Add AuthenticationHomeserverViewData to easily map AuthenticationState.Homeserver to a type in the SwiftUI target.

This commit is contained in:
Doug
2022-05-24 13:41:47 +01:00
parent a74134fdba
commit ac4572ae6a
22 changed files with 147 additions and 197 deletions
@@ -39,27 +39,19 @@ enum MockAuthenticationRegistrationScreenState: MockScreenState, CaseIterable {
let viewModel: AuthenticationRegistrationViewModel
switch self {
case .matrixDotOrg:
viewModel = AuthenticationRegistrationViewModel(homeserverAddress: "https://matrix.org", ssoIdentityProviders: [
SSOIdentityProvider(id: "1", name: "Apple", brand: "apple", iconURL: nil),
SSOIdentityProvider(id: "2", name: "Facebook", brand: "facebook", iconURL: nil),
SSOIdentityProvider(id: "3", name: "GitHub", brand: "github", iconURL: nil),
SSOIdentityProvider(id: "4", name: "GitLab", brand: "gitlab", iconURL: nil),
SSOIdentityProvider(id: "5", name: "Google", brand: "google", iconURL: nil)
])
viewModel = AuthenticationRegistrationViewModel(homeserver: .mockMatrixDotOrg)
case .passwordOnly:
viewModel = AuthenticationRegistrationViewModel(homeserverAddress: "https://example.com", ssoIdentityProviders: [])
viewModel = AuthenticationRegistrationViewModel(homeserver: .mockBasicServer)
case .passwordWithCredentials:
viewModel = AuthenticationRegistrationViewModel(homeserverAddress: "https://example.com", ssoIdentityProviders: [])
viewModel = AuthenticationRegistrationViewModel(homeserver: .mockBasicServer)
viewModel.context.username = "alice"
viewModel.context.password = "password"
case .passwordWithUsernameError:
viewModel = AuthenticationRegistrationViewModel(homeserverAddress: "https://example.com", ssoIdentityProviders: [])
viewModel = AuthenticationRegistrationViewModel(homeserver: .mockBasicServer)
viewModel.state.hasEditedUsername = true
Task { await viewModel.displayError(.usernameUnavailable(VectorL10n.authInvalidUserName)) }
case .ssoOnly:
viewModel = AuthenticationRegistrationViewModel(homeserverAddress: "https://company.com",
showRegistrationForm: false,
ssoIdentityProviders: [SSOIdentityProvider(id: "test", name: "SAML", brand: nil, iconURL: nil)])
viewModel = AuthenticationRegistrationViewModel(homeserver: .mockEnterpriseSSO)
}