BIT-712: Adding UI for the FastMail service (#459)

This commit is contained in:
joshua-livefront
2023-12-29 15:23:11 -05:00
committed by GitHub
parent 4deeb40b10
commit fd1f112293
4 changed files with 187 additions and 1 deletions

View File

@@ -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")

View File

@@ -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 =