Merge pull request #6984 from thundernest/rename_account_setup_autoconfig_to_autodiscovery

Rename account setup autoconfig to autodiscovery
This commit is contained in:
Wolf-Martell Montwé 2023-06-15 18:42:42 +02:00 committed by GitHub
commit 4bc2afa9ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 147 additions and 146 deletions

View file

@ -5,9 +5,9 @@ import app.k9mail.autodiscovery.service.RealAutoDiscoveryService
import app.k9mail.feature.account.setup.domain.DomainContract
import app.k9mail.feature.account.setup.domain.usecase.GetAutoDiscovery
import app.k9mail.feature.account.setup.ui.AccountSetupViewModel
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigValidator
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigViewModel
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryValidator
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryViewModel
import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract
import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigValidator
import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigViewModel
@ -34,14 +34,14 @@ val featureAccountSetupModule: Module = module {
)
}
factory<AccountAutoConfigContract.Validator> { AccountAutoConfigValidator() }
factory<AccountAutoDiscoveryContract.Validator> { AccountAutoDiscoveryValidator() }
factory<AccountIncomingConfigContract.Validator> { AccountIncomingConfigValidator() }
factory<AccountOutgoingConfigContract.Validator> { AccountOutgoingConfigValidator() }
factory<AccountOptionsContract.Validator> { AccountOptionsValidator() }
viewModel { AccountSetupViewModel() }
viewModel {
AccountAutoConfigViewModel(
AccountAutoDiscoveryViewModel(
validator = get(),
getAutoDiscovery = get(),
)

View file

@ -7,9 +7,9 @@ import app.k9mail.feature.account.setup.ui.AccountSetupContract.Effect
import app.k9mail.feature.account.setup.ui.AccountSetupContract.Event
import app.k9mail.feature.account.setup.ui.AccountSetupContract.SetupStep
import app.k9mail.feature.account.setup.ui.AccountSetupContract.ViewModel
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigScreen
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigViewModel
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryScreen
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryViewModel
import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract
import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigScreen
import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigViewModel
@ -26,7 +26,7 @@ fun AccountSetupScreen(
onFinish: () -> Unit,
onBack: () -> Unit,
viewModel: ViewModel = koinViewModel<AccountSetupViewModel>(),
autoConfigViewModel: AccountAutoConfigContract.ViewModel = koinViewModel<AccountAutoConfigViewModel>(),
autoDiscoveryViewModel: AccountAutoDiscoveryContract.ViewModel = koinViewModel<AccountAutoDiscoveryViewModel>(),
incomingViewModel: AccountIncomingConfigContract.ViewModel = koinViewModel<AccountIncomingConfigViewModel>(),
outgoingViewModel: AccountOutgoingConfigContract.ViewModel = koinViewModel<AccountOutgoingConfigViewModel>(),
optionsViewModel: AccountOptionsContract.ViewModel = koinViewModel<AccountOptionsViewModel>(),
@ -40,10 +40,10 @@ fun AccountSetupScreen(
when (state.value.setupStep) {
SetupStep.AUTO_CONFIG -> {
AccountAutoConfigScreen(
AccountAutoDiscoveryScreen(
onNext = { dispatch(Event.OnNext) },
onBack = { dispatch(Event.OnBack) },
viewModel = autoConfigViewModel,
viewModel = autoDiscoveryViewModel,
)
}

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig
package app.k9mail.feature.account.setup.ui.autodiscovery
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
@ -19,14 +19,14 @@ import app.k9mail.core.ui.compose.theme.K9Theme
import app.k9mail.core.ui.compose.theme.MainTheme
import app.k9mail.core.ui.compose.theme.ThunderbirdTheme
import app.k9mail.feature.account.setup.R
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.Event
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.State
import app.k9mail.feature.account.setup.ui.autoconfig.item.contentItems
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Event
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.State
import app.k9mail.feature.account.setup.ui.autodiscovery.item.contentItems
import app.k9mail.feature.account.setup.ui.common.item.ErrorItem
import app.k9mail.feature.account.setup.ui.common.item.LoadingItem
@Composable
internal fun AccountAutoConfigContent(
internal fun AccountAutoDiscoveryContent(
state: State,
onEvent: (Event) -> Unit,
contentPadding: PaddingValues,
@ -34,7 +34,7 @@ internal fun AccountAutoConfigContent(
) {
ResponsiveWidthContainer(
modifier = Modifier
.testTag("AccountAutoConfigContent")
.testTag("AccountAutoDiscoveryContent")
.padding(contentPadding)
.fillMaxWidth()
.then(modifier),
@ -73,9 +73,9 @@ internal fun AccountAutoConfigContent(
@Composable
@DevicePreviews
internal fun AccountAutoConfigContentK9Preview() {
internal fun AccountAutoDiscoveryContentK9Preview() {
K9Theme {
AccountAutoConfigContent(
AccountAutoDiscoveryContent(
state = State(),
onEvent = {},
contentPadding = PaddingValues(),
@ -85,9 +85,9 @@ internal fun AccountAutoConfigContentK9Preview() {
@Composable
@DevicePreviews
internal fun AccountAutoConfigContentThunderbirdPreview() {
internal fun AccountAutoDiscoveryContentThunderbirdPreview() {
ThunderbirdTheme {
AccountAutoConfigContent(
AccountAutoDiscoveryContent(
state = State(),
onEvent = {},
contentPadding = PaddingValues(),

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig
package app.k9mail.feature.account.setup.ui.autodiscovery
import app.k9mail.autodiscovery.api.AutoDiscoveryResult
import app.k9mail.core.common.domain.usecase.validation.ValidationResult
@ -6,7 +6,7 @@ import app.k9mail.core.ui.compose.common.mvi.UnidirectionalViewModel
import app.k9mail.feature.account.setup.domain.input.BooleanInputField
import app.k9mail.feature.account.setup.domain.input.StringInputField
interface AccountAutoConfigContract {
interface AccountAutoDiscoveryContract {
enum class ConfigStep {
EMAIL_ADDRESS,

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig
package app.k9mail.feature.account.setup.ui.autodiscovery
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@ -10,14 +10,14 @@ import app.k9mail.core.ui.compose.designsystem.template.Scaffold
import app.k9mail.core.ui.compose.theme.K9Theme
import app.k9mail.core.ui.compose.theme.ThunderbirdTheme
import app.k9mail.feature.account.setup.R
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.Effect
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.Event
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.ViewModel
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Effect
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Event
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.ViewModel
import app.k9mail.feature.account.setup.ui.common.AccountSetupBottomBar
import app.k9mail.feature.account.setup.ui.common.AccountSetupTopHeader
@Composable
internal fun AccountAutoConfigScreen(
internal fun AccountAutoDiscoveryScreen(
onNext: () -> Unit,
onBack: () -> Unit,
viewModel: ViewModel,
@ -44,7 +44,7 @@ internal fun AccountAutoConfigScreen(
},
modifier = modifier,
) { innerPadding ->
AccountAutoConfigContent(
AccountAutoDiscoveryContent(
state = state.value,
onEvent = { dispatch(it) },
contentPadding = innerPadding,
@ -54,13 +54,13 @@ internal fun AccountAutoConfigScreen(
@Composable
@DevicePreviews
internal fun AccountAutoConfigScreenK9Preview() {
internal fun AccountAutoDiscoveryScreenK9Preview() {
K9Theme {
AccountAutoConfigScreen(
AccountAutoDiscoveryScreen(
onNext = {},
onBack = {},
viewModel = AccountAutoConfigViewModel(
validator = AccountAutoConfigValidator(),
viewModel = AccountAutoDiscoveryViewModel(
validator = AccountAutoDiscoveryValidator(),
getAutoDiscovery = { AutoDiscoveryResult.NoUsableSettingsFound },
),
)
@ -69,13 +69,13 @@ internal fun AccountAutoConfigScreenK9Preview() {
@Composable
@DevicePreviews
internal fun AccountAutoConfigScreenThunderbirdPreview() {
internal fun AccountAutoDiscoveryScreenThunderbirdPreview() {
ThunderbirdTheme {
AccountAutoConfigScreen(
AccountAutoDiscoveryScreen(
onNext = {},
onBack = {},
viewModel = AccountAutoConfigViewModel(
validator = AccountAutoConfigValidator(),
viewModel = AccountAutoDiscoveryViewModel(
validator = AccountAutoDiscoveryValidator(),
getAutoDiscovery = { AutoDiscoveryResult.NoUsableSettingsFound },
),
)

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig
package app.k9mail.feature.account.setup.ui.autodiscovery
import app.k9mail.core.common.domain.usecase.validation.ValidationResult
import app.k9mail.feature.account.setup.domain.DomainContract.UseCase
@ -6,11 +6,11 @@ import app.k9mail.feature.account.setup.domain.usecase.ValidateConfigurationAppr
import app.k9mail.feature.account.setup.domain.usecase.ValidateEmailAddress
import app.k9mail.feature.account.setup.domain.usecase.ValidatePassword
internal class AccountAutoConfigValidator(
internal class AccountAutoDiscoveryValidator(
private val emailAddressValidator: UseCase.ValidateEmailAddress = ValidateEmailAddress(),
private val passwordValidator: UseCase.ValidatePassword = ValidatePassword(),
private val configurationApprovalValidator: UseCase.ValidateConfigurationApproval = ValidateConfigurationApproval(),
) : AccountAutoConfigContract.Validator {
) : AccountAutoDiscoveryContract.Validator {
override fun validateEmailAddress(emailAddress: String): ValidationResult {
return emailAddressValidator.execute(emailAddress)

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig
package app.k9mail.feature.account.setup.ui.autodiscovery
import androidx.lifecycle.viewModelScope
import app.k9mail.autodiscovery.api.AutoDiscoveryResult
@ -6,17 +6,17 @@ import app.k9mail.core.common.domain.usecase.validation.ValidationResult
import app.k9mail.core.ui.compose.common.mvi.BaseViewModel
import app.k9mail.feature.account.setup.domain.DomainContract.UseCase
import app.k9mail.feature.account.setup.domain.input.StringInputField
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.ConfigStep
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.Effect
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.Error
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.Event
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.State
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.Validator
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.ViewModel
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.ConfigStep
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Effect
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Error
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Event
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.State
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Validator
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.ViewModel
import kotlinx.coroutines.launch
@Suppress("TooManyFunctions")
internal class AccountAutoConfigViewModel(
internal class AccountAutoDiscoveryViewModel(
initialState: State = State(),
private val validator: Validator,
private val getAutoDiscovery: UseCase.GetAutoDiscovery,
@ -88,7 +88,7 @@ internal class AccountAutoConfigViewModel(
updateState {
it.copy(error = null)
}
loadAutoConfig()
loadAutoDiscovery()
}
private fun submitEmail() {
@ -103,12 +103,12 @@ internal class AccountAutoConfigViewModel(
}
if (!hasError) {
loadAutoConfig()
loadAutoDiscovery()
}
}
}
private fun loadAutoConfig() {
private fun loadAutoDiscovery() {
viewModelScope.launch {
updateState {
it.copy(

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig
package app.k9mail.feature.account.setup.ui.autodiscovery
import android.content.res.Resources
import app.k9mail.core.common.domain.usecase.validation.ValidationError
@ -18,10 +18,10 @@ internal fun AutoDiscoveryConnectionSecurity.toResourceString(resources: Resourc
}
}
internal fun AccountAutoConfigContract.Error.toResourceString(resources: Resources): String {
internal fun AccountAutoDiscoveryContract.Error.toResourceString(resources: Resources): String {
return when (this) {
AccountAutoConfigContract.Error.NetworkError -> resources.getString(R.string.account_setup_error_network)
AccountAutoConfigContract.Error.UnknownError -> resources.getString(R.string.account_setup_error_unknown)
AccountAutoDiscoveryContract.Error.NetworkError -> resources.getString(R.string.account_setup_error_network)
AccountAutoDiscoveryContract.Error.UnknownError -> resources.getString(R.string.account_setup_error_unknown)
}
}

View file

@ -1,10 +1,10 @@
package app.k9mail.feature.account.setup.ui.autoconfig.item
package app.k9mail.feature.account.setup.ui.autodiscovery.item
import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import app.k9mail.autodiscovery.api.AutoDiscoveryResult
import app.k9mail.feature.account.setup.ui.autoconfig.view.AutoDiscoveryStatusView
import app.k9mail.feature.account.setup.ui.autodiscovery.view.AutoDiscoveryStatusView
import app.k9mail.feature.account.setup.ui.common.item.ListItem
@Composable

View file

@ -1,10 +1,10 @@
package app.k9mail.feature.account.setup.ui.autoconfig.item
package app.k9mail.feature.account.setup.ui.autodiscovery.item
import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import app.k9mail.feature.account.setup.domain.input.BooleanInputField
import app.k9mail.feature.account.setup.ui.autoconfig.view.ConfigurationApprovalView
import app.k9mail.feature.account.setup.ui.autodiscovery.view.ConfigurationApprovalView
import app.k9mail.feature.account.setup.ui.common.item.ListItem
@Composable

View file

@ -1,9 +1,9 @@
package app.k9mail.feature.account.setup.ui.autoconfig.item
package app.k9mail.feature.account.setup.ui.autodiscovery.item
import androidx.compose.foundation.lazy.LazyListScope
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.ConfigStep
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.Event
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.State
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.ConfigStep
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Event
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.State
internal fun LazyListScope.contentItems(
state: State,

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig.item
package app.k9mail.feature.account.setup.ui.autodiscovery.item
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.lazy.LazyItemScope

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig.item
package app.k9mail.feature.account.setup.ui.autodiscovery.item
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.lazy.LazyItemScope

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig.view
package app.k9mail.feature.account.setup.ui.autodiscovery.view
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
@ -26,7 +26,8 @@ import app.k9mail.core.ui.compose.designsystem.atom.text.TextBody2
import app.k9mail.core.ui.compose.theme.Icons
import app.k9mail.core.ui.compose.theme.MainTheme
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
import app.k9mail.feature.account.setup.ui.autoconfig.toResourceString
import app.k9mail.feature.account.setup.ui.autodiscovery.toResourceString
import app.k9mail.feature.account.setup.ui.common.toResourceString
@Composable
internal fun AutoDiscoveryServerSettingsView(

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig.view
package app.k9mail.feature.account.setup.ui.autodiscovery.view
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
@ -11,7 +11,9 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.autodiscovery.api.AuthenticationType
import app.k9mail.autodiscovery.api.AutoDiscoveryResult
import app.k9mail.autodiscovery.api.ConnectionSecurity
import app.k9mail.autodiscovery.api.ImapServerSettings
import app.k9mail.autodiscovery.api.SmtpServerSettings
import app.k9mail.core.common.net.toHostname
@ -112,15 +114,15 @@ internal fun AutoDiscoveryStatusBodyViewPreview() {
incomingServerSettings = ImapServerSettings(
hostname = "imap.example.com".toHostname(),
port = 993.toPort(),
connectionSecurity = app.k9mail.autodiscovery.api.ConnectionSecurity.TLS,
authenticationType = app.k9mail.autodiscovery.api.AuthenticationType.PasswordEncrypted,
connectionSecurity = ConnectionSecurity.TLS,
authenticationType = AuthenticationType.PasswordEncrypted,
username = "",
),
outgoingServerSettings = SmtpServerSettings(
hostname = "smtp.example.com".toHostname(),
port = 465.toPort(),
connectionSecurity = app.k9mail.autodiscovery.api.ConnectionSecurity.TLS,
authenticationType = app.k9mail.autodiscovery.api.AuthenticationType.PasswordEncrypted,
connectionSecurity = ConnectionSecurity.TLS,
authenticationType = AuthenticationType.PasswordEncrypted,
username = "",
),
isTrusted = true,

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig.view
package app.k9mail.feature.account.setup.ui.autodiscovery.view
import androidx.annotation.StringRes
import androidx.compose.ui.graphics.vector.ImageVector

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig.view
package app.k9mail.feature.account.setup.ui.autodiscovery.view
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig.view
package app.k9mail.feature.account.setup.ui.autodiscovery.view
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.border

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig.view
package app.k9mail.feature.account.setup.ui.autodiscovery.view
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
@ -11,7 +11,7 @@ import app.k9mail.core.ui.compose.designsystem.molecule.input.CheckboxInput
import app.k9mail.core.ui.compose.theme.MainTheme
import app.k9mail.feature.account.setup.R
import app.k9mail.feature.account.setup.domain.input.BooleanInputField
import app.k9mail.feature.account.setup.ui.autoconfig.toResourceString
import app.k9mail.feature.account.setup.ui.autodiscovery.toResourceString
@Composable
internal fun ConfigurationApprovalView(

View file

@ -63,7 +63,7 @@ internal fun AccountSetupTopHeader(
@Preview
@Composable
internal fun AccountAutoConfigTopHeaderPreview() {
internal fun AccountSetupTopHeaderPreview() {
PreviewWithThemes {
AccountSetupTopHeader()
}

View file

@ -1,7 +1,7 @@
package app.k9mail.feature.account.setup
import app.k9mail.feature.account.setup.ui.AccountSetupContract
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract
import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract
import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract
@ -31,7 +31,7 @@ class AccountSetupModuleKtTest : KoinTest {
featureAccountSetupModule.verify(
extraTypes = listOf(
AccountSetupContract.State::class,
AccountAutoConfigContract.State::class,
AccountAutoDiscoveryContract.State::class,
AccountIncomingConfigContract.State::class,
AccountOutgoingConfigContract.State::class,
AccountOptionsContract.State::class,

View file

@ -7,7 +7,7 @@ import app.k9mail.core.ui.compose.theme.ThunderbirdTheme
import app.k9mail.feature.account.setup.ui.AccountSetupContract.Effect
import app.k9mail.feature.account.setup.ui.AccountSetupContract.SetupStep
import app.k9mail.feature.account.setup.ui.AccountSetupContract.State
import app.k9mail.feature.account.setup.ui.autoconfig.FakeAccountAutoConfigViewModel
import app.k9mail.feature.account.setup.ui.autodiscovery.FakeAccountAutoDiscoveryViewModel
import app.k9mail.feature.account.setup.ui.incoming.FakeAccountIncomingConfigViewModel
import app.k9mail.feature.account.setup.ui.options.FakeAccountOptionsViewModel
import app.k9mail.feature.account.setup.ui.outgoing.FakeAccountOutgoingConfigViewModel
@ -23,7 +23,7 @@ class AccountSetupScreenKtTest : ComposeTest() {
@Test
fun `should display correct screen for every setup step`() = runTest {
val viewModel = FakeAccountSetupViewModel()
val autoConfigViewModel = FakeAccountAutoConfigViewModel()
val autoDiscoveryViewModel = FakeAccountAutoDiscoveryViewModel()
val incomingViewModel = FakeAccountIncomingConfigViewModel()
val outgoingViewModel = FakeAccountOutgoingConfigViewModel()
val optionsViewModel = FakeAccountOptionsViewModel()
@ -34,7 +34,7 @@ class AccountSetupScreenKtTest : ComposeTest() {
onFinish = { },
onBack = { },
viewModel = viewModel,
autoConfigViewModel = autoConfigViewModel,
autoDiscoveryViewModel = autoDiscoveryViewModel,
incomingViewModel = incomingViewModel,
outgoingViewModel = outgoingViewModel,
optionsViewModel = optionsViewModel,
@ -52,7 +52,7 @@ class AccountSetupScreenKtTest : ComposeTest() {
fun `should delegate navigation effects`() = runTest {
val initialState = State()
val viewModel = FakeAccountSetupViewModel(initialState)
val autoConfigViewModel = FakeAccountAutoConfigViewModel()
val autoDiscoveryViewModel = FakeAccountAutoDiscoveryViewModel()
val incomingViewModel = FakeAccountIncomingConfigViewModel()
val outgoingViewModel = FakeAccountOutgoingConfigViewModel()
val optionsViewModel = FakeAccountOptionsViewModel()
@ -65,7 +65,7 @@ class AccountSetupScreenKtTest : ComposeTest() {
onFinish = { onFinishCounter++ },
onBack = { onBackCounter++ },
viewModel = viewModel,
autoConfigViewModel = autoConfigViewModel,
autoDiscoveryViewModel = autoDiscoveryViewModel,
incomingViewModel = incomingViewModel,
outgoingViewModel = outgoingViewModel,
optionsViewModel = optionsViewModel,
@ -88,7 +88,7 @@ class AccountSetupScreenKtTest : ComposeTest() {
}
private fun getTagForStep(step: SetupStep): String = when (step) {
SetupStep.AUTO_CONFIG -> "AccountAutoConfigContent"
SetupStep.AUTO_CONFIG -> "AccountAutoDiscoveryContent"
SetupStep.INCOMING_CONFIG -> "AccountIncomingConfigContent"
SetupStep.OUTGOING_CONFIG -> "AccountOutgoingConfigContent"
SetupStep.OPTIONS -> "AccountOptionsContent"

View file

@ -1,26 +0,0 @@
package app.k9mail.feature.account.setup.ui.autoconfig
import app.k9mail.core.ui.compose.common.mvi.BaseViewModel
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.Effect
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.Event
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.State
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.ViewModel
class FakeAccountAutoConfigViewModel(
initialState: State = State(),
) : BaseViewModel<State, Event, Effect>(initialState), ViewModel {
val events = mutableListOf<Event>()
override fun initState(state: State) {
updateState { state }
}
override fun event(event: Event) {
events.add(event)
}
fun effect(effect: Effect) {
emitEffect(effect)
}
}

View file

@ -1,29 +1,27 @@
package app.k9mail.feature.account.setup.ui.autoconfig
package app.k9mail.feature.account.setup.ui.autodiscovery
import app.k9mail.core.ui.compose.testing.ComposeTest
import app.k9mail.core.ui.compose.testing.setContent
import app.k9mail.core.ui.compose.theme.ThunderbirdTheme
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.Effect
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.State
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Effect
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.State
import assertk.assertThat
import assertk.assertions.isEqualTo
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Test
@OptIn(ExperimentalCoroutinesApi::class)
class AccountAutoConfigScreenKtTest : ComposeTest() {
class AccountAutoDiscoveryScreenKtTest : ComposeTest() {
@Test
fun `should delegate navigation effects`() = runTest {
val initialState = State()
val viewModel = FakeAccountAutoConfigViewModel(initialState)
val viewModel = FakeAccountAutoDiscoveryViewModel(initialState)
var onNextCounter = 0
var onBackCounter = 0
setContent {
ThunderbirdTheme {
AccountAutoConfigScreen(
AccountAutoDiscoveryScreen(
onNext = { onNextCounter++ },
onBack = { onBackCounter++ },
viewModel = viewModel,

View file

@ -1,14 +1,14 @@
package app.k9mail.feature.account.setup.ui.autoconfig
package app.k9mail.feature.account.setup.ui.autodiscovery
import app.k9mail.feature.account.setup.domain.input.BooleanInputField
import app.k9mail.feature.account.setup.domain.input.StringInputField
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.ConfigStep
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.State
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.ConfigStep
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.State
import assertk.assertThat
import assertk.assertions.isEqualTo
import org.junit.Test
class AccountAutoConfigStateTest {
class AccountAutoDiscoveryStateTest {
@Test
fun `should set default values`() {

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.autoconfig
package app.k9mail.feature.account.setup.ui.autodiscovery
import app.cash.turbine.testIn
import app.k9mail.autodiscovery.api.AutoDiscoveryResult
@ -9,11 +9,11 @@ import app.k9mail.feature.account.setup.domain.entity.AutoDiscoverySettingsFixtu
import app.k9mail.feature.account.setup.domain.input.BooleanInputField
import app.k9mail.feature.account.setup.domain.input.StringInputField
import app.k9mail.feature.account.setup.testing.eventStateTest
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.ConfigStep
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.Effect
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.Error
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.Event
import app.k9mail.feature.account.setup.ui.autoconfig.AccountAutoConfigContract.State
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.ConfigStep
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Effect
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Error
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Event
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.State
import assertk.assertThat
import assertk.assertions.assertThatAndTurbinesConsumed
import assertk.assertions.isEqualTo
@ -22,13 +22,13 @@ import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
class AccountAutoConfigViewModelTest {
class AccountAutoDiscoveryViewModelTest {
@get:Rule
val mainDispatcherRule = MainDispatcherRule()
private val testSubject = AccountAutoConfigViewModel(
validator = FakeAccountAutoConfigValidator(),
private val testSubject = AccountAutoDiscoveryViewModel(
validator = FakeAccountAutoDiscoveryValidator(),
getAutoDiscovery = {
delay(50)
AutoDiscoveryResult.NoUsableSettingsFound
@ -91,8 +91,8 @@ class AccountAutoConfigViewModelTest {
configStep = ConfigStep.EMAIL_ADDRESS,
emailAddress = StringInputField(value = "email"),
)
val viewModel = AccountAutoConfigViewModel(
validator = FakeAccountAutoConfigValidator(),
val viewModel = AccountAutoDiscoveryViewModel(
validator = FakeAccountAutoDiscoveryValidator(),
getAutoDiscovery = {
delay(50)
autoDiscoverySettings
@ -147,8 +147,8 @@ class AccountAutoConfigViewModelTest {
emailAddress = StringInputField(value = "email"),
)
val discoveryError = Exception("discovery error")
val viewModel = AccountAutoConfigViewModel(
validator = FakeAccountAutoConfigValidator(),
val viewModel = AccountAutoDiscoveryViewModel(
validator = FakeAccountAutoDiscoveryValidator(),
getAutoDiscovery = {
delay(50)
AutoDiscoveryResult.UnexpectedException(discoveryError)
@ -184,7 +184,7 @@ class AccountAutoConfigViewModelTest {
val failureState = validatedState.copy(
isLoading = false,
error = AccountAutoConfigContract.Error.UnknownError,
error = AccountAutoDiscoveryContract.Error.UnknownError,
)
assertThatAndTurbinesConsumed(
actual = stateTurbine.awaitItem(),
@ -229,8 +229,8 @@ class AccountAutoConfigViewModelTest {
configStep = ConfigStep.EMAIL_ADDRESS,
emailAddress = StringInputField(value = "invalid email"),
)
val viewModel = AccountAutoConfigViewModel(
validator = FakeAccountAutoConfigValidator(
val viewModel = AccountAutoDiscoveryViewModel(
validator = FakeAccountAutoDiscoveryValidator(
emailAddressAnswer = ValidationResult.Failure(TestError),
),
getAutoDiscovery = { AutoDiscoveryResult.NoUsableSettingsFound },
@ -312,8 +312,8 @@ class AccountAutoConfigViewModelTest {
emailAddress = StringInputField(value = "email"),
password = StringInputField(value = "password"),
)
val viewModel = AccountAutoConfigViewModel(
validator = FakeAccountAutoConfigValidator(
val viewModel = AccountAutoDiscoveryViewModel(
validator = FakeAccountAutoDiscoveryValidator(
passwordAnswer = ValidationResult.Failure(TestError),
),
getAutoDiscovery = { AutoDiscoveryResult.NoUsableSettingsFound },

View file

@ -1,12 +1,12 @@
package app.k9mail.feature.account.setup.ui.autoconfig
package app.k9mail.feature.account.setup.ui.autodiscovery
import app.k9mail.core.common.domain.usecase.validation.ValidationResult
class FakeAccountAutoConfigValidator(
class FakeAccountAutoDiscoveryValidator(
private val emailAddressAnswer: ValidationResult = ValidationResult.Success,
private val passwordAnswer: ValidationResult = ValidationResult.Success,
private val configurationApprovalAnswer: ValidationResult = ValidationResult.Success,
) : AccountAutoConfigContract.Validator {
) : AccountAutoDiscoveryContract.Validator {
override fun validateEmailAddress(emailAddress: String): ValidationResult = emailAddressAnswer
override fun validatePassword(password: String): ValidationResult = passwordAnswer
override fun validateConfigurationApproval(

View file

@ -0,0 +1,26 @@
package app.k9mail.feature.account.setup.ui.autodiscovery
import app.k9mail.core.ui.compose.common.mvi.BaseViewModel
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Effect
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Event
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.State
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.ViewModel
class FakeAccountAutoDiscoveryViewModel(
initialState: State = State(),
) : BaseViewModel<State, Event, Effect>(initialState), ViewModel {
val events = mutableListOf<Event>()
override fun initState(state: State) {
updateState { state }
}
override fun event(event: Event) {
events.add(event)
}
fun effect(effect: Effect) {
emitEffect(effect)
}
}