mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 10:32:34 +00:00
ConfirmAccountProviderEvents -> ConfirmAccountProviderEvent
This commit is contained in:
+4
-4
@@ -8,11 +8,11 @@
|
|||||||
|
|
||||||
package io.element.android.features.login.impl.screens.confirmaccountprovider
|
package io.element.android.features.login.impl.screens.confirmaccountprovider
|
||||||
|
|
||||||
sealed interface ConfirmAccountProviderEvents {
|
sealed interface ConfirmAccountProviderEvent {
|
||||||
data class UserInputChanged(val accountProvider: String) : ConfirmAccountProviderEvents
|
data class UserInputChanged(val accountProvider: String) : ConfirmAccountProviderEvent
|
||||||
|
|
||||||
// Carries the account provider to submit (the current field text, or the accepted autocomplete suggestion),
|
// Carries the account provider to submit (the current field text, or the accepted autocomplete suggestion),
|
||||||
// captured from the view at click time so it can't lag behind fast input (e.g. keyboard autofill).
|
// captured from the view at click time so it can't lag behind fast input (e.g. keyboard autofill).
|
||||||
data class Continue(val accountProvider: String) : ConfirmAccountProviderEvents
|
data class Continue(val accountProvider: String) : ConfirmAccountProviderEvent
|
||||||
data object ClearError : ConfirmAccountProviderEvents
|
data object ClearError : ConfirmAccountProviderEvent
|
||||||
}
|
}
|
||||||
+4
-4
@@ -110,14 +110,14 @@ class ConfirmAccountProviderPresenter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleEvent(event: ConfirmAccountProviderEvents) {
|
fun handleEvent(event: ConfirmAccountProviderEvent) {
|
||||||
when (event) {
|
when (event) {
|
||||||
is ConfirmAccountProviderEvents.UserInputChanged -> {
|
is ConfirmAccountProviderEvent.UserInputChanged -> {
|
||||||
userInput = event.accountProvider
|
userInput = event.accountProvider
|
||||||
}
|
}
|
||||||
// Validate (and persist) the chosen account provider before proceeding. This also enforces the
|
// Validate (and persist) the chosen account provider before proceeding. This also enforces the
|
||||||
// account-provider access control, which the login submit does not run on its own.
|
// account-provider access control, which the login submit does not run on its own.
|
||||||
is ConfirmAccountProviderEvents.Continue -> {
|
is ConfirmAccountProviderEvent.Continue -> {
|
||||||
// Apply the accepted account provider (any accepted completion) back into the field so it
|
// Apply the accepted account provider (any accepted completion) back into the field so it
|
||||||
// renders the full server rather than the typed prefix, and survives the OAuth round-trip.
|
// renders the full server rather than the typed prefix, and survives the OAuth round-trip.
|
||||||
val accountProvider = event.accountProvider.trim()
|
val accountProvider = event.accountProvider.trim()
|
||||||
@@ -137,7 +137,7 @@ class ConfirmAccountProviderPresenter(
|
|||||||
ChangeServerEvent.ChangeServer(AccountProvider(url = accountProviderUrl))
|
ChangeServerEvent.ChangeServer(AccountProvider(url = accountProviderUrl))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ConfirmAccountProviderEvents.ClearError -> {
|
ConfirmAccountProviderEvent.ClearError -> {
|
||||||
loginModeState.eventSink(LoginModeEvent.ClearError)
|
loginModeState.eventSink(LoginModeEvent.ClearError)
|
||||||
changeServerState.eventSink(ChangeServerEvent.ClearError)
|
changeServerState.eventSink(ChangeServerEvent.ClearError)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ data class ConfirmAccountProviderState(
|
|||||||
val isAccountCreation: Boolean,
|
val isAccountCreation: Boolean,
|
||||||
val loginModeState: LoginModeState,
|
val loginModeState: LoginModeState,
|
||||||
val changeServerState: ChangeServerState,
|
val changeServerState: ChangeServerState,
|
||||||
val eventSink: (ConfirmAccountProviderEvents) -> Unit
|
val eventSink: (ConfirmAccountProviderEvent) -> Unit
|
||||||
) {
|
) {
|
||||||
val submitEnabled: Boolean
|
val submitEnabled: Boolean
|
||||||
get() = accountProviderInput.isNotBlank() &&
|
get() = accountProviderInput.isNotBlank() &&
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ private fun aConfirmAccountProviderState(
|
|||||||
isAccountCreation: Boolean = false,
|
isAccountCreation: Boolean = false,
|
||||||
loginModeState: LoginModeState = aLoginModeState(),
|
loginModeState: LoginModeState = aLoginModeState(),
|
||||||
changeServerState: ChangeServerState = aChangeServerState(),
|
changeServerState: ChangeServerState = aChangeServerState(),
|
||||||
eventSink: (ConfirmAccountProviderEvents) -> Unit = {},
|
eventSink: (ConfirmAccountProviderEvent) -> Unit = {},
|
||||||
) = ConfirmAccountProviderState(
|
) = ConfirmAccountProviderState(
|
||||||
accountProviderInput = accountProviderInput,
|
accountProviderInput = accountProviderInput,
|
||||||
accountProviderSuggestion = accountProviderSuggestion,
|
accountProviderSuggestion = accountProviderSuggestion,
|
||||||
|
|||||||
+5
-5
@@ -99,7 +99,7 @@ fun ConfirmAccountProviderView(
|
|||||||
// Dismiss the keyboard and release focus while the account provider is being validated.
|
// Dismiss the keyboard and release focus while the account provider is being validated.
|
||||||
focusManager.clearFocus(force = true)
|
focusManager.clearFocus(force = true)
|
||||||
// Submit the exact field text (plus any accepted suggestion).
|
// Submit the exact field text (plus any accepted suggestion).
|
||||||
eventSink(ConfirmAccountProviderEvents.Continue(accountProviderToSubmit))
|
eventSink(ConfirmAccountProviderEvent.Continue(accountProviderToSubmit))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Once a validation / login error has been dismissed, return focus and the keyboard to the field so
|
// Once a validation / login error has been dismissed, return focus and the keyboard to the field so
|
||||||
@@ -151,7 +151,7 @@ fun ConfirmAccountProviderView(
|
|||||||
value = input,
|
value = input,
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
input = it
|
input = it
|
||||||
eventSink(ConfirmAccountProviderEvents.UserInputChanged(it))
|
eventSink(ConfirmAccountProviderEvent.UserInputChanged(it))
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
@@ -181,7 +181,7 @@ fun ConfirmAccountProviderView(
|
|||||||
// showing, Done submits directly.
|
// showing, Done submits directly.
|
||||||
val accepted = input + suggestionSuffix
|
val accepted = input + suggestionSuffix
|
||||||
input = accepted
|
input = accepted
|
||||||
eventSink(ConfirmAccountProviderEvents.UserInputChanged(accepted))
|
eventSink(ConfirmAccountProviderEvent.UserInputChanged(accepted))
|
||||||
focusManager.clearFocus(force = true)
|
focusManager.clearFocus(force = true)
|
||||||
} else {
|
} else {
|
||||||
submit()
|
submit()
|
||||||
@@ -197,7 +197,7 @@ fun ConfirmAccountProviderView(
|
|||||||
role = Role.Button,
|
role = Role.Button,
|
||||||
) {
|
) {
|
||||||
input = ""
|
input = ""
|
||||||
eventSink(ConfirmAccountProviderEvents.UserInputChanged(""))
|
eventSink(ConfirmAccountProviderEvent.UserInputChanged(""))
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
@@ -222,7 +222,7 @@ fun ConfirmAccountProviderView(
|
|||||||
|
|
||||||
LoginModeView(
|
LoginModeView(
|
||||||
loginMode = state.loginModeState.loginMode,
|
loginMode = state.loginModeState.loginMode,
|
||||||
onClearError = { eventSink(ConfirmAccountProviderEvents.ClearError) },
|
onClearError = { eventSink(ConfirmAccountProviderEvent.ClearError) },
|
||||||
onLearnMoreClick = onLearnMoreClick,
|
onLearnMoreClick = onLearnMoreClick,
|
||||||
onOAuthDetails = onOAuthDetails,
|
onOAuthDetails = onOAuthDetails,
|
||||||
onNeedLoginPassword = onNeedLoginPassword,
|
onNeedLoginPassword = onNeedLoginPassword,
|
||||||
|
|||||||
+28
-28
@@ -68,7 +68,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink.invoke(ConfirmAccountProviderEvents.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
initialState.eventSink.invoke(ConfirmAccountProviderEvent.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
||||||
val successState = awaitLoginMode { it is AsyncData.Success }
|
val successState = awaitLoginMode { it is AsyncData.Success }
|
||||||
assertThat(successState.loginModeState.loginMode.dataOrNull()).isEqualTo(LoginMode.PasswordLogin)
|
assertThat(successState.loginModeState.loginMode.dataOrNull()).isEqualTo(LoginMode.PasswordLogin)
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
@@ -87,7 +87,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink.invoke(ConfirmAccountProviderEvents.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
initialState.eventSink.invoke(ConfirmAccountProviderEvent.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
||||||
val successState = awaitLoginMode { it is AsyncData.Success }
|
val successState = awaitLoginMode { it is AsyncData.Success }
|
||||||
assertThat(successState.loginModeState.loginMode.dataOrNull()).isInstanceOf(LoginMode.OAuth::class.java)
|
assertThat(successState.loginModeState.loginMode.dataOrNull()).isInstanceOf(LoginMode.OAuth::class.java)
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
@@ -108,7 +108,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink.invoke(ConfirmAccountProviderEvents.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
initialState.eventSink.invoke(ConfirmAccountProviderEvent.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
||||||
val successState = awaitLoginMode { it is AsyncData.Success }
|
val successState = awaitLoginMode { it is AsyncData.Success }
|
||||||
assertThat(successState.loginModeState.loginMode.dataOrNull()).isInstanceOf(LoginMode.OAuth::class.java)
|
assertThat(successState.loginModeState.loginMode.dataOrNull()).isInstanceOf(LoginMode.OAuth::class.java)
|
||||||
authenticationService.givenOAuthCancelError(AN_EXCEPTION)
|
authenticationService.givenOAuthCancelError(AN_EXCEPTION)
|
||||||
@@ -133,7 +133,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink.invoke(ConfirmAccountProviderEvents.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
initialState.eventSink.invoke(ConfirmAccountProviderEvent.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
||||||
val successState = awaitLoginMode { it is AsyncData.Success }
|
val successState = awaitLoginMode { it is AsyncData.Success }
|
||||||
assertThat(successState.loginModeState.loginMode.dataOrNull()).isInstanceOf(LoginMode.OAuth::class.java)
|
assertThat(successState.loginModeState.loginMode.dataOrNull()).isInstanceOf(LoginMode.OAuth::class.java)
|
||||||
defaultOAuthActionFlow.post(OAuthAction.GoBack())
|
defaultOAuthActionFlow.post(OAuthAction.GoBack())
|
||||||
@@ -157,7 +157,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink.invoke(ConfirmAccountProviderEvents.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
initialState.eventSink.invoke(ConfirmAccountProviderEvent.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
||||||
awaitLoginMode { it is AsyncData.Loading }
|
awaitLoginMode { it is AsyncData.Loading }
|
||||||
defaultOAuthActionFlow.post(OAuthAction.GoBack(toUnblock = true))
|
defaultOAuthActionFlow.post(OAuthAction.GoBack(toUnblock = true))
|
||||||
val cancelFinalState = awaitLoginMode { it is AsyncData.Uninitialized }
|
val cancelFinalState = awaitLoginMode { it is AsyncData.Uninitialized }
|
||||||
@@ -180,7 +180,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink.invoke(ConfirmAccountProviderEvents.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
initialState.eventSink.invoke(ConfirmAccountProviderEvent.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
||||||
val successState = awaitLoginMode { it is AsyncData.Success }
|
val successState = awaitLoginMode { it is AsyncData.Success }
|
||||||
assertThat(successState.loginModeState.loginMode.dataOrNull()).isInstanceOf(LoginMode.OAuth::class.java)
|
assertThat(successState.loginModeState.loginMode.dataOrNull()).isInstanceOf(LoginMode.OAuth::class.java)
|
||||||
authenticationService.givenLoginError(AN_EXCEPTION)
|
authenticationService.givenLoginError(AN_EXCEPTION)
|
||||||
@@ -205,7 +205,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink.invoke(ConfirmAccountProviderEvents.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
initialState.eventSink.invoke(ConfirmAccountProviderEvent.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
||||||
val successState = awaitLoginMode { it is AsyncData.Success }
|
val successState = awaitLoginMode { it is AsyncData.Success }
|
||||||
assertThat(successState.loginModeState.loginMode.dataOrNull()).isInstanceOf(LoginMode.OAuth::class.java)
|
assertThat(successState.loginModeState.loginMode.dataOrNull()).isInstanceOf(LoginMode.OAuth::class.java)
|
||||||
defaultOidcActionFlow.post(OAuthAction.Success("aUrl"))
|
defaultOidcActionFlow.post(OAuthAction.Success("aUrl"))
|
||||||
@@ -227,7 +227,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink.invoke(ConfirmAccountProviderEvents.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
initialState.eventSink.invoke(ConfirmAccountProviderEvent.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
||||||
// The account provider validation fails, so the login is never attempted.
|
// The account provider validation fails, so the login is never attempted.
|
||||||
val failureState = awaitState { it.changeServerState.changeServerAction is AsyncData.Failure }
|
val failureState = awaitState { it.changeServerState.changeServerAction is AsyncData.Failure }
|
||||||
assertThat(failureState.loginModeState.loginMode).isEqualTo(AsyncData.Uninitialized)
|
assertThat(failureState.loginModeState.loginMode).isEqualTo(AsyncData.Uninitialized)
|
||||||
@@ -249,13 +249,13 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
|
|
||||||
// Submit will return an error while validating the account provider
|
// Submit will return an error while validating the account provider
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
initialState.eventSink(ConfirmAccountProviderEvent.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
||||||
|
|
||||||
// Check an error was returned
|
// Check an error was returned
|
||||||
val submittedState = awaitState { it.changeServerState.changeServerAction is AsyncData.Failure }
|
val submittedState = awaitState { it.changeServerState.changeServerAction is AsyncData.Failure }
|
||||||
|
|
||||||
// Assert the error is then cleared
|
// Assert the error is then cleared
|
||||||
submittedState.eventSink(ConfirmAccountProviderEvents.ClearError)
|
submittedState.eventSink(ConfirmAccountProviderEvent.ClearError)
|
||||||
val clearedState = awaitState { it.changeServerState.changeServerAction is AsyncData.Uninitialized }
|
val clearedState = awaitState { it.changeServerState.changeServerAction is AsyncData.Uninitialized }
|
||||||
assertThat(clearedState.loginModeState.loginMode).isEqualTo(AsyncData.Uninitialized)
|
assertThat(clearedState.loginModeState.loginMode).isEqualTo(AsyncData.Uninitialized)
|
||||||
}
|
}
|
||||||
@@ -274,12 +274,12 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
initialState.eventSink(ConfirmAccountProviderEvent.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
||||||
// Check an error was returned
|
// Check an error was returned
|
||||||
val submittedState = awaitLoginMode { it is AsyncData.Failure }
|
val submittedState = awaitLoginMode { it is AsyncData.Failure }
|
||||||
assertThat(submittedState.loginModeState.loginMode.errorOrNull()).isInstanceOf(AccountCreationNotSupported::class.java)
|
assertThat(submittedState.loginModeState.loginMode.errorOrNull()).isInstanceOf(AccountCreationNotSupported::class.java)
|
||||||
// Assert the error is then cleared
|
// Assert the error is then cleared
|
||||||
submittedState.eventSink(ConfirmAccountProviderEvents.ClearError)
|
submittedState.eventSink(ConfirmAccountProviderEvent.ClearError)
|
||||||
val clearedState = awaitLoginMode { it is AsyncData.Uninitialized }
|
val clearedState = awaitLoginMode { it is AsyncData.Uninitialized }
|
||||||
assertThat(clearedState.loginModeState.loginMode).isEqualTo(AsyncData.Uninitialized)
|
assertThat(clearedState.loginModeState.loginMode).isEqualTo(AsyncData.Uninitialized)
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
@@ -299,7 +299,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
initialState.eventSink(ConfirmAccountProviderEvent.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
||||||
val submittedState = awaitLoginMode { it is AsyncData.Success }
|
val submittedState = awaitLoginMode { it is AsyncData.Success }
|
||||||
assertThat(submittedState.loginModeState.loginMode.dataOrNull()).isInstanceOf(LoginMode.OAuth::class.java)
|
assertThat(submittedState.loginModeState.loginMode.dataOrNull()).isInstanceOf(LoginMode.OAuth::class.java)
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
@@ -316,7 +316,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
assertThat(initialState.accountProviderSuggestion).isNull()
|
assertThat(initialState.accountProviderSuggestion).isNull()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.UserInputChanged("random"))
|
initialState.eventSink(ConfirmAccountProviderEvent.UserInputChanged("random"))
|
||||||
val suggestionState = awaitState { it.accountProviderInput == "random" }
|
val suggestionState = awaitState { it.accountProviderInput == "random" }
|
||||||
// Completion is offered without the https:// scheme, even though history stores the full URL.
|
// Completion is offered without the https:// scheme, even though history stores the full URL.
|
||||||
assertThat(suggestionState.accountProviderSuggestion).isEqualTo("randomcommunity.org")
|
assertThat(suggestionState.accountProviderSuggestion).isEqualTo("randomcommunity.org")
|
||||||
@@ -340,9 +340,9 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.UserInputChanged("random"))
|
initialState.eventSink(ConfirmAccountProviderEvent.UserInputChanged("random"))
|
||||||
val suggestionState = awaitState { it.accountProviderSuggestion != null }
|
val suggestionState = awaitState { it.accountProviderSuggestion != null }
|
||||||
suggestionState.eventSink(ConfirmAccountProviderEvents.Continue("randomcommunity.org"))
|
suggestionState.eventSink(ConfirmAccountProviderEvent.Continue("randomcommunity.org"))
|
||||||
awaitLoginMode { it is AsyncData.Success }
|
awaitLoginMode { it is AsyncData.Success }
|
||||||
assertThat(submittedUrls.first()).isEqualTo("https://randomcommunity.org")
|
assertThat(submittedUrls.first()).isEqualTo("https://randomcommunity.org")
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
@@ -360,9 +360,9 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.UserInputChanged("random"))
|
initialState.eventSink(ConfirmAccountProviderEvent.UserInputChanged("random"))
|
||||||
val suggestionState = awaitState { it.accountProviderSuggestion != null }
|
val suggestionState = awaitState { it.accountProviderSuggestion != null }
|
||||||
suggestionState.eventSink(ConfirmAccountProviderEvents.Continue("randomcommunity.org"))
|
suggestionState.eventSink(ConfirmAccountProviderEvent.Continue("randomcommunity.org"))
|
||||||
// The field now renders the full accepted server rather than the typed prefix.
|
// The field now renders the full accepted server rather than the typed prefix.
|
||||||
val appliedState = awaitState { it.accountProviderInput == "randomcommunity.org" }
|
val appliedState = awaitState { it.accountProviderInput == "randomcommunity.org" }
|
||||||
assertThat(appliedState.accountProviderInput).isEqualTo("randomcommunity.org")
|
assertThat(appliedState.accountProviderInput).isEqualTo("randomcommunity.org")
|
||||||
@@ -381,7 +381,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.UserInputChanged("ele"))
|
initialState.eventSink(ConfirmAccountProviderEvent.UserInputChanged("ele"))
|
||||||
val suggestionState = awaitState { it.accountProviderInput == "ele" }
|
val suggestionState = awaitState { it.accountProviderInput == "ele" }
|
||||||
assertThat(suggestionState.accountProviderSuggestion).isEqualTo("element.io")
|
assertThat(suggestionState.accountProviderSuggestion).isEqualTo("element.io")
|
||||||
}
|
}
|
||||||
@@ -394,7 +394,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.UserInputChanged("matr"))
|
initialState.eventSink(ConfirmAccountProviderEvent.UserInputChanged("matr"))
|
||||||
val suggestionState = awaitState { it.accountProviderInput == "matr" }
|
val suggestionState = awaitState { it.accountProviderInput == "matr" }
|
||||||
assertThat(suggestionState.accountProviderSuggestion).isEqualTo("matrix.org")
|
assertThat(suggestionState.accountProviderSuggestion).isEqualTo("matrix.org")
|
||||||
}
|
}
|
||||||
@@ -409,9 +409,9 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.UserInputChanged("https://mat"))
|
initialState.eventSink(ConfirmAccountProviderEvent.UserInputChanged("https://mat"))
|
||||||
assertThat(awaitState { it.accountProviderInput == "https://mat" }.accountProviderSuggestion).isNull()
|
assertThat(awaitState { it.accountProviderInput == "https://mat" }.accountProviderSuggestion).isNull()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.UserInputChanged("http://mat"))
|
initialState.eventSink(ConfirmAccountProviderEvent.UserInputChanged("http://mat"))
|
||||||
assertThat(awaitState { it.accountProviderInput == "http://mat" }.accountProviderSuggestion).isNull()
|
assertThat(awaitState { it.accountProviderInput == "http://mat" }.accountProviderSuggestion).isNull()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -430,7 +430,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.Continue("matrix.org"))
|
initialState.eventSink(ConfirmAccountProviderEvent.Continue("matrix.org"))
|
||||||
awaitLoginMode { it is AsyncData.Success }
|
awaitLoginMode { it is AsyncData.Success }
|
||||||
assertThat(submittedUrls.first()).isEqualTo(AuthenticationConfig.MATRIX_ORG_URL)
|
assertThat(submittedUrls.first()).isEqualTo(AuthenticationConfig.MATRIX_ORG_URL)
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
@@ -453,7 +453,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
initialState.eventSink(ConfirmAccountProviderEvent.Continue(AuthenticationConfig.MATRIX_ORG_URL))
|
||||||
awaitLoginMode { it is AsyncData.Success }
|
awaitLoginMode { it is AsyncData.Success }
|
||||||
assertThat(submittedUrls).containsExactly(AuthenticationConfig.MATRIX_ORG_URL)
|
assertThat(submittedUrls).containsExactly(AuthenticationConfig.MATRIX_ORG_URL)
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
@@ -472,7 +472,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
val presenter = createConfirmAccountProviderPresenter(matrixAuthenticationService = authenticationService)
|
val presenter = createConfirmAccountProviderPresenter(matrixAuthenticationService = authenticationService)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.Continue("@alice:example.org"))
|
initialState.eventSink(ConfirmAccountProviderEvent.Continue("@alice:example.org"))
|
||||||
awaitLoginMode { it is AsyncData.Success }
|
awaitLoginMode { it is AsyncData.Success }
|
||||||
assertThat(submittedUrls.first()).isEqualTo("https://example.org")
|
assertThat(submittedUrls.first()).isEqualTo("https://example.org")
|
||||||
assertThat(authenticationService.getOAuthUrlLoginHint).isEqualTo("mxid:@alice:example.org")
|
assertThat(authenticationService.getOAuthUrlLoginHint).isEqualTo("mxid:@alice:example.org")
|
||||||
@@ -492,7 +492,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
val presenter = createConfirmAccountProviderPresenter(matrixAuthenticationService = authenticationService)
|
val presenter = createConfirmAccountProviderPresenter(matrixAuthenticationService = authenticationService)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.Continue("@alice:example.org:8448"))
|
initialState.eventSink(ConfirmAccountProviderEvent.Continue("@alice:example.org:8448"))
|
||||||
awaitLoginMode { it is AsyncData.Success }
|
awaitLoginMode { it is AsyncData.Success }
|
||||||
assertThat(submittedUrls.first()).isEqualTo("https://example.org:8448")
|
assertThat(submittedUrls.first()).isEqualTo("https://example.org:8448")
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
@@ -507,7 +507,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
val presenter = createConfirmAccountProviderPresenter(matrixAuthenticationService = authenticationService)
|
val presenter = createConfirmAccountProviderPresenter(matrixAuthenticationService = authenticationService)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.Continue("matrix.org"))
|
initialState.eventSink(ConfirmAccountProviderEvent.Continue("matrix.org"))
|
||||||
awaitLoginMode { it is AsyncData.Success }
|
awaitLoginMode { it is AsyncData.Success }
|
||||||
assertThat(authenticationService.getOAuthUrlLoginHint).isNull()
|
assertThat(authenticationService.getOAuthUrlLoginHint).isNull()
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
@@ -525,7 +525,7 @@ class ConfirmAccountProviderPresenterTest {
|
|||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
initialState.eventSink(ConfirmAccountProviderEvents.Continue("@alice:example.org"))
|
initialState.eventSink(ConfirmAccountProviderEvent.Continue("@alice:example.org"))
|
||||||
awaitLoginMode { it is AsyncData.Success }
|
awaitLoginMode { it is AsyncData.Success }
|
||||||
assertThat(authenticationService.getOAuthUrlLoginHint).isNull()
|
assertThat(authenticationService.getOAuthUrlLoginHint).isNull()
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
|
|||||||
Reference in New Issue
Block a user