From 3ba2f704e3c5e1aae5d45789c7803bdbee660f19 Mon Sep 17 00:00:00 2001 From: Patrick Honkonen <1883101+SaintPatrck@users.noreply.github.com> Date: Fri, 15 Mar 2024 16:46:44 -0400 Subject: [PATCH] BIT-2040 Correct redirect behavior for Import Items action (#1150) --- .../feature/settings/vault/VaultSettingsScreen.kt | 2 +- .../feature/settings/vault/VaultSettingsViewModel.kt | 6 ------ .../feature/settings/vault/VaultSettingsScreenTest.kt | 10 +++++++++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsScreen.kt index a33a94f62..5b10ea0e9 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsScreen.kt @@ -117,7 +117,7 @@ fun VaultSettingsScreen( dialogMessage = stringResource( id = R.string.you_can_import_data_to_your_vault_on_x, - state.value.baseUrl, + state.value.importUrl, ), modifier = Modifier .semantics { testTag = "ImportItemsLinkItemView" } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsViewModel.kt index 5e7ed853b..f1f390643 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsViewModel.kt @@ -1,7 +1,6 @@ package com.x8bit.bitwarden.ui.platform.feature.settings.vault import com.x8bit.bitwarden.data.platform.repository.EnvironmentRepository -import com.x8bit.bitwarden.data.platform.repository.util.baseWebVaultUrlOrDefault import com.x8bit.bitwarden.data.platform.repository.util.toBaseWebVaultImportUrl import com.x8bit.bitwarden.ui.platform.base.BaseViewModel import dagger.hilt.android.lifecycle.HiltViewModel @@ -16,10 +15,6 @@ class VaultSettingsViewModel @Inject constructor( ) : BaseViewModel( initialState = run { VaultSettingsState( - baseUrl = environmentRepository - .environment - .environmentUrlData - .baseWebVaultUrlOrDefault, importUrl = environmentRepository .environment .environmentUrlData @@ -58,7 +53,6 @@ class VaultSettingsViewModel @Inject constructor( * Models the state for the VaultSettingScreen. */ data class VaultSettingsState( - val baseUrl: String, val importUrl: String, ) diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsScreenTest.kt index 5edbb9cea..1bb798f5a 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsScreenTest.kt @@ -29,7 +29,7 @@ class VaultSettingsScreenTest : BaseComposeTest() { private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow( VaultSettingsState( - baseUrl = "testUrl", importUrl = "testUrl/#/tools/import", + importUrl = "testUrl/#/tools/import", ), ) private val intentManager: IntentManager = mockk(relaxed = true) { @@ -97,6 +97,14 @@ class VaultSettingsScreenTest : BaseComposeTest() { } } + @Test + fun `import items click should display dialog with importUrl`() { + composeTestRule.onNodeWithText("Import items").performClick() + composeTestRule + .onNodeWithText(mutableStateFlow.value.importUrl, substring = true) + .assertIsDisplayed() + } + @Test fun `NavigateBack should call onNavigateBack`() { mutableEventFlow.tryEmit(VaultSettingsEvent.NavigateBack)