PM-21156: Fix ConfigService retrofit instance (#5126)

This commit is contained in:
David Perez
2025-05-05 09:51:47 -05:00
committed by GitHub
parent 1a2beea770
commit 07469672ba
4 changed files with 5 additions and 7 deletions

View File

@@ -18,7 +18,6 @@ import com.x8bit.bitwarden.ui.platform.feature.settings.autofill.chrome.model.Ch
import com.x8bit.bitwarden.ui.platform.util.persistentListOfNotNull
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
@@ -58,7 +57,9 @@ class AutoFillViewModel @Inject constructor(
defaultUriMatchType = settingsRepository.defaultUriMatchType,
showAutofillActionCard = false,
activeUserId = userId,
chromeAutofillSettingsOptions = persistentListOf(),
chromeAutofillSettingsOptions = chromeThirdPartyAutofillEnabledManager
.chromeThirdPartyAutofillStatus
.toChromeAutoFillSettingsOptions(),
)
},
) {

View File

@@ -50,6 +50,7 @@ class AutoFillViewModelTest : BaseViewModelTest() {
private val chromeThirdPartyAutofillEnabledManager =
mockk<ChromeThirdPartyAutofillEnabledManager> {
every { chromeThirdPartyAutofillStatusFlow } returns mutableChromeAutofillStatusFlow
every { chromeThirdPartyAutofillStatus } returns DEFAULT_AUTOFILL_STATUS
}
private val settingsRepository: SettingsRepository = mockk {
@@ -79,7 +80,6 @@ class AutoFillViewModelTest : BaseViewModelTest() {
@Test
fun `initial state should be correct when not set`() {
mockkStatic(::isBuildVersionBelow)
every { isBuildVersionBelow(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) } returns false
val viewModel = createViewModel(state = null)
@@ -90,7 +90,6 @@ class AutoFillViewModelTest : BaseViewModelTest() {
@Test
fun `initial state should be correct when set`() {
mockkStatic(::isBuildVersionBelow)
every { isBuildVersionBelow(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) } returns false
mutableIsAutofillEnabledStateFlow.value = true
@@ -106,7 +105,6 @@ class AutoFillViewModelTest : BaseViewModelTest() {
@Test
fun `initial state should be correct when sdk is below min`() {
mockkStatic(::isBuildVersionBelow)
every { isBuildVersionBelow(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) } returns true
val expected = DEFAULT_STATE.copy(

View File

@@ -118,7 +118,7 @@ internal class BitwardenServiceClientImpl(
override val configService: ConfigService by lazy {
ConfigServiceImpl(
configApi = retrofits.createStaticRetrofit().create(),
configApi = retrofits.unauthenticatedApiRetrofit.create(),
)
}

View File

@@ -7,7 +7,6 @@ import com.bitwarden.network.util.toResult
/**
* Default implementation of [ConfigService] for querying app configurations.
*/
// TODO [PM-19846] Make internal when dependents are migrated.
internal class ConfigServiceImpl(private val configApi: ConfigApi) : ConfigService {
override suspend fun getConfig(): Result<ConfigResponseJson> = configApi.getConfig().toResult()
}