Add explicit title to reset password screen dialogs (#1364)

This commit is contained in:
David Perez 2024-05-13 12:49:56 -05:00 committed by Álison Fernandes
parent 0379e68a5c
commit 1ede84d22c
4 changed files with 14 additions and 15 deletions

View file

@ -31,7 +31,6 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.x8bit.bitwarden.R import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.data.auth.datasource.disk.model.ForcePasswordResetReason import com.x8bit.bitwarden.data.auth.datasource.disk.model.ForcePasswordResetReason
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenMediumTopAppBar import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenMediumTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
@ -59,7 +58,7 @@ fun ResetPasswordScreen(
is ResetPasswordState.DialogState.Error -> { is ResetPasswordState.DialogState.Error -> {
BitwardenBasicDialog( BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown( visibilityState = BasicDialogState.Shown(
title = dialog.title ?: R.string.an_error_has_occurred.asText(), title = dialog.title,
message = dialog.message, message = dialog.message,
), ),
onDismissRequest = remember(viewModel) { onDismissRequest = remember(viewModel) {

View file

@ -101,7 +101,7 @@ class ResetPasswordViewModel @Inject constructor(
mutableStateFlow.update { mutableStateFlow.update {
it.copy( it.copy(
dialogState = ResetPasswordState.DialogState.Error( dialogState = ResetPasswordState.DialogState.Error(
title = null, title = R.string.an_error_has_occurred.asText(),
message = R.string.validation_field_required message = R.string.validation_field_required
.asText(R.string.master_password.asText()), .asText(R.string.master_password.asText()),
), ),
@ -126,7 +126,7 @@ class ResetPasswordViewModel @Inject constructor(
mutableStateFlow.update { mutableStateFlow.update {
it.copy( it.copy(
dialogState = ResetPasswordState.DialogState.Error( dialogState = ResetPasswordState.DialogState.Error(
title = null, title = R.string.an_error_has_occurred.asText(),
message = R.string.master_password_length_val_message_x message = R.string.master_password_length_val_message_x
.asText(MIN_PASSWORD_LENGTH), .asText(MIN_PASSWORD_LENGTH),
), ),
@ -218,7 +218,7 @@ class ResetPasswordViewModel @Inject constructor(
mutableStateFlow.update { mutableStateFlow.update {
it.copy( it.copy(
dialogState = ResetPasswordState.DialogState.Error( dialogState = ResetPasswordState.DialogState.Error(
title = null, title = R.string.an_error_has_occurred.asText(),
message = R.string.generic_error_message.asText(), message = R.string.generic_error_message.asText(),
), ),
) )
@ -243,7 +243,7 @@ class ResetPasswordViewModel @Inject constructor(
mutableStateFlow.update { mutableStateFlow.update {
it.copy( it.copy(
dialogState = ResetPasswordState.DialogState.Error( dialogState = ResetPasswordState.DialogState.Error(
title = null, title = R.string.an_error_has_occurred.asText(),
message = R.string.generic_error_message.asText(), message = R.string.generic_error_message.asText(),
), ),
) )
@ -256,7 +256,7 @@ class ResetPasswordViewModel @Inject constructor(
mutableStateFlow.update { mutableStateFlow.update {
it.copy( it.copy(
dialogState = ResetPasswordState.DialogState.Error( dialogState = ResetPasswordState.DialogState.Error(
title = null, title = R.string.an_error_has_occurred.asText(),
message = R.string.invalid_master_password.asText(), message = R.string.invalid_master_password.asText(),
), ),
) )
@ -309,7 +309,7 @@ class ResetPasswordViewModel @Inject constructor(
mutableStateFlow.update { mutableStateFlow.update {
it.copy( it.copy(
dialogState = ResetPasswordState.DialogState.Error( dialogState = ResetPasswordState.DialogState.Error(
title = null, title = R.string.an_error_has_occurred.asText(),
message = R.string.master_password_confirmation_val_message.asText(), message = R.string.master_password_confirmation_val_message.asText(),
), ),
) )
@ -365,7 +365,7 @@ data class ResetPasswordState(
*/ */
@Parcelize @Parcelize
data class Error( data class Error(
val title: Text? = null, val title: Text?,
val message: Text, val message: Text,
) : DialogState() ) : DialogState()

View file

@ -31,7 +31,7 @@ import org.junit.Test
class ResetPasswordScreenTest : BaseComposeTest() { class ResetPasswordScreenTest : BaseComposeTest() {
private val mutableEventFlow = bufferedMutableSharedFlow<ResetPasswordEvent>() private val mutableEventFlow = bufferedMutableSharedFlow<ResetPasswordEvent>()
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE) private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
val viewModel = mockk<ResetPasswordViewModel>(relaxed = true) { private val viewModel = mockk<ResetPasswordViewModel>(relaxed = true) {
every { eventFlow } returns mutableEventFlow every { eventFlow } returns mutableEventFlow
every { stateFlow } returns mutableStateFlow every { stateFlow } returns mutableStateFlow
} }

View file

@ -62,7 +62,7 @@ class ResetPasswordViewModelTest : BaseViewModelTest() {
assertEquals( assertEquals(
DEFAULT_STATE.copy( DEFAULT_STATE.copy(
dialogState = ResetPasswordState.DialogState.Error( dialogState = ResetPasswordState.DialogState.Error(
title = null, title = R.string.an_error_has_occurred.asText(),
message = R.string.validation_field_required message = R.string.validation_field_required
.asText(R.string.master_password.asText()), .asText(R.string.master_password.asText()),
), ),
@ -116,7 +116,7 @@ class ResetPasswordViewModelTest : BaseViewModelTest() {
DEFAULT_STATE.copy( DEFAULT_STATE.copy(
resetReason = ForcePasswordResetReason.ADMIN_FORCE_PASSWORD_RESET, resetReason = ForcePasswordResetReason.ADMIN_FORCE_PASSWORD_RESET,
dialogState = ResetPasswordState.DialogState.Error( dialogState = ResetPasswordState.DialogState.Error(
title = null, title = R.string.an_error_has_occurred.asText(),
message = R.string.master_password_length_val_message_x message = R.string.master_password_length_val_message_x
.asText(MIN_PASSWORD_LENGTH), .asText(MIN_PASSWORD_LENGTH),
), ),
@ -141,7 +141,7 @@ class ResetPasswordViewModelTest : BaseViewModelTest() {
assertEquals( assertEquals(
DEFAULT_STATE.copy( DEFAULT_STATE.copy(
dialogState = ResetPasswordState.DialogState.Error( dialogState = ResetPasswordState.DialogState.Error(
title = null, title = R.string.an_error_has_occurred.asText(),
message = R.string.master_password_confirmation_val_message.asText(), message = R.string.master_password_confirmation_val_message.asText(),
), ),
passwordInput = password, passwordInput = password,
@ -171,7 +171,7 @@ class ResetPasswordViewModelTest : BaseViewModelTest() {
assertEquals( assertEquals(
DEFAULT_STATE.copy( DEFAULT_STATE.copy(
dialogState = ResetPasswordState.DialogState.Error( dialogState = ResetPasswordState.DialogState.Error(
title = null, title = R.string.an_error_has_occurred.asText(),
message = R.string.generic_error_message.asText(), message = R.string.generic_error_message.asText(),
), ),
currentPasswordInput = currentPassword, currentPasswordInput = currentPassword,
@ -203,7 +203,7 @@ class ResetPasswordViewModelTest : BaseViewModelTest() {
assertEquals( assertEquals(
DEFAULT_STATE.copy( DEFAULT_STATE.copy(
dialogState = ResetPasswordState.DialogState.Error( dialogState = ResetPasswordState.DialogState.Error(
title = null, title = R.string.an_error_has_occurred.asText(),
message = R.string.invalid_master_password.asText(), message = R.string.invalid_master_password.asText(),
), ),
currentPasswordInput = currentPassword, currentPasswordInput = currentPassword,