mirror of
https://github.com/bitwarden/android.git
synced 2026-05-30 16:43:22 -05:00
BIT-712: Adding UI for the FastMail service (#459)
This commit is contained in:
@@ -1055,6 +1055,46 @@ class GeneratorScreenTest : BaseComposeTest() {
|
||||
|
||||
//endregion DuckDuckGo Service Type Tests
|
||||
|
||||
//region FastMail Service Type Tests
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `in Username_ForwardedEmailAlias_FastMail state, updating api key text input should send ApiKeyTextChange action`() {
|
||||
updateState(
|
||||
GeneratorState(
|
||||
generatedText = "Placeholder",
|
||||
selectedType = GeneratorState.MainType.Username(
|
||||
GeneratorState.MainType.Username.UsernameType.ForwardedEmailAlias(
|
||||
selectedServiceType = GeneratorState
|
||||
.MainType
|
||||
.Username
|
||||
.UsernameType
|
||||
.ForwardedEmailAlias
|
||||
.ServiceType
|
||||
.FastMail(),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
val newApiKey = "apiKey"
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText("API key (required)")
|
||||
.performScrollTo()
|
||||
.performTextInput(newApiKey)
|
||||
|
||||
verify {
|
||||
viewModel.trySendAction(
|
||||
GeneratorAction.MainType.Username.UsernameType.ForwardedEmailAlias.FastMail.ApiKeyTextChange(
|
||||
apiKey = newApiKey,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
//endregion FastMail Service Type Tests
|
||||
|
||||
//region FirefoxRelay Service Type Tests
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
|
||||
@@ -37,6 +37,9 @@ class GeneratorViewModelTest : BaseViewModelTest() {
|
||||
private val initialDuckDuckGoState = createDuckDuckGoState()
|
||||
private val duckDuckGoSavedStateHandle = createSavedStateHandleWithState(initialDuckDuckGoState)
|
||||
|
||||
private val initialFastMailState = createFastMailState()
|
||||
private val fastMailSavedStateHandle = createSavedStateHandleWithState(initialFastMailState)
|
||||
|
||||
private val initialFirefoxRelay = createFirefoxRelayState()
|
||||
private val firefoxRelaySavedStateHandle = createSavedStateHandleWithState(initialFirefoxRelay)
|
||||
|
||||
@@ -1083,6 +1086,50 @@ class GeneratorViewModelTest : BaseViewModelTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
inner class FastMailActions {
|
||||
private val defaultFastMailState = createFastMailState()
|
||||
private lateinit var viewModel: GeneratorViewModel
|
||||
|
||||
@BeforeEach
|
||||
fun setup() {
|
||||
viewModel = GeneratorViewModel(fastMailSavedStateHandle, fakeGeneratorRepository)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ApiKeyTextChange should update api key text correctly`() = runTest {
|
||||
val newApiKey = "newApiKey"
|
||||
val action = GeneratorAction
|
||||
.MainType
|
||||
.Username
|
||||
.UsernameType
|
||||
.ForwardedEmailAlias
|
||||
.FastMail.ApiKeyTextChange(
|
||||
apiKey = newApiKey,
|
||||
)
|
||||
|
||||
viewModel.actionChannel.trySend(action)
|
||||
|
||||
val expectedState = defaultFastMailState.copy(
|
||||
selectedType = GeneratorState.MainType.Username(
|
||||
GeneratorState.MainType.Username.UsernameType.ForwardedEmailAlias(
|
||||
selectedServiceType = GeneratorState
|
||||
.MainType
|
||||
.Username
|
||||
.UsernameType
|
||||
.ForwardedEmailAlias
|
||||
.ServiceType
|
||||
.FastMail(
|
||||
apiKey = newApiKey,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
assertEquals(expectedState, viewModel.stateFlow.value)
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
inner class FirefoxRelayActions {
|
||||
private val defaultFirefoxRelayState = createFirefoxRelayState()
|
||||
@@ -1371,6 +1418,24 @@ class GeneratorViewModelTest : BaseViewModelTest() {
|
||||
),
|
||||
)
|
||||
|
||||
private fun createFastMailState(
|
||||
generatedText: String = "defaultFastMail",
|
||||
): GeneratorState =
|
||||
GeneratorState(
|
||||
generatedText = generatedText,
|
||||
selectedType = GeneratorState.MainType.Username(
|
||||
GeneratorState.MainType.Username.UsernameType.ForwardedEmailAlias(
|
||||
selectedServiceType = GeneratorState
|
||||
.MainType
|
||||
.Username
|
||||
.UsernameType
|
||||
.ForwardedEmailAlias
|
||||
.ServiceType
|
||||
.FastMail(),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
private fun createFirefoxRelayState(
|
||||
generatedText: String = "defaultFirefoxRelay",
|
||||
): GeneratorState =
|
||||
|
||||
Reference in New Issue
Block a user