diff --git a/app/app/src/main/kotlin/com/hedvig/android/app/ui/HedvigApp.kt b/app/app/src/main/kotlin/com/hedvig/android/app/ui/HedvigApp.kt index 9b7f4d1194..183e1f79a4 100644 --- a/app/app/src/main/kotlin/com/hedvig/android/app/ui/HedvigApp.kt +++ b/app/app/src/main/kotlin/com/hedvig/android/app/ui/HedvigApp.kt @@ -32,7 +32,6 @@ import com.hedvig.android.feature.force.upgrade.ForceUpgradeBlockingScreen import com.hedvig.android.feature.login.navigation.LoginDestination import com.hedvig.android.featureflags.FeatureManager import com.hedvig.android.language.LanguageService -import com.hedvig.android.logger.LogPriority import com.hedvig.android.logger.logcat import com.hedvig.android.market.MarketManager import com.hedvig.android.navigation.activity.ExternalNavigator diff --git a/app/data/data-changetier/src/main/kotlin/com/hedvig/android/data/changetier/data/CreateChangeTierDeductibleIntentUseCase.kt b/app/data/data-changetier/src/main/kotlin/com/hedvig/android/data/changetier/data/CreateChangeTierDeductibleIntentUseCase.kt index 2d5fb0d753..dfe5e3e730 100644 --- a/app/data/data-changetier/src/main/kotlin/com/hedvig/android/data/changetier/data/CreateChangeTierDeductibleIntentUseCase.kt +++ b/app/data/data-changetier/src/main/kotlin/com/hedvig/android/data/changetier/data/CreateChangeTierDeductibleIntentUseCase.kt @@ -35,100 +35,94 @@ internal class CreateChangeTierDeductibleIntentUseCaseImpl( source: ChangeTierCreateSource, ): Either { return either { - val isTierEnabled = featureManager.isFeatureEnabled(Feature.TIER).first() val isAddonFlagEnabled = featureManager.isFeatureEnabled(Feature.TRAVEL_ADDON).first() - if (!isTierEnabled) { - logcat(ERROR) { "Tried to get changeTierQuotes when feature flag is disabled!" } - raise(ErrorMessage()) - } else { - val changeTierDeductibleResponse = apolloClient - .mutation( - ChangeTierDeductibleCreateIntentMutation( - contractId = insuranceId, - source = source.toSource(), - addonsFlagOn = isAddonFlagEnabled, - ), - ) - .safeExecute() - val intent = changeTierDeductibleResponse.getOrNull()?.changeTierDeductibleCreateIntent?.intent - if (intent != null) { - if (intent.quotes.isNotEmpty()) { - val currentQuote = with(intent.agreementToChange) { - ensureNotNull(tierLevel) { - ErrorMessage("For insuranceId:$insuranceId and source:$source, agreementToChange tierLevel was null") - } - ensureNotNull(tierName) { - ErrorMessage("For insuranceId:$insuranceId and source:$source, agreementToChange tierName was null") - } - TierDeductibleQuote( - id = TierConstants.CURRENT_ID, - deductible = deductible?.toDeductible(), - premium = UiMoney.fromMoneyFragment(premium), - productVariant = productVariant.toProductVariant(), - tier = Tier( - tierName = tierName, - tierLevel = tierLevel, - tierDescription = productVariant.tierDescription, - tierDisplayName = productVariant.displayNameTier, - ), - displayItems = displayItems.toDisplayItems(), - addons = emptyList(), // todo: we don't show current agreement addon anywhere - ) + val changeTierDeductibleResponse = apolloClient + .mutation( + ChangeTierDeductibleCreateIntentMutation( + contractId = insuranceId, + source = source.toSource(), + addonsFlagOn = isAddonFlagEnabled, + ), + ) + .safeExecute() + val intent = changeTierDeductibleResponse.getOrNull()?.changeTierDeductibleCreateIntent?.intent + if (intent != null) { + if (intent.quotes.isNotEmpty()) { + val currentQuote = with(intent.agreementToChange) { + ensureNotNull(tierLevel) { + ErrorMessage("For insuranceId:$insuranceId and source:$source, agreementToChange tierLevel was null") } - val quotesToOffer = intent.quotes.map { - ensureNotNull(it.tierLevel) { - ErrorMessage("For insuranceId:$insuranceId and source:$source, tierLevel was null") - } - ensureNotNull(it.tierName) { - ErrorMessage("For insuranceId:$insuranceId and source:$source, tierName was null") - } - TierDeductibleQuote( - id = it.id, - deductible = it.deductible?.toDeductible(), - displayItems = it.displayItems.toDisplayItems(), - premium = UiMoney.fromMoneyFragment(it.premium), - productVariant = it.productVariant.toProductVariant(), - tier = Tier( - tierName = it.tierName, - tierLevel = it.tierLevel, - tierDescription = it.productVariant.tierDescription, - tierDisplayName = it.productVariant.displayNameTier, - ), - addons = it.addons?.map { addon -> - ChangeTierDeductibleAddonQuote( - addonId = addon.addonId, - displayName = addon.displayName, - displayItems = addon.displayItems.toDisplayItems(), - previousPremium = UiMoney.fromMoneyFragment(addon.previousPremium), - premium = UiMoney.fromMoneyFragment(addon.premium), - addonVariant = addon.addonVariant.toAddonVariant(), - ) - } ?: emptyList(), - ) + ensureNotNull(tierName) { + ErrorMessage("For insuranceId:$insuranceId and source:$source, agreementToChange tierName was null") } - val intentResult = ChangeTierDeductibleIntent( - activationDate = intent.activationDate, - quotes = listOf(currentQuote) + quotesToOffer, + TierDeductibleQuote( + id = TierConstants.CURRENT_ID, + deductible = deductible?.toDeductible(), + premium = UiMoney.fromMoneyFragment(premium), + productVariant = productVariant.toProductVariant(), + tier = Tier( + tierName = tierName, + tierLevel = tierLevel, + tierDescription = productVariant.tierDescription, + tierDisplayName = productVariant.displayNameTier, + ), + displayItems = displayItems.toDisplayItems(), + addons = emptyList(), // todo: we don't show current agreement addon anywhere ) - logcat(LogPriority.VERBOSE) { "createChangeTierDeductibleIntentUseCase has intent: $intentResult" } - intentResult - } else { - val intentResult = ChangeTierDeductibleIntent( - activationDate = intent.activationDate, - quotes = listOf(), + } + val quotesToOffer = intent.quotes.map { + ensureNotNull(it.tierLevel) { + ErrorMessage("For insuranceId:$insuranceId and source:$source, tierLevel was null") + } + ensureNotNull(it.tierName) { + ErrorMessage("For insuranceId:$insuranceId and source:$source, tierName was null") + } + TierDeductibleQuote( + id = it.id, + deductible = it.deductible?.toDeductible(), + displayItems = it.displayItems.toDisplayItems(), + premium = UiMoney.fromMoneyFragment(it.premium), + productVariant = it.productVariant.toProductVariant(), + tier = Tier( + tierName = it.tierName, + tierLevel = it.tierLevel, + tierDescription = it.productVariant.tierDescription, + tierDisplayName = it.productVariant.displayNameTier, + ), + addons = it.addons?.map { addon -> + ChangeTierDeductibleAddonQuote( + addonId = addon.addonId, + displayName = addon.displayName, + displayItems = addon.displayItems.toDisplayItems(), + previousPremium = UiMoney.fromMoneyFragment(addon.previousPremium), + premium = UiMoney.fromMoneyFragment(addon.premium), + addonVariant = addon.addonVariant.toAddonVariant(), + ) + } ?: emptyList(), ) - logcat(LogPriority.VERBOSE) { "createChangeTierDeductibleIntentUseCase has intent: $intentResult" } - intentResult } + val intentResult = ChangeTierDeductibleIntent( + activationDate = intent.activationDate, + quotes = listOf(currentQuote) + quotesToOffer, + ) + logcat(LogPriority.VERBOSE) { "createChangeTierDeductibleIntentUseCase has intent: $intentResult" } + intentResult } else { - if (changeTierDeductibleResponse.isRight()) { - logcat(ERROR) { "Tried to get changeTierQuotes but output intent is null!" } - } - if (changeTierDeductibleResponse.isLeft()) { - logcat(ERROR) { "Tried to get changeTierQuotes but got error: $changeTierDeductibleResponse!" } - } - raise(ErrorMessage()) + val intentResult = ChangeTierDeductibleIntent( + activationDate = intent.activationDate, + quotes = listOf(), + ) + logcat(LogPriority.VERBOSE) { "createChangeTierDeductibleIntentUseCase has intent: $intentResult" } + intentResult } + } else { + if (changeTierDeductibleResponse.isRight()) { + logcat(ERROR) { "Tried to get changeTierQuotes but output intent is null!" } + } + if (changeTierDeductibleResponse.isLeft()) { + logcat(ERROR) { "Tried to get changeTierQuotes but got error: $changeTierDeductibleResponse!" } + } + raise(ErrorMessage()) } } } diff --git a/app/data/data-changetier/src/test/kotlin/data/CreateChangeTierDeductibleIntentUseCaseImplTest.kt b/app/data/data-changetier/src/test/kotlin/data/CreateChangeTierDeductibleIntentUseCaseImplTest.kt index 1eff575712..da708a715d 100644 --- a/app/data/data-changetier/src/test/kotlin/data/CreateChangeTierDeductibleIntentUseCaseImplTest.kt +++ b/app/data/data-changetier/src/test/kotlin/data/CreateChangeTierDeductibleIntentUseCaseImplTest.kt @@ -353,7 +353,7 @@ class CreateChangeTierDeductibleIntentUseCaseImplTest { @Test fun `when BE response has empty quotes return intent with empty quotes`() = runTest { - val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TIER to true, Feature.TRAVEL_ADDON to true)) + val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TRAVEL_ADDON to true)) val createChangeTierDeductibleIntentUseCase = CreateChangeTierDeductibleIntentUseCaseImpl( apolloClient = apolloClientWithGoodResponseButEmptyQuotes, featureManager = featureManager, @@ -367,13 +367,8 @@ class CreateChangeTierDeductibleIntentUseCaseImplTest { } @Test - fun `when response is fine and tier feature flag is on get a good result`() = runTest { - val featureManager = FakeFeatureManager2( - fixedMap = mapOf( - Feature.TIER to true, - Feature.TRAVEL_ADDON to true, - ), - ) + fun `when response is fine get a good result`() = runTest { + val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TRAVEL_ADDON to true)) val createChangeTierDeductibleIntentUseCase = CreateChangeTierDeductibleIntentUseCaseImpl( apolloClient = apolloClientWithGoodResponse, featureManager = featureManager, @@ -399,37 +394,9 @@ class CreateChangeTierDeductibleIntentUseCaseImplTest { .isEqualTo(500.0) } - @Test - fun `when response is fine but tier feature flag is off the result is ErrorMessage`() = runTest { - val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TIER to false, Feature.TRAVEL_ADDON to true)) - val createChangeTierDeductibleIntentUseCase = CreateChangeTierDeductibleIntentUseCaseImpl( - apolloClient = apolloClientWithGoodResponse, - featureManager = featureManager, - ) - val result = createChangeTierDeductibleIntentUseCase.invoke(testId, ChangeTierCreateSource.SELF_SERVICE) - - assertk.assertThat(result) - .isNotNull() - .isLeft() - } - - @Test - fun `when response is bad and tier feature flag is on the result is ErrorMessage`() = runTest { - val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TIER to true, Feature.TRAVEL_ADDON to true)) - val createChangeTierDeductibleIntentUseCase = CreateChangeTierDeductibleIntentUseCaseImpl( - apolloClient = apolloClientWithBadResponse, - featureManager = featureManager, - ) - val result = createChangeTierDeductibleIntentUseCase.invoke(testId, ChangeTierCreateSource.SELF_SERVICE) - - assertk.assertThat(result) - .isNotNull() - .isLeft() - } - @Test fun `when response is otherwise good but the intent is null the result is ErrorMessage`() = runTest { - val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TIER to true, Feature.TRAVEL_ADDON to true)) + val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TRAVEL_ADDON to true)) val createChangeTierDeductibleIntentUseCase = CreateChangeTierDeductibleIntentUseCaseImpl( apolloClient = apolloClientWithGoodButNullResponse, featureManager = featureManager, @@ -444,7 +411,7 @@ class CreateChangeTierDeductibleIntentUseCaseImplTest { @Test fun `when response is otherwise good but the tierName in existing agreement is null the result is ErrorMessage`() = runTest { - val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TIER to true, Feature.TRAVEL_ADDON to true)) + val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TRAVEL_ADDON to true)) val createChangeTierDeductibleIntentUseCase = CreateChangeTierDeductibleIntentUseCaseImpl( apolloClient = apolloClientWithGoodResponseButNullTierNameInExisting, featureManager = featureManager, @@ -459,7 +426,7 @@ class CreateChangeTierDeductibleIntentUseCaseImplTest { @Test fun `when response is otherwise good but the tierName in one of the quotes is null the result is ErrorMessage`() = runTest { - val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TIER to true, Feature.TRAVEL_ADDON to true)) + val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TRAVEL_ADDON to true)) val createChangeTierDeductibleIntentUseCase = CreateChangeTierDeductibleIntentUseCaseImpl( apolloClient = apolloClientWithGoodResponseButNullTierNameInOneQuote, featureManager = featureManager, @@ -473,7 +440,7 @@ class CreateChangeTierDeductibleIntentUseCaseImplTest { @Test fun `in good response one of the quotes should have the current const id`() = runTest { - val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TIER to true, Feature.TRAVEL_ADDON to true)) + val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TRAVEL_ADDON to true)) val createChangeTierDeductibleIntentUseCase = CreateChangeTierDeductibleIntentUseCaseImpl( apolloClient = apolloClientWithGoodResponse, featureManager = featureManager, @@ -492,4 +459,18 @@ class CreateChangeTierDeductibleIntentUseCaseImplTest { .prop(TierDeductibleQuote::id) .isEqualTo(TierConstants.CURRENT_ID) } + + @Test + fun `when response is bad the result is ErrorMessage`() = runTest { + val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TRAVEL_ADDON to true)) + val createChangeTierDeductibleIntentUseCase = CreateChangeTierDeductibleIntentUseCaseImpl( + apolloClient = apolloClientWithBadResponse, + featureManager = featureManager, + ) + val result = createChangeTierDeductibleIntentUseCase.invoke(testId, ChangeTierCreateSource.SELF_SERVICE) + + assertk.assertThat(result) + .isNotNull() + .isLeft() + } } diff --git a/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/customize/CustomizeTravelAddonDestination.kt b/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/customize/CustomizeTravelAddonDestination.kt index 766c08c1c7..743d48576d 100644 --- a/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/customize/CustomizeTravelAddonDestination.kt +++ b/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/customize/CustomizeTravelAddonDestination.kt @@ -314,7 +314,8 @@ private fun CustomizeTravelAddonCard( ), size = Small, containerColor = HedvigTheme.colorScheme.fillNegative, - hintText = stringResource(R.string.ADDON_FLOW_SELECT_DAYS_PLACEHOLDER), // there is always one option chosen, should never be shown anyway + // there is always one option chosen, should never be shown anyway + hintText = stringResource(R.string.ADDON_FLOW_SELECT_DAYS_PLACEHOLDER), chosenItemIndex = uiState.travelAddonOffer.addonOptions.indexOf(uiState.currentlyChosenOption) .takeIf { it >= 0 }, onDoAlongWithDismissRequest = onSetOptionBackToPreviouslyChosen, diff --git a/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/summary/AddonSummaryDestination.kt b/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/summary/AddonSummaryDestination.kt index 4e8cbbf33f..1eb89057c3 100644 --- a/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/summary/AddonSummaryDestination.kt +++ b/app/feature/feature-addon-purchase/src/main/kotlin/com/hedvig/android/feature/addon/purchase/ui/summary/AddonSummaryDestination.kt @@ -168,8 +168,8 @@ private fun SummarySuccessScreen(uiState: Content, onConfirmClick: () -> Unit, n R.string.ADDON_FLOW_PRICE_LABEL, uiState.totalPriceChange.amount.toInt(), ) - } // without + (supposedly with minus) - else { + } else { + // without + (supposedly with minus) stringResource( R.string.TERMINATION_FLOW_PAYMENT_PER_MONTH, // todo: mb better to have a separate key? uiState.totalPriceChange.amount.toInt(), diff --git a/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/data/GetCurrentContractDataUseCase.kt b/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/data/GetCurrentContractDataUseCase.kt index 68006a01b1..5169937640 100644 --- a/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/data/GetCurrentContractDataUseCase.kt +++ b/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/data/GetCurrentContractDataUseCase.kt @@ -5,11 +5,8 @@ import arrow.core.raise.either import com.apollographql.apollo.ApolloClient import com.hedvig.android.apollo.safeExecute import com.hedvig.android.core.common.ErrorMessage -import com.hedvig.android.featureflags.FeatureManager -import com.hedvig.android.featureflags.flags.Feature.TIER import com.hedvig.android.logger.LogPriority.ERROR import com.hedvig.android.logger.logcat -import kotlinx.coroutines.flow.first import octopus.CurrentContractsForTierChangeQuery internal interface GetCurrentContractDataUseCase { @@ -18,15 +15,9 @@ internal interface GetCurrentContractDataUseCase { internal class GetCurrentContractDataUseCaseImpl( private val apolloClient: ApolloClient, - private val featureManager: FeatureManager, ) : GetCurrentContractDataUseCase { override suspend fun invoke(insuranceId: String): Either { return either { - val isTierEnabled = featureManager.isFeatureEnabled(TIER).first() - if (!isTierEnabled) { - logcat(ERROR) { "Tried to start Change Tier flow when feature flag is disabled" } - raise(ErrorMessage("Tried to start Change Tier flow when feature flag is disabled")) - } val result = apolloClient .query(CurrentContractsForTierChangeQuery()) .safeExecute() diff --git a/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/data/GetCustomizableInsurancesUseCase.kt b/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/data/GetCustomizableInsurancesUseCase.kt index 9525f4140a..191a7630d7 100644 --- a/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/data/GetCustomizableInsurancesUseCase.kt +++ b/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/data/GetCustomizableInsurancesUseCase.kt @@ -10,10 +10,8 @@ import com.hedvig.android.apollo.safeFlow import com.hedvig.android.core.common.ErrorMessage import com.hedvig.android.data.contract.ContractGroup import com.hedvig.android.data.contract.toContractGroup -import com.hedvig.android.featureflags.FeatureManager -import com.hedvig.android.featureflags.flags.Feature import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.map import octopus.ContractsEligibleForTierChangeQuery interface GetCustomizableInsurancesUseCase { @@ -22,22 +20,16 @@ interface GetCustomizableInsurancesUseCase { internal class GetCustomizableInsurancesUseCaseImpl( private val apolloClient: ApolloClient, - private val featureManager: FeatureManager, ) : GetCustomizableInsurancesUseCase { override suspend fun invoke(): Flow?>> { - return combine( - featureManager.isFeatureEnabled(Feature.TIER), - apolloClient - .query(ContractsEligibleForTierChangeQuery()) - .safeFlow(::ErrorMessage), - ) { isEnabled, memberResponse -> - either { - if (!isEnabled) { - raise(ErrorMessage()) + return apolloClient + .query(ContractsEligibleForTierChangeQuery()) + .safeFlow(::ErrorMessage) + .map { memberResponse -> + either { + memberResponse.bind().currentMember.toInsurancesForChangingTier().toNonEmptyListOrNull() } - memberResponse.bind().currentMember.toInsurancesForChangingTier().toNonEmptyListOrNull() } - } } } diff --git a/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/di/ChooseTierModule.kt b/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/di/ChooseTierModule.kt index 4476a98890..a666603b9e 100644 --- a/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/di/ChooseTierModule.kt +++ b/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/di/ChooseTierModule.kt @@ -12,7 +12,6 @@ import com.hedvig.android.feature.change.tier.ui.chooseinsurance.ChooseInsurance import com.hedvig.android.feature.change.tier.ui.stepcustomize.SelectCoverageViewModel import com.hedvig.android.feature.change.tier.ui.stepstart.StartTierFlowViewModel import com.hedvig.android.feature.change.tier.ui.stepsummary.SummaryViewModel -import com.hedvig.android.featureflags.FeatureManager import org.koin.core.module.dsl.viewModel import org.koin.dsl.module @@ -42,14 +41,12 @@ val chooseTierModule = module { single { GetCurrentContractDataUseCaseImpl( apolloClient = get(), - featureManager = get(), ) } single { GetCustomizableInsurancesUseCaseImpl( apolloClient = get(), - featureManager = get(), ) } diff --git a/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/ui/stepcustomize/SelectCoverageViewModel.kt b/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/ui/stepcustomize/SelectCoverageViewModel.kt index 1e358c9417..39ac5a9f97 100644 --- a/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/ui/stepcustomize/SelectCoverageViewModel.kt +++ b/app/feature/feature-choose-tier/src/main/kotlin/com/hedvig/android/feature/change/tier/ui/stepcustomize/SelectCoverageViewModel.kt @@ -306,7 +306,8 @@ internal data class SelectCoverageSuccessUiState( val isTierChoiceEnabled: Boolean, val quoteToNavigateFurther: TierDeductibleQuote? = null, val quotesToCompare: List? = null, - val tiers: List>, // sorted list of tiers with corresponding premiums (depending on selected deductible) + // sorted list of tiers with corresponding premiums (depending on selected deductible) + val tiers: List>, val quotesForChosenTier: List, ) diff --git a/app/feature/feature-choose-tier/src/test/kotlin/data/GetCustomizableInsurancesUseCase.kt b/app/feature/feature-choose-tier/src/test/kotlin/data/GetCustomizableInsurancesUseCase.kt index 2849a1c492..60a95e7948 100644 --- a/app/feature/feature-choose-tier/src/test/kotlin/data/GetCustomizableInsurancesUseCase.kt +++ b/app/feature/feature-choose-tier/src/test/kotlin/data/GetCustomizableInsurancesUseCase.kt @@ -12,8 +12,6 @@ import com.hedvig.android.apollo.test.TestNetworkTransportType import com.hedvig.android.core.common.test.isLeft import com.hedvig.android.core.common.test.isRight import com.hedvig.android.feature.change.tier.data.GetCustomizableInsurancesUseCaseImpl -import com.hedvig.android.featureflags.flags.Feature -import com.hedvig.android.featureflags.test.FakeFeatureManager2 import com.hedvig.android.logger.TestLogcatLoggingRule import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.first @@ -106,11 +104,7 @@ class GetCustomizableInsurancesUseCaseImplTest { @Test fun `when response is fine and tier feature flag is on the result is good`() = runTest { - val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TIER to true)) - val useCase = GetCustomizableInsurancesUseCaseImpl( - apolloClient = apolloClientWithGoodResponse, - featureManager = featureManager, - ) + val useCase = GetCustomizableInsurancesUseCaseImpl(apolloClient = apolloClientWithGoodResponse) useCase.invoke().collectLatest { result -> assertk.assertThat(result.getOrNull()?.first()?.displayName) .isNotNull().isEqualTo("Variant") @@ -118,38 +112,16 @@ class GetCustomizableInsurancesUseCaseImplTest { } @Test - fun `when response is fine but tier feature flag is off the result is ErrorMessage`() = runTest { - val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TIER to false)) - val useCase = GetCustomizableInsurancesUseCaseImpl( - apolloClient = apolloClientWithGoodResponse, - featureManager = featureManager, - ) + fun `when response is bad the result is ErrorMessage`() = runTest { + val useCase = GetCustomizableInsurancesUseCaseImpl(apolloClient = apolloClientWithBadResponse) useCase.invoke().collectLatest { result -> - assertk.assertThat(result) - .isLeft() - } - } - - @Test - fun `when response is bad and tier feature flag is on the result is ErrorMessage`() = runTest { - val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TIER to true)) - val useCase = GetCustomizableInsurancesUseCaseImpl( - apolloClient = apolloClientWithBadResponse, - featureManager = featureManager, - ) - useCase.invoke().collectLatest { result -> - assertk.assertThat(result) - .isLeft() + assertk.assertThat(result).isLeft() } } @Test fun `when response is otherwise good but there is no customizable insurance in it return null`() = runTest { - val featureManager = FakeFeatureManager2(fixedMap = mapOf(Feature.TIER to true)) - val useCase = GetCustomizableInsurancesUseCaseImpl( - apolloClient = apolloClientWithGoodResponseButNotEligible, - featureManager = featureManager, - ) + val useCase = GetCustomizableInsurancesUseCaseImpl(apolloClient = apolloClientWithGoodResponseButNotEligible) val result = useCase.invoke().first() assertk.assertThat(result).isRight().isNull() } diff --git a/app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/EditCoInsuredAddMissingInfoDestination.kt b/app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/EditCoInsuredAddMissingInfoDestination.kt index a64deb7d87..b39d47a1ae 100644 --- a/app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/EditCoInsuredAddMissingInfoDestination.kt +++ b/app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/EditCoInsuredAddMissingInfoDestination.kt @@ -141,7 +141,8 @@ private fun EditCoInsuredScreen( onCompleted(uiState.contractUpdateDate) } } - val hedvigBottomSheetState = rememberHedvigBottomSheetState() + val hedvigBottomSheetState = + rememberHedvigBottomSheetState() DismissSheetOnSuccessfulInfoChangeEffect(hedvigBottomSheetState, uiState.finishedAdding) ClearBottomSheetContentStateOnSheetDismissedEffect(hedvigBottomSheetState, onResetAddBottomSheetState) HedvigBottomSheet( @@ -168,7 +169,9 @@ private fun EditCoInsuredScreen( .fillMaxSize() .padding( WindowInsets - .safeDrawing.only(WindowInsetsSides.Horizontal).asPaddingValues(), + .safeDrawing + .only(WindowInsetsSides.Horizontal) + .asPaddingValues(), ) .verticalScroll(state = rememberScrollState()), ) { @@ -190,7 +193,9 @@ private fun EditCoInsuredScreen( id = R.string.CONTRACT_ADD_COINSURED_REVIEW_INFO, ), priority = NotificationDefaults.NotificationPriority.Attention, - modifier = Modifier.padding(horizontal = 16.dp).fillMaxWidth(), + modifier = Modifier + .padding(horizontal = 16.dp) + .fillMaxWidth(), ) } @@ -203,7 +208,9 @@ private fun EditCoInsuredScreen( onClick = onCommitChanges, enabled = true, isLoading = uiState.listState.isCommittingUpdate, - modifier = Modifier.padding(horizontal = 16.dp).fillMaxWidth(), + modifier = Modifier + .padding(horizontal = 16.dp) + .fillMaxWidth(), ) } } @@ -211,7 +218,9 @@ private fun EditCoInsuredScreen( HedvigTextButton( onClick = navigateUp, text = stringResource(R.string.general_cancel_button), - modifier = Modifier.padding(horizontal = 16.dp).fillMaxWidth(), + modifier = Modifier + .padding(horizontal = 16.dp) + .fillMaxWidth(), ) Spacer(Modifier.height(16.dp)) Spacer(Modifier.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom))) diff --git a/app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/EditCoInsuredPresenter.kt b/app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/EditCoInsuredPresenter.kt index 5c4f9863b7..8dfa05347d 100644 --- a/app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/EditCoInsuredPresenter.kt +++ b/app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/EditCoInsuredPresenter.kt @@ -484,10 +484,14 @@ internal sealed interface EditCoInsuredState { ) { fun canPickExistingCoInsured() = !selectableCoInsured.isNullOrEmpty() - fun canContinue() = - (showManualInput && manualInfo.firstName != null && manualInfo.lastName != null && manualInfo.birthDate != null) || - (!showManualInput && infoFromSsn.ssn?.length == 12) || - (selectedCoInsured != null) + fun canContinue() = ( + showManualInput && + manualInfo.firstName != null && + manualInfo.lastName != null && + manualInfo.birthDate != null + ) || + (!showManualInput && infoFromSsn.ssn?.length == 12) || + (selectedCoInsured != null) fun shouldFetchInfo() = !showManualInput && infoFromSsn.ssn != null && infoFromSsn.firstName == null && infoFromSsn.lastName == null diff --git a/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/data/GetMemberActionsUseCase.kt b/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/data/GetMemberActionsUseCase.kt index 77fc7cc688..649ba2e4d9 100644 --- a/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/data/GetMemberActionsUseCase.kt +++ b/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/data/GetMemberActionsUseCase.kt @@ -32,7 +32,6 @@ internal class GetMemberActionsUseCaseImpl( { featureManager.isFeatureEnabled(Feature.EDIT_COINSURED).first() }, { featureManager.isFeatureEnabled(Feature.MOVING_FLOW).first() }, { featureManager.isFeatureEnabled(Feature.PAYMENT_SCREEN).first() }, - { featureManager.isFeatureEnabled(Feature.TIER).first() }, { marketManager.selectedMarket().filterNotNull().first() }, { apolloClient @@ -45,7 +44,6 @@ internal class GetMemberActionsUseCaseImpl( isCoInsuredFeatureOn, isMovingFeatureOn, isConnectPaymentFeatureOn, - isTierEnabled, market, memberActions, -> @@ -58,7 +56,7 @@ internal class GetMemberActionsUseCaseImpl( isTravelCertificateEnabled = memberActions?.isTravelCertificateEnabled ?: false, sickAbroadAction = memberActions?.sickAbroadAction.toSickAbroadAction(), firstVetAction = memberActions?.firstVetAction?.toVetAction(), - isTierChangeEnabled = isTierEnabled && memberActions?.isChangeTierEnabled ?: false, + isTierChangeEnabled = memberActions?.isChangeTierEnabled ?: false, ) } } diff --git a/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/data/GetQuickLinksUseCase.kt b/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/data/GetQuickLinksUseCase.kt index ee2280841f..4a40a731dd 100644 --- a/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/data/GetQuickLinksUseCase.kt +++ b/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/data/GetQuickLinksUseCase.kt @@ -52,8 +52,7 @@ internal class GetQuickLinksUseCase( add(quickAction) } } - // double-check - here and in getMemberActionsUseCase, but why not - if (memberActionOptions.isTierChangeEnabled && featureManager.isFeatureEnabled(Feature.TIER).first()) { + if (memberActionOptions.isTierChangeEnabled) { add( QuickAction.StandaloneQuickLink( quickLinkDestination = QuickLinkDestination.OuterDestination.QuickLinkChangeTier, diff --git a/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/model/Question.kt b/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/model/Question.kt index d070109353..c61bcf2441 100644 --- a/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/model/Question.kt +++ b/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/model/Question.kt @@ -182,15 +182,17 @@ internal enum class Question( COVERAGE_Q23( titleRes = R.string.HC_COVERAGE_TITLE, questionRes = R.string.HC_COVERAGE_Q_23, - answerRes = R.string.HC_COVERAGE_A_23), + answerRes = R.string.HC_COVERAGE_A_23, + ), COVERAGE_Q24( titleRes = R.string.HC_COVERAGE_TITLE, questionRes = R.string.HC_COVERAGE_Q_24, - answerRes = R.string.HC_COVERAGE_A_24), + answerRes = R.string.HC_COVERAGE_A_24, + ), COVERAGE_Q25( titleRes = R.string.HC_COVERAGE_TITLE, questionRes = R.string.HC_COVERAGE_Q_25, - answerRes = R.string.HC_COVERAGE_A_25 + answerRes = R.string.HC_COVERAGE_A_25, ), // INSURANCE diff --git a/app/feature/feature-help-center/src/test/kotlin/GetMemberActionsUseCaseImpl.kt b/app/feature/feature-help-center/src/test/kotlin/GetMemberActionsUseCaseImpl.kt index 2dba901b77..90c35b52c4 100644 --- a/app/feature/feature-help-center/src/test/kotlin/GetMemberActionsUseCaseImpl.kt +++ b/app/feature/feature-help-center/src/test/kotlin/GetMemberActionsUseCaseImpl.kt @@ -81,59 +81,32 @@ class GetMemberActionsUseCaseImplTest { } @Test - fun `when response has isChangeTierEnabled as true but FF is off MemberAction should have isTierChangeEnabled as false`() = - runTest { - val featureManager = FakeFeatureManager2( - fixedMap = mapOf( - Feature.TIER to false, - Feature.MOVING_FLOW to true, - Feature.EDIT_COINSURED to true, - Feature.PAYMENT_SCREEN to true, - ), - ) - val marketManager = FakeMarketManager() - val subjectUseCase = GetMemberActionsUseCaseImpl( - apolloClient = apolloClientWithGoodResponseTierChangeTrue, - featureManager = featureManager, - marketManager = marketManager, - ) - val result = subjectUseCase.invoke() - assertk.assertThat(result) - .isRight() - .prop(MemberAction::isTierChangeEnabled) - .isFalse() - } - - @Test - fun `when response has isChangeTierEnabled as true and FF is on MemberAction should have isTierChangeEnabled as true`() = - runTest { - val featureManager = FakeFeatureManager2( - fixedMap = mapOf( - Feature.TIER to true, - Feature.MOVING_FLOW to true, - Feature.EDIT_COINSURED to true, - Feature.PAYMENT_SCREEN to true, - ), - ) - val marketManager = FakeMarketManager() - val subjectUseCase = GetMemberActionsUseCaseImpl( - apolloClient = apolloClientWithGoodResponseTierChangeTrue, - featureManager = featureManager, - marketManager = marketManager, - ) - val result = subjectUseCase.invoke() - assertk.assertThat(result) - .isRight() - .prop(MemberAction::isTierChangeEnabled) - .isTrue() - } + fun `when response has isChangeTierEnabled as true MemberAction should have isTierChangeEnabled as true`() = runTest { + val featureManager = FakeFeatureManager2( + fixedMap = mapOf( + Feature.MOVING_FLOW to true, + Feature.EDIT_COINSURED to true, + Feature.PAYMENT_SCREEN to true, + ), + ) + val marketManager = FakeMarketManager() + val subjectUseCase = GetMemberActionsUseCaseImpl( + apolloClient = apolloClientWithGoodResponseTierChangeTrue, + featureManager = featureManager, + marketManager = marketManager, + ) + val result = subjectUseCase.invoke() + assertk.assertThat(result) + .isRight() + .prop(MemberAction::isTierChangeEnabled) + .isTrue() + } @Test - fun `when FF is on but response has isChangeTierEnabled as false MemberAction should have isTierChangeEnabled as false`() = + fun `when response has isChangeTierEnabled as false MemberAction should have isTierChangeEnabled as false`() = runTest { val featureManager = FakeFeatureManager2( fixedMap = mapOf( - Feature.TIER to true, Feature.MOVING_FLOW to true, Feature.EDIT_COINSURED to true, Feature.PAYMENT_SCREEN to true, diff --git a/app/feature/feature-help-center/src/test/kotlin/GetQuickLinksUseCaseTest.kt b/app/feature/feature-help-center/src/test/kotlin/GetQuickLinksUseCaseTest.kt index 9bf9b2411c..9f09a5a60f 100644 --- a/app/feature/feature-help-center/src/test/kotlin/GetQuickLinksUseCaseTest.kt +++ b/app/feature/feature-help-center/src/test/kotlin/GetQuickLinksUseCaseTest.kt @@ -61,7 +61,7 @@ class GetQuickLinksUseCaseTest { } @Test - fun `when response is fine and tier feature flag is on return ChangeTier quickAction`() = runTest { + fun `when response is fine return ChangeTier quickAction`() = runTest { val featureManager = FakeFeatureManager2(fixedReturnForAll = true) val getMemberActionsUseCase = FakeGetMemberActionsUseCase() getMemberActionsUseCase.turbine.add(fakeMemberActionWithTier.right()) @@ -92,38 +92,7 @@ class GetQuickLinksUseCaseTest { } @Test - fun `when response is fine but tier feature flag is off should not contain ChangeTier quickAction`() = runTest { - val featureManager = FakeFeatureManager2(fixedReturnForAll = false) - val getMemberActionsUseCase = FakeGetMemberActionsUseCase() - getMemberActionsUseCase.turbine.add(fakeMemberActionWithTier.right()) - val useCase = GetQuickLinksUseCase( - apolloClient = apolloClientWithGoodResponse, - featureManager = featureManager, - getMemberActionsUseCase = getMemberActionsUseCase, - ) - val result = useCase.invoke() - val listNotEmpty = result.getOrNull()?.isNotEmpty() ?: false - assertk.assertThat(listNotEmpty).isTrue() - assertk - .assertThat(result) - .isRight() - .transform { list -> - list.filterIsInstance() - .none { - it.links.contains( - QuickAction.StandaloneQuickLink( - quickLinkDestination = QuickLinkDestination.OuterDestination.QuickLinkChangeTier, - titleRes = R.string.HC_QUICK_ACTIONS_UPGRADE_COVERAGE_TITLE, - hintTextRes = R.string.HC_QUICK_ACTIONS_UPGRADE_COVERAGE_SUBTITLE, - ), - ) - } - } - .isTrue() - } - - @Test - fun `when tier feature flag is on but response says cannot change tier should not contain ChangeTier quickAction`() = + fun `when response says cannot change tier should not contain ChangeTier quickAction`() = runTest { val featureManager = FakeFeatureManager2(fixedReturnForAll = true) val getMemberActionsUseCase = FakeGetMemberActionsUseCase() diff --git a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt index b70992119f..5fbae1054c 100644 --- a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt +++ b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt @@ -39,8 +39,7 @@ internal class GetInsuranceContractsUseCaseImpl( }, featureManager.isFeatureEnabled(Feature.EDIT_COINSURED), featureManager.isFeatureEnabled(Feature.MOVING_FLOW), - featureManager.isFeatureEnabled(Feature.TIER), - ) { insuranceQueryResponse, isEditCoInsuredEnabled, isMovingFlowFlagEnabled, isTierEnabled -> + ) { insuranceQueryResponse, isEditCoInsuredEnabled, isMovingFlowFlagEnabled -> either { val insuranceQueryData = insuranceQueryResponse.bind() val contractHolderDisplayName = insuranceQueryData.getContractHolderDisplayName() @@ -54,7 +53,6 @@ internal class GetInsuranceContractsUseCaseImpl( contractHolderSSN = contractHolderSSN, isEditCoInsuredEnabled = isEditCoInsuredEnabled, isMovingFlowEnabled = isMovingEnabledForMember, - isTierFlagEnabled = isTierEnabled, ) } @@ -65,7 +63,6 @@ internal class GetInsuranceContractsUseCaseImpl( contractHolderSSN = contractHolderSSN, isEditCoInsuredEnabled = isEditCoInsuredEnabled, isMovingFlowEnabled = isMovingEnabledForMember, - isTierFlagEnabled = isTierEnabled, ) } terminatedContracts + activeContracts @@ -85,11 +82,10 @@ private fun ContractFragment.toContract( contractHolderSSN: String?, isEditCoInsuredEnabled: Boolean, isMovingFlowEnabled: Boolean, - isTierFlagEnabled: Boolean, ): InsuranceContract { return InsuranceContract( id = id, - tierName = if (isTierFlagEnabled) currentAgreement.productVariant.displayNameTier else null, + tierName = currentAgreement.productVariant.displayNameTier, displayName = currentAgreement.productVariant.displayName, contractHolderDisplayName = contractHolderDisplayName, contractHolderSSN = contractHolderSSN, @@ -136,7 +132,7 @@ private fun ContractFragment.toContract( supportsAddressChange = supportsMoving && isMovingFlowEnabled, supportsEditCoInsured = supportsCoInsured && isEditCoInsuredEnabled, isTerminated = isTerminated, - supportsTierChange = supportsChangeTier && isTierFlagEnabled, + supportsTierChange = supportsChangeTier, ) } @@ -146,7 +142,7 @@ private fun AgreementCreationCause.toCreationCause() = when (this) { AgreementCreationCause.MIDTERM_CHANGE -> InsuranceAgreement.CreationCause.MIDTERM_CHANGE AgreementCreationCause.UNKNOWN, AgreementCreationCause.UNKNOWN__, - -> InsuranceAgreement.CreationCause.UNKNOWN + -> InsuranceAgreement.CreationCause.UNKNOWN } private fun ContractFragment.CoInsured.toCoInsured(): InsuranceAgreement.CoInsured = InsuranceAgreement.CoInsured( diff --git a/app/feature/feature-insurances/src/test/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCaseImplTest.kt b/app/feature/feature-insurances/src/test/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCaseImplTest.kt index 24d846248c..ea7fe553b0 100644 --- a/app/feature/feature-insurances/src/test/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCaseImplTest.kt +++ b/app/feature/feature-insurances/src/test/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCaseImplTest.kt @@ -17,6 +17,7 @@ import kotlinx.coroutines.test.runTest import kotlinx.datetime.LocalDate import octopus.InsuranceContractsQuery import octopus.type.AgreementCreationCause.RENEWAL +import octopus.type.MemberBuilder import octopus.type.buildAgreement import octopus.type.buildContract import octopus.type.buildMember @@ -42,38 +43,9 @@ class GetInsuranceContractsUseCaseImplTest { lastName = "test" ssn = "test" terminatedContracts = listOf() - activeContracts = buildList { - add( - buildContract { - masterInceptionDate = LocalDate(2021, 3, 9) - terminationDate = null - supportsMoving = true - supportsCoInsured = true - supportsChangeTier = true - coInsured = listOf() - upcomingChangedAgreement = null - id = "id" - exposureDisplayName = "displaySubtitle" - currentAgreement = buildAgreement { - activeFrom = LocalDate(2024, 3, 9) - activeTo = LocalDate(2025, 3, 9) - certificateUrl = null - creationCause = RENEWAL - displayItems = listOf() - productVariant = buildProductVariant { - displayName = "Variant" - displayNameTier = "Standard" - tierDescription = "kjkjkjkjhkj" - typeOfContract = "Swedish home" - partner = null - perils = listOf() - insurableLimits = listOf() - documents = listOf() - } - } - }, - ) - } + activeContracts = listOf( + buildContractWithTier(true), + ) } }, ) @@ -90,71 +62,48 @@ class GetInsuranceContractsUseCaseImplTest { lastName = "test" ssn = "test" terminatedContracts = listOf() - activeContracts = buildList { - add( - buildContract { - masterInceptionDate = LocalDate(2021, 3, 9) - terminationDate = null - supportsMoving = true - supportsCoInsured = true - supportsChangeTier = false - coInsured = listOf() - upcomingChangedAgreement = null - id = "id" - exposureDisplayName = "displaySubtitle" - currentAgreement = buildAgreement { - activeFrom = LocalDate(2024, 3, 9) - activeTo = LocalDate(2025, 3, 9) - certificateUrl = null - creationCause = RENEWAL - displayItems = listOf() - productVariant = buildProductVariant { - displayName = "Variant" - displayNameTier = "Standard" - tierDescription = "kjkjkjkjhkj" - typeOfContract = "Swedish home" - partner = null - perils = listOf() - insurableLimits = listOf() - documents = listOf() - } - } - }, - ) - } + activeContracts = listOf( + buildContractWithTier(false), + ) } }, ) } - @Test - fun `when the contract response has isChangeTierEnabled as true and FF is on InsuranceContract should have supportsTierChange as true`() = - runTest { - val featureManager = FakeFeatureManager2( - fixedMap = mapOf( - Feature.TIER to true, - Feature.MOVING_FLOW to true, - Feature.EDIT_COINSURED to true, - Feature.PAYMENT_SCREEN to true, - Feature.TRAVEL_ADDON to false, - ), - ) - val subjectUseCase = GetInsuranceContractsUseCaseImpl( - apolloClient = apolloClientWithGoodResponseThatSupportsTier, - featureManager = featureManager, - ) - val result = subjectUseCase.invoke(true).first() - assertk.assertThat(result).isRight().transform { - it.first().supportsTierChange - }.isTrue() + private fun MemberBuilder.buildContractWithTier(supportsChangeTier: Boolean) = buildContract { + masterInceptionDate = LocalDate(2021, 3, 9) + terminationDate = null + supportsMoving = true + supportsCoInsured = true + this@buildContract.supportsChangeTier = supportsChangeTier + coInsured = listOf() + upcomingChangedAgreement = null + id = "id" + exposureDisplayName = "displaySubtitle" + currentAgreement = buildAgreement { + activeFrom = LocalDate(2024, 3, 9) + activeTo = LocalDate(2025, 3, 9) + certificateUrl = null + creationCause = RENEWAL + displayItems = listOf() + productVariant = buildProductVariant { + displayName = "Variant" + displayNameTier = "Standard" + tierDescription = "kjkjkjkjhkj" + typeOfContract = "Swedish home" + partner = null + perils = listOf() + insurableLimits = listOf() + documents = listOf() + } } + } @Test - fun `when the contract response has isChangeTierEnabled as true but FF is off InsuranceContract should have supportsTierChange as false`() = + fun `when the contract response has isChangeTierEnabled as true, InsuranceContract should have supportsTierChange as true`() = runTest { val featureManager = FakeFeatureManager2( fixedMap = mapOf( - Feature.TIER to false, Feature.MOVING_FLOW to true, Feature.EDIT_COINSURED to true, Feature.PAYMENT_SCREEN to true, @@ -168,37 +117,14 @@ class GetInsuranceContractsUseCaseImplTest { val result = subjectUseCase.invoke(true).first() assertk.assertThat(result).isRight().transform { it.first().supportsTierChange - }.isFalse() - } - - @Test - fun `when FF is on but the contract response has isChangeTierEnabled as false InsuranceContract should have supportsTierChange as false`() = - runTest { - val featureManager = FakeFeatureManager2( - fixedMap = mapOf( - Feature.TIER to true, - Feature.MOVING_FLOW to true, - Feature.EDIT_COINSURED to true, - Feature.PAYMENT_SCREEN to true, - Feature.TRAVEL_ADDON to false, - ), - ) - val subjectUseCase = GetInsuranceContractsUseCaseImpl( - apolloClient = apolloClientWithGoodResponseWithoutTier, - featureManager = featureManager, - ) - val result = subjectUseCase.invoke(true).first() - assertk.assertThat(result).isRight().transform { - it.first().supportsTierChange - }.isFalse() + }.isTrue() } @Test - fun `when FF is off and the contract response has isChangeTierEnabled as false InsuranceContract should have supportsTierChange as false`() = + fun `when the contract response has isChangeTierEnabled as false InsuranceContract should have supportsTierChange as false`() = runTest { val featureManager = FakeFeatureManager2( fixedMap = mapOf( - Feature.TIER to false, Feature.MOVING_FLOW to true, Feature.EDIT_COINSURED to true, Feature.PAYMENT_SCREEN to true, diff --git a/app/feature/feature-terminate-insurance/src/main/kotlin/com/hedvig/android/feature/terminateinsurance/data/TerminateInsuranceRepository.kt b/app/feature/feature-terminate-insurance/src/main/kotlin/com/hedvig/android/feature/terminateinsurance/data/TerminateInsuranceRepository.kt index 616880dd59..23cd336498 100644 --- a/app/feature/feature-terminate-insurance/src/main/kotlin/com/hedvig/android/feature/terminateinsurance/data/TerminateInsuranceRepository.kt +++ b/app/feature/feature-terminate-insurance/src/main/kotlin/com/hedvig/android/feature/terminateinsurance/data/TerminateInsuranceRepository.kt @@ -9,7 +9,6 @@ import com.hedvig.android.apollo.safeExecute import com.hedvig.android.core.common.ErrorMessage import com.hedvig.android.feature.terminateinsurance.InsuranceId import com.hedvig.android.featureflags.FeatureManager -import com.hedvig.android.featureflags.flags.Feature.TIER import com.hedvig.android.featureflags.flags.Feature.TRAVEL_ADDON import kotlinx.coroutines.flow.first import kotlinx.datetime.LocalDate @@ -41,7 +40,6 @@ internal class TerminateInsuranceRepositoryImpl( ) : TerminateInsuranceRepository { override suspend fun startTerminationFlow(insuranceId: InsuranceId): Either { return either { - val isTierEnabled = featureManager.isFeatureEnabled(TIER).first() val isAddonsEnabled = featureManager.isFeatureEnabled(TRAVEL_ADDON).first() val result = apolloClient .mutation(FlowTerminationStartMutation(FlowTerminationStartInput(insuranceId.id), isAddonsEnabled)) @@ -50,13 +48,12 @@ internal class TerminateInsuranceRepositoryImpl( .flowTerminationStart terminationFlowContextStorage.saveContext(result.context) terminationFlowContextStorage.saveContractId(insuranceId.id) - result.currentStep.toTerminateInsuranceStep(isTierEnabled) + result.currentStep.toTerminateInsuranceStep() } } override suspend fun setTerminationDate(terminationDate: LocalDate): Either { return either { - val isTierEnabled = featureManager.isFeatureEnabled(TIER).first() val isAddonsEnabled = featureManager.isFeatureEnabled(TRAVEL_ADDON).first() val result = apolloClient .mutation( @@ -70,7 +67,7 @@ internal class TerminateInsuranceRepositoryImpl( .bind() .flowTerminationDateNext terminationFlowContextStorage.saveContext(result.context) - result.currentStep.toTerminateInsuranceStep(isTierEnabled) + result.currentStep.toTerminateInsuranceStep() } } @@ -78,7 +75,6 @@ internal class TerminateInsuranceRepositoryImpl( reason: TerminationReason, ): Either { return either { - val isTierEnabled = featureManager.isFeatureEnabled(TIER).first() val isAddonsEnabled = featureManager.isFeatureEnabled(TRAVEL_ADDON).first() val result = apolloClient .mutation( @@ -97,13 +93,12 @@ internal class TerminateInsuranceRepositoryImpl( .bind() .flowTerminationSurveyNext terminationFlowContextStorage.saveContext(result.context) - result.currentStep.toTerminateInsuranceStep(isTierEnabled) + result.currentStep.toTerminateInsuranceStep() } } override suspend fun confirmDeletion(): Either { return either { - val isTierEnabled = featureManager.isFeatureEnabled(TIER).first() val isAddonsEnabled = featureManager.isFeatureEnabled(TRAVEL_ADDON).first() val result = apolloClient .mutation(FlowTerminationDeletionNextMutation(terminationFlowContextStorage.getContext(), isAddonsEnabled)) @@ -111,7 +106,7 @@ internal class TerminateInsuranceRepositoryImpl( .bind() .flowTerminationDeletionNext terminationFlowContextStorage.saveContext(result.context) - result.currentStep.toTerminateInsuranceStep(isTierEnabled) + result.currentStep.toTerminateInsuranceStep() } } diff --git a/app/feature/feature-terminate-insurance/src/main/kotlin/com/hedvig/android/feature/terminateinsurance/data/TerminateInsuranceStep.kt b/app/feature/feature-terminate-insurance/src/main/kotlin/com/hedvig/android/feature/terminateinsurance/data/TerminateInsuranceStep.kt index 71f0f23863..dfa3bd5f00 100644 --- a/app/feature/feature-terminate-insurance/src/main/kotlin/com/hedvig/android/feature/terminateinsurance/data/TerminateInsuranceStep.kt +++ b/app/feature/feature-terminate-insurance/src/main/kotlin/com/hedvig/android/feature/terminateinsurance/data/TerminateInsuranceStep.kt @@ -47,9 +47,7 @@ internal sealed interface TerminateInsuranceStep { data class UnknownStep(val message: String? = "") : TerminateInsuranceStep } -internal fun TerminationFlowStepFragment.CurrentStep.toTerminateInsuranceStep( - isTierFeatureEnabled: Boolean, -): TerminateInsuranceStep { +internal fun TerminationFlowStepFragment.CurrentStep.toTerminateInsuranceStep(): TerminateInsuranceStep { return when (this) { is TerminationFlowStepFragment.FlowTerminationDateStepCurrentStep -> { TerminateInsuranceStep.TerminateInsuranceDate(minDate, maxDate, extraCoverage.toExtraCoverageItems()) @@ -66,7 +64,7 @@ internal fun TerminationFlowStepFragment.CurrentStep.toTerminateInsuranceStep( is TerminationFlowStepFragment.FlowTerminationSurveyStepCurrentStep -> { TerminateInsuranceStep.Survey( - options.toOptionList(isTierFeatureEnabled), + options.toOptionList(), ) } @@ -74,9 +72,7 @@ internal fun TerminationFlowStepFragment.CurrentStep.toTerminateInsuranceStep( } } -private fun List.toOptionList( - isTierFeatureEnabled: Boolean, -): List { +private fun List.toOptionList(): List { return map { // remade a bit of logic here. If we receive unknown actions in suggestion for one of the subOptions // (or the option itself), @@ -86,28 +82,24 @@ private fun List.noUnknownActions( - isTierFeatureEnabled: Boolean, -): Boolean { +private fun List.noUnknownActions(): Boolean { return none { subOption -> - subOption.suggestion?.toSuggestion(isTierFeatureEnabled) == UnknownAction + subOption.suggestion?.toSuggestion() == UnknownAction } } -private fun List.toSubOptionList( - isTierFeatureEnabled: Boolean, -): List { +private fun List.toSubOptionList(): List { // no subOptions if one of them contains some action that we don't know how to handle val filtered = takeIf { subs -> - subs.noUnknownActions(isTierFeatureEnabled) + subs.noUnknownActions() } ?: listOf() return filtered.map { subOption -> TerminationSurveyOption( @@ -116,14 +108,13 @@ private fun List { when (action) { @@ -135,20 +126,10 @@ private fun FlowTerminationSurveyOptionSuggestionFragment.toSuggestion( } FlowTerminationSurveyRedirectAction.CHANGE_TIER_FOUND_BETTER_PRICE -> { - if (isTierFeatureEnabled) { - SurveyOptionSuggestion.Action.DowngradePriceByChangingTier( - description = description, - buttonTitle = buttonTitle, - ) - } else { - logcat( - LogPriority.ERROR, - message = { - "FlowTerminationSurveyStepCurrentStep suggestion: CHANGE_TIER_FOUND_BETTER_PRICE but tier feature flag is disabled!" - }, - ) - UnknownAction - } + SurveyOptionSuggestion.Action.DowngradePriceByChangingTier( + description = description, + buttonTitle = buttonTitle, + ) } FlowTerminationSurveyRedirectAction.CHANGE_TIER_MISSING_COVERAGE_AND_TERMS -> { diff --git a/app/feature/feature-terminate-insurance/src/test/kotlin/com/hedvig/android/feature/terminateinsurance/data/TerminateInsuranceRepositoryImplTest.kt b/app/feature/feature-terminate-insurance/src/test/kotlin/com/hedvig/android/feature/terminateinsurance/data/TerminateInsuranceRepositoryImplTest.kt index 768db4da38..5b7a3ee5d5 100644 --- a/app/feature/feature-terminate-insurance/src/test/kotlin/com/hedvig/android/feature/terminateinsurance/data/TerminateInsuranceRepositoryImplTest.kt +++ b/app/feature/feature-terminate-insurance/src/test/kotlin/com/hedvig/android/feature/terminateinsurance/data/TerminateInsuranceRepositoryImplTest.kt @@ -134,56 +134,10 @@ class TerminateInsuranceRepositoryImplTest { } @Test - fun `when response is ok but FF is off options with tier-related subOptions should be mapped without subOptions but with required feedback`() = + fun `when response is ok, options with tier-related subOptions should have subOptions and no required feedback`() = runTest { val featureManager = FakeFeatureManager2( fixedMap = mapOf( - Feature.TIER to false, - Feature.TRAVEL_ADDON to false, - ), - ) - - val repo = TerminateInsuranceRepositoryImpl( - apolloClient = apolloClientWithGoodResponse, - featureManager = featureManager, - terminationFlowContextStorage = TerminationFlowContextStorage(testDataStore), - ) - val result = repo.startTerminationFlow(InsuranceId(testId)) - - assertk.assertThat(result) - .isRight() - .isInstanceOf(TerminateInsuranceStep.Survey::class) - .prop(TerminateInsuranceStep.Survey::options) - .transform { list -> - list.none { option -> - option.subOptions.any { subOption -> - subOption.suggestion is SurveyOptionSuggestion.Action.DowngradePriceByChangingTier || - subOption.suggestion is SurveyOptionSuggestion.Action.UpgradeCoverageByChangingTier - } - } - } - .isTrue() - - assertk.assertThat(result) - .isRight() - .isInstanceOf(TerminateInsuranceStep.Survey::class) - .prop(TerminateInsuranceStep.Survey::options) - .transform { list -> - list.filter { option -> - option.id == "001" - }.all { - it.feedBackRequired && it.subOptions.isEmpty() - } - } - .isTrue() - } - - @Test - fun `when response is ok and FF is on options with tier-related subOptions should have subOptions and no required feedback`() = - runTest { - val featureManager = FakeFeatureManager2( - fixedMap = mapOf( - Feature.TIER to true, Feature.TRAVEL_ADDON to false, ), ) @@ -224,42 +178,10 @@ class TerminateInsuranceRepositoryImplTest { } @Test - fun `when response is ok but FF is off options with tier actions should have their action mapped to UnknownAction and have required feedback`() = - runTest { - val featureManager = FakeFeatureManager2( - fixedMap = mapOf( - Feature.TIER to false, - Feature.TRAVEL_ADDON to false, - ), - ) - - val repo = TerminateInsuranceRepositoryImpl( - apolloClient = apolloClientWithGoodResponse, - featureManager = featureManager, - terminationFlowContextStorage = TerminationFlowContextStorage(testDataStore), - ) - val result = repo.startTerminationFlow(InsuranceId(testId)) - - assertk.assertThat(result) - .isRight() - .isInstanceOf(TerminateInsuranceStep.Survey::class) - .prop(TerminateInsuranceStep.Survey::options) - .transform { list -> - list.filter { option -> - option.id == "0013" - }.all { - it.feedBackRequired && it.suggestion is SurveyOptionSuggestion.Action.UnknownAction - } - } - .isTrue() - } - - @Test - fun `when response is ok and FF is on options with tier actions should have corresponding action and have no feedback`() = + fun `when response is ok, options with tier actions should have corresponding action and have no feedback`() = runTest { val featureManager = FakeFeatureManager2( fixedMap = mapOf( - Feature.TIER to true, Feature.TRAVEL_ADDON to false, ), ) diff --git a/app/featureflags/feature-flags-public/src/main/kotlin/com/hedvig/android/featureflags/flags/Feature.kt b/app/featureflags/feature-flags-public/src/main/kotlin/com/hedvig/android/featureflags/flags/Feature.kt index 84d76ec0e9..a1168b9ff2 100644 --- a/app/featureflags/feature-flags-public/src/main/kotlin/com/hedvig/android/featureflags/flags/Feature.kt +++ b/app/featureflags/feature-flags-public/src/main/kotlin/com/hedvig/android/featureflags/flags/Feature.kt @@ -16,6 +16,5 @@ enum class Feature( ), EDIT_COINSURED("Let member edit co insured"), HELP_CENTER("Enable the help center screens"), - TIER("Let members change tier"), TRAVEL_ADDON("Let members purchase addons"), } diff --git a/app/featureflags/feature-flags-public/src/main/kotlin/com/hedvig/android/featureflags/flags/UnleashFeatureFlagProvider.kt b/app/featureflags/feature-flags-public/src/main/kotlin/com/hedvig/android/featureflags/flags/UnleashFeatureFlagProvider.kt index 4d8aa8c801..99260d45ae 100644 --- a/app/featureflags/feature-flags-public/src/main/kotlin/com/hedvig/android/featureflags/flags/UnleashFeatureFlagProvider.kt +++ b/app/featureflags/feature-flags-public/src/main/kotlin/com/hedvig/android/featureflags/flags/UnleashFeatureFlagProvider.kt @@ -20,7 +20,6 @@ internal class UnleashFeatureFlagProvider( Feature.UPDATE_NECESSARY -> hedvigUnleashClient.client.isEnabled("update_necessary", false) Feature.EDIT_COINSURED -> hedvigUnleashClient.client.isEnabled("edit_coinsured", false) Feature.HELP_CENTER -> hedvigUnleashClient.client.isEnabled("help_center", true) - Feature.TIER -> hedvigUnleashClient.client.isEnabled("enable_tiers", false) Feature.TRAVEL_ADDON -> hedvigUnleashClient.client.isEnabled("enable_addons", false) } }.distinctUntilChanged() diff --git a/app/shared/tier-comparison/src/main/kotlin/com/hedvig/android/shared/tier/comparison/data/GetCoverageComparisonUseCase.kt b/app/shared/tier-comparison/src/main/kotlin/com/hedvig/android/shared/tier/comparison/data/GetCoverageComparisonUseCase.kt index 6fd93576a4..981aaa5011 100644 --- a/app/shared/tier-comparison/src/main/kotlin/com/hedvig/android/shared/tier/comparison/data/GetCoverageComparisonUseCase.kt +++ b/app/shared/tier-comparison/src/main/kotlin/com/hedvig/android/shared/tier/comparison/data/GetCoverageComparisonUseCase.kt @@ -5,11 +5,8 @@ import arrow.core.raise.either import com.apollographql.apollo.ApolloClient import com.hedvig.android.apollo.safeExecute import com.hedvig.android.core.common.ErrorMessage -import com.hedvig.android.featureflags.FeatureManager -import com.hedvig.android.featureflags.flags.Feature.TIER import com.hedvig.android.logger.LogPriority.ERROR import com.hedvig.android.logger.logcat -import kotlinx.coroutines.flow.first import octopus.CompareCoverageQuery interface GetCoverageComparisonUseCase { @@ -18,18 +15,12 @@ interface GetCoverageComparisonUseCase { internal class GetCoverageComparisonUseCaseImpl( private val apolloClient: ApolloClient, - private val featureManager: FeatureManager, ) : GetCoverageComparisonUseCase { override suspend fun invoke(termsVersionIds: List): Either { // val mockIds = listOf("SE_DOG_BASIC-20230330-HEDVIG-null", // "SE_DOG_STANDARD-20230330-HEDVIG-null",) return either { - val isTierEnabled = featureManager.isFeatureEnabled(TIER).first() - if (!isTierEnabled) { - logcat(ERROR) { "Tried to ask for coverage comparison when feature flag is disabled" } - raise(ErrorMessage("Tried to ask for coverage comparison when feature flag is disabled")) - } val result = apolloClient.query(CompareCoverageQuery(termsVersionIds)) .safeExecute() .mapLeft { @@ -112,7 +103,8 @@ internal val mockComparisonData = ComparisonData( rows = listOf( ComparisonRow( title = "Veterinary care", - description = "We ensure that you receive compensation for the examination, care and treatment your pet needs if it gets ill or injured in the event accident.", + description = "We ensure that you receive compensation for the examination, care and treatment your pet needs " + + "if it gets ill or injured in the event accident.", numbers = "Standard: 40000 kr\nMax: 80000 kr", cells = listOf( ComparisonCell("30 000 kr", true), @@ -123,7 +115,8 @@ internal val mockComparisonData = ComparisonData( ), ComparisonRow( title = "Advanced diagnostics", - description = "If your pet needs diagnostic examination prescribed by a veterinarian for further care, we compensate costs that have been approved in advance by Hedvig.", + description = "If your pet needs diagnostic examination prescribed by a veterinarian for further care, we " + + "compensate costs that have been approved in advance by Hedvig.", numbers = "Standard: 40000 kr\nMax: 80000 kr", cells = listOf( ComparisonCell(null, false), @@ -134,7 +127,8 @@ internal val mockComparisonData = ComparisonData( ), ComparisonRow( title = "Care of pet at home", - description = "Compensation for loss of income if you need to stay home from work to take care of your sick or injured pet.", + description = "Compensation for loss of income if you need to stay home from work to take care of your sick " + + "or injured pet.", numbers = "Standard: 40000 kr\nMax: 80000 kr", cells = listOf( ComparisonCell(null, false), @@ -145,7 +139,8 @@ internal val mockComparisonData = ComparisonData( ), ComparisonRow( title = "Life insurance", - description = "If your pet were to die as a result of illness or injury. Or if your pet must be euthanized according to a veterinarian. You also get compensation if your pet is stolen or lost.", + description = "If your pet were to die as a result of illness or injury. Or if your pet must be euthanized " + + "according to a veterinarian. You also get compensation if your pet is stolen or lost.", numbers = "Standard: 40000 kr\nMax: 80000 kr", cells = listOf( ComparisonCell(null, false), @@ -156,7 +151,8 @@ internal val mockComparisonData = ComparisonData( ), ComparisonRow( title = "Veterinary care", - description = "We ensure that you receive compensation for the examination, care and treatment your pet needs if it gets ill or injured in the event accident.", + description = "We ensure that you receive compensation for the examination, care and treatment your pet needs " + + "if it gets ill or injured in the event accident.", numbers = "Standard: 40000 kr\nMax: 80000 kr", cells = listOf( ComparisonCell("30 000 kr", true), @@ -167,7 +163,8 @@ internal val mockComparisonData = ComparisonData( ), ComparisonRow( title = "Advanced diagnostics", - description = "If your pet needs diagnostic examination prescribed by a veterinarian for further care, we compensate costs that have been approved in advance by Hedvig.", + description = "If your pet needs diagnostic examination prescribed by a veterinarian for further care, we " + + "compensate costs that have been approved in advance by Hedvig.", numbers = "Standard: 40000 kr\nMax: 80000 kr", cells = listOf( ComparisonCell(null, false), @@ -178,7 +175,8 @@ internal val mockComparisonData = ComparisonData( ), ComparisonRow( title = "Care of pet at home", - description = "Compensation for loss of income if you need to stay home from work to take care of your sick or injured pet.", + description = "Compensation for loss of income if you need to stay home from work to take care of your sick or " + + "injured pet.", numbers = "Standard: 40000 kr\nMax: 80000 kr", cells = listOf( ComparisonCell(null, false), @@ -189,7 +187,8 @@ internal val mockComparisonData = ComparisonData( ), ComparisonRow( title = "Life insurance", - description = "If your pet were to die as a result of illness or injury. Or if your pet must be euthanized according to a veterinarian. You also get compensation if your pet is stolen or lost.", + description = "If your pet were to die as a result of illness or injury. Or if your pet must be euthanized " + + "according to a veterinarian. You also get compensation if your pet is stolen or lost.", numbers = "Standard: 40000 kr\nMax: 80000 kr", cells = listOf( ComparisonCell(null, false), diff --git a/app/shared/tier-comparison/src/main/kotlin/com/hedvig/android/shared/tier/comparison/di/ComparisonModule.kt b/app/shared/tier-comparison/src/main/kotlin/com/hedvig/android/shared/tier/comparison/di/ComparisonModule.kt index 7d319c6f86..6c6d855f60 100644 --- a/app/shared/tier-comparison/src/main/kotlin/com/hedvig/android/shared/tier/comparison/di/ComparisonModule.kt +++ b/app/shared/tier-comparison/src/main/kotlin/com/hedvig/android/shared/tier/comparison/di/ComparisonModule.kt @@ -1,7 +1,6 @@ package com.hedvig.android.shared.tier.comparison.di import com.apollographql.apollo.ApolloClient -import com.hedvig.android.featureflags.FeatureManager import com.hedvig.android.shared.tier.comparison.data.GetCoverageComparisonUseCase import com.hedvig.android.shared.tier.comparison.data.GetCoverageComparisonUseCaseImpl import com.hedvig.android.shared.tier.comparison.navigation.ComparisonParameters @@ -19,7 +18,6 @@ val comparisonModule = module { single { GetCoverageComparisonUseCaseImpl( apolloClient = get(), - featureManager = get(), ) } }