Updated on 2026-08-14
This commit is contained in:
parent
5c293e71ec
commit
6caeea3576
22 changed files with 243 additions and 135 deletions
|
|
@ -1,10 +1,8 @@
|
|||
package com.tangem.features.tangempay.cashback.impl.model
|
||||
|
||||
import com.tangem.domain.models.account.TangemPayTariffPlan
|
||||
|
||||
/** Cashback program tier, mapped once from the domain and shared by the rate tile and the details sheet. */
|
||||
internal data class CashbackTier(
|
||||
val planType: TangemPayTariffPlan.Type,
|
||||
val tierId: String,
|
||||
val rate: Int?,
|
||||
val label: String,
|
||||
val scope: String,
|
||||
|
|
|
|||
|
|
@ -12,17 +12,13 @@ internal class TangemPayCashbackInfoTilesConverter(
|
|||
) {
|
||||
|
||||
// TODO([REDACTED_TASK_KEY]): move hardcoded strings to string resources
|
||||
fun convert(
|
||||
tiers: List<CashbackTier>,
|
||||
currentPlanType: TangemPayTariffPlan.Type,
|
||||
currentPlanName: String?,
|
||||
): TangemPayCashbackInfoTilesUM {
|
||||
val rate = tiers.selectTier(currentPlanType)?.rate
|
||||
fun convert(tiers: List<CashbackTier>, currentPlan: TangemPayTariffPlan?): TangemPayCashbackInfoTilesUM {
|
||||
val rate = tiers.selectTier(currentPlan?.tierId)?.rate
|
||||
return TangemPayCashbackInfoTilesUM(
|
||||
rate = TangemPayCashbackInfoTilesUM.Tile(
|
||||
iconRes = R.drawable.ic_percent_24,
|
||||
title = stringReference(if (rate != null) "Cashback $rate%" else "Cashback"),
|
||||
subtitle = currentPlanName?.let { stringReference("With your $it plan") } ?: TextReference.EMPTY,
|
||||
subtitle = currentPlan?.name?.let { stringReference("With your $it plan") } ?: TextReference.EMPTY,
|
||||
onClick = onRateClick,
|
||||
),
|
||||
accruals = TangemPayCashbackInfoTilesUM.Tile(
|
||||
|
|
@ -34,9 +30,7 @@ internal class TangemPayCashbackInfoTilesConverter(
|
|||
)
|
||||
}
|
||||
|
||||
private fun List<CashbackTier>.selectTier(planType: TangemPayTariffPlan.Type): CashbackTier? {
|
||||
return firstOrNull {
|
||||
planType != TangemPayTariffPlan.Type.UNKNOWN && it.planType == planType
|
||||
} ?: firstOrNull()
|
||||
private fun List<CashbackTier>.selectTier(tierId: String?): CashbackTier? {
|
||||
return firstOrNull { it.tierId == tierId } ?: firstOrNull()
|
||||
}
|
||||
}
|
||||
|
|
@ -86,8 +86,7 @@ internal class TangemPayCashbackModel @Inject constructor(
|
|||
infoTiles = promotions?.let {
|
||||
infoTilesConverter.convert(
|
||||
tiers = tiers,
|
||||
currentPlanType = plan?.type ?: TangemPayTariffPlan.Type.UNKNOWN,
|
||||
currentPlanName = plan?.name,
|
||||
currentPlan = plan,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import com.tangem.core.ui.format.bigdecimal.fiat
|
|||
import com.tangem.core.ui.format.bigdecimal.format
|
||||
import com.tangem.core.ui.format.bigdecimal.getJavaCurrencyByCode
|
||||
import com.tangem.core.ui.format.bigdecimal.optionalDecimals
|
||||
import com.tangem.domain.models.account.TangemPayTariffPlan
|
||||
import com.tangem.domain.pay.model.CashbackPromotions
|
||||
import com.tangem.utils.converter.Converter
|
||||
import java.math.BigDecimal
|
||||
|
|
@ -14,7 +13,7 @@ internal class TangemPayCashbackTiersConverter : Converter<CashbackPromotions, L
|
|||
override fun convert(value: CashbackPromotions): List<CashbackTier> {
|
||||
return value.cardTiers.map { tier ->
|
||||
CashbackTier(
|
||||
planType = TangemPayTariffPlan.Type.fromString(tier.tier),
|
||||
tierId = tier.tier,
|
||||
rate = CashbackRates.forTier(tier.tier),
|
||||
label = tier.label,
|
||||
scope = tier.scope,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.tangem.features.tangempay.entity
|
|||
|
||||
import com.tangem.core.ui.components.notifications.NotificationConfig
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.domain.models.account.PaymentAccountStatusValue
|
||||
import com.tangem.domain.models.account.TangemPayCustomerTariffPlan
|
||||
import com.tangem.domain.models.account.TangemPayTariffPlanState
|
||||
|
|
@ -37,7 +37,6 @@ internal class TangemPayDetailsNotificationFactory(
|
|||
},
|
||||
)
|
||||
|
||||
// TODO v_rodionov: #[REDACTED_TASK_KEY] fix hardcoded strings
|
||||
fun createAwaitingDepositConfig(tariffPlan: TangemPayTariffPlanState?): NotificationConfig? {
|
||||
if (!isTiersPlusPlanEnabled) return null
|
||||
if (tariffPlan == null) return null
|
||||
|
|
@ -52,13 +51,15 @@ internal class TangemPayDetailsNotificationFactory(
|
|||
|
||||
val feeText = orderStep.toPlan.formatRecurringFeeOrNull() ?: return null
|
||||
|
||||
val title = "Top-up your account on $feeText"
|
||||
return NotificationConfig(
|
||||
title = stringReference(title),
|
||||
subtitle = stringReference("To pay monthly fee for plan and start use card"),
|
||||
title = resourceReference(R.string.tangempay_card_details_awaiting_deposit_title, wrappedList(feeText)),
|
||||
subtitle = resourceReference(R.string.tangempay_card_details_awaiting_deposit_subtitle),
|
||||
iconResId = R.drawable.ic_alert_circle_24,
|
||||
buttonsState = NotificationConfig.ButtonsState.SecondaryButtonConfig(
|
||||
text = stringReference("Cancel ${orderStep.toPlan.name}, move to ${orderStep.fromPlan.name}"),
|
||||
text = resourceReference(
|
||||
R.string.tangempay_card_details_awaiting_deposit_cancel_button,
|
||||
wrappedList(orderStep.toPlan.name, orderStep.fromPlan.name),
|
||||
),
|
||||
onClick = { intents.onCancelPlusTransition(order.orderId) },
|
||||
),
|
||||
)
|
||||
|
|
@ -81,16 +82,18 @@ internal class TangemPayDetailsNotificationFactory(
|
|||
iconResId = if (isRedesignEnabled) R.drawable.ic_alert_circle_24 else R.drawable.img_attention_20,
|
||||
)
|
||||
|
||||
// TODO v_rodionov: #[REDACTED_TASK_KEY] fix hardcoded strings
|
||||
private fun createTariffSystemDownGradePendingConfig(tariffPlan: TangemPayTariffPlanState): NotificationConfig? {
|
||||
val date = tariffPlan.tariff.formatNextBillingDateOrNull() ?: return null
|
||||
val planName = tariffPlan.tariff.plan.name
|
||||
return NotificationConfig(
|
||||
title = stringReference("Top up your account shortly"),
|
||||
subtitle = stringReference("If it will remain below zero your $planName cards will be closed on $date"),
|
||||
title = resourceReference(R.string.tangempay_card_details_system_downgrade_title),
|
||||
subtitle = resourceReference(
|
||||
R.string.tangempay_card_details_system_downgrade_subtitle,
|
||||
wrappedList(planName, date),
|
||||
),
|
||||
iconResId = R.drawable.ic_alert_circle_24,
|
||||
buttonsState = NotificationConfig.ButtonsState.SecondaryButtonConfig(
|
||||
text = stringReference("Add funds"),
|
||||
text = resourceReference(R.string.tangempay_card_details_add_funds),
|
||||
onClick = intents::onClickAddFunds,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import com.tangem.core.ui.res.generated.icons.Icons
|
|||
import com.tangem.core.ui.res.generated.icons.ic_document_20
|
||||
import com.tangem.domain.models.account.PaymentAccountStatusValue
|
||||
import com.tangem.domain.models.account.TangemPayCustomerTariffPlan
|
||||
import com.tangem.domain.models.account.TangemPayTariffPlan
|
||||
import com.tangem.domain.models.account.TangemPayTariffPlanState
|
||||
import com.tangem.domain.models.pay.TangemPayCard
|
||||
import com.tangem.domain.models.pay.TangemPayCardFrozenState
|
||||
|
|
@ -286,10 +285,7 @@ internal class TangemPayDetailsStateFactory(
|
|||
),
|
||||
)
|
||||
}
|
||||
if (isTiersPlusPlanEnabled &&
|
||||
tariffPlan != null &&
|
||||
tariffPlan.tariff.plan.type != TangemPayTariffPlan.Type.BASIC
|
||||
) {
|
||||
if (isTiersPlusPlanEnabled && tariffPlan != null && !tariffPlan.tariff.plan.isBasicTier) {
|
||||
add(
|
||||
TangemPayDropDownItemUM(
|
||||
title = resourceReference(R.string.tangempay_visa_benefits),
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.tangem.core.decompose.model.ParamsContainer
|
|||
import com.tangem.core.decompose.navigation.Router
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.core.decompose.ui.UiMessageSender
|
||||
import com.tangem.core.ui.utils.DateTimeFormatters
|
||||
import com.tangem.domain.models.account.TangemPayCustomerTariffPlan
|
||||
|
|
@ -50,7 +51,6 @@ internal class TangemPayCurrentPlanModel @Inject constructor(
|
|||
onChangePlanClick = { router.push(TangemPayAccountDetailsInnerRoute.SelectPlan(params.tariffPlan)) },
|
||||
)
|
||||
|
||||
// TODO v_rodionov: #[REDACTED_TASK_KEY] fix hardcoded strings
|
||||
private fun createNotification(customerPlan: TangemPayCustomerTariffPlan): TangemPayCurrentPlanUM.Notification? {
|
||||
val date = customerPlan.formatNextBillingDateOrNull(formatter = DateTimeFormatters.dateMMMd) ?: return null
|
||||
val feeText = customerPlan.plan.formatRecurringFeeOrNull() ?: return null
|
||||
|
|
@ -58,19 +58,25 @@ internal class TangemPayCurrentPlanModel @Inject constructor(
|
|||
TangemPayCustomerTariffPlan.Status.DOWNGRADE_PENDING -> {
|
||||
val targetPlan = customerPlan.pendingPlan ?: return null
|
||||
TangemPayCurrentPlanUM.Notification(
|
||||
text = stringReference(
|
||||
"Your ${customerPlan.plan.name} plan is active till $date, then we will move you to " +
|
||||
"${targetPlan.name}. $feeText won't be charged.",
|
||||
text = resourceReference(
|
||||
R.string.tangempay_current_plan_active_till_notification,
|
||||
wrappedList(customerPlan.plan.name, date, targetPlan.name, feeText),
|
||||
),
|
||||
button = TangemPayCurrentPlanUM.Notification.Button(
|
||||
text = stringReference("Stay on ${customerPlan.plan.name}"),
|
||||
text = resourceReference(
|
||||
R.string.tangempay_current_plan_stay_button,
|
||||
wrappedList(customerPlan.plan.name),
|
||||
),
|
||||
isProcessing = isProcessing,
|
||||
onClick = ::onStayOnPlanClick,
|
||||
),
|
||||
)
|
||||
}
|
||||
TangemPayCustomerTariffPlan.Status.ACTIVE -> TangemPayCurrentPlanUM.Notification(
|
||||
text = stringReference("$feeText monthly fee will be charged on $date"),
|
||||
text = resourceReference(
|
||||
R.string.tangempay_current_plan_fee_charged_notification,
|
||||
wrappedList(feeText, date),
|
||||
),
|
||||
)
|
||||
else -> null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.tangem.core.decompose.navigation.Router
|
|||
import com.tangem.core.decompose.ui.UiMessageSender
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.core.ui.utils.DateTimeFormatters
|
||||
import com.tangem.domain.models.account.TangemPayTariffPlan
|
||||
import com.tangem.domain.models.account.TangemPayTariffPlanTransition
|
||||
|
|
@ -189,28 +190,34 @@ internal class TangemPaySelectPlanModel @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
// TODO v_rodionov: #[REDACTED_TASK_KEY] fix hardcoded strings
|
||||
private fun buildConfirmContent(): TangemPaySelectPlanUM.Content {
|
||||
val transition = allowedTransitions.getOrNull(selectedIndex) ?: return buildSelectContent()
|
||||
val targetProgramme = transition.plan.name
|
||||
val targetPlanName = transition.plan.name
|
||||
val programName = transition.plan.programName
|
||||
return TangemPaySelectPlanUM.Content.Confirm(
|
||||
title = when (transition.type) {
|
||||
TangemPayTariffPlanTransition.Type.UPGRADE -> stringReference(
|
||||
"We will issue Visa $targetProgramme for you",
|
||||
TangemPayTariffPlanTransition.Type.UPGRADE -> resourceReference(
|
||||
R.string.tangempay_select_plan_confirm_upgrade_title,
|
||||
wrappedList(programName),
|
||||
)
|
||||
TangemPayTariffPlanTransition.Type.DOWNGRADE -> {
|
||||
val nextBillingDate = nextBillingDate()
|
||||
if (nextBillingDate != null) {
|
||||
val programName = "UNKNOWN" // TODO v_rodionov: #[REDACTED_TASK_KEY] fix hardcoded strings
|
||||
val planName = params.tariffPlan.plan.name
|
||||
stringReference(
|
||||
"Your $planName plan and $programName cards will be active till $nextBillingDate",
|
||||
resourceReference(
|
||||
R.string.tangempay_select_plan_confirm_downgrade_title,
|
||||
wrappedList(params.tariffPlan.plan.name, programName, nextBillingDate),
|
||||
)
|
||||
} else {
|
||||
stringReference("You are switching to $targetProgramme")
|
||||
resourceReference(
|
||||
R.string.tangempay_select_plan_confirm_switch_title,
|
||||
wrappedList(targetPlanName),
|
||||
)
|
||||
}
|
||||
}
|
||||
else -> stringReference("You are switching to $targetProgramme")
|
||||
else -> resourceReference(
|
||||
R.string.tangempay_select_plan_confirm_switch_title,
|
||||
wrappedList(targetPlanName),
|
||||
)
|
||||
},
|
||||
points = buildConfirmPoints(transition),
|
||||
confirmButtonText = resourceReference(
|
||||
|
|
@ -226,18 +233,27 @@ internal class TangemPaySelectPlanModel @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
// TODO v_rodionov: #[REDACTED_TASK_KEY] fix hardcoded strings
|
||||
private fun buildConfirmPoints(
|
||||
transition: TangemPayTariffPlanTransition,
|
||||
): ImmutableList<TangemPaySelectPlanUM.PointUM> {
|
||||
val programName = "UNKNOWN" // TODO v_rodionov: #[REDACTED_TASK_KEY] fix hardcoded strings
|
||||
val programName = transition.plan.programName
|
||||
return when (transition.type) {
|
||||
TangemPayTariffPlanTransition.Type.UPGRADE -> {
|
||||
val feeText = transition.plan.formatRecurringFeeOrNull()
|
||||
buildList {
|
||||
add("You will get your virtual Visa $programName in minutes")
|
||||
add(
|
||||
resourceReference(
|
||||
R.string.tangempay_select_plan_confirm_point_virtual_card,
|
||||
wrappedList(programName),
|
||||
),
|
||||
)
|
||||
if (feeText != null) {
|
||||
add("$feeText monthly fee will be taken from your account")
|
||||
add(
|
||||
resourceReference(
|
||||
R.string.tangempay_select_plan_confirm_point_monthly_fee,
|
||||
wrappedList(feeText),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -245,18 +261,33 @@ internal class TangemPaySelectPlanModel @Inject constructor(
|
|||
val date = nextBillingDate()
|
||||
buildList {
|
||||
if (date != null) {
|
||||
add("On $date we will move you to ${transition.plan.name} plan")
|
||||
add(
|
||||
resourceReference(
|
||||
R.string.tangempay_select_plan_confirm_point_move_on_date,
|
||||
wrappedList(date, transition.plan.name),
|
||||
),
|
||||
)
|
||||
}
|
||||
add("Your Visa $programName cards will be closed")
|
||||
add(
|
||||
resourceReference(
|
||||
R.string.tangempay_select_plan_confirm_point_cards_closed,
|
||||
wrappedList(programName),
|
||||
),
|
||||
)
|
||||
if (date != null) {
|
||||
add("You can cancel this transition till $date")
|
||||
add(
|
||||
resourceReference(
|
||||
R.string.tangempay_select_plan_confirm_point_cancel_till,
|
||||
wrappedList(date),
|
||||
),
|
||||
)
|
||||
}
|
||||
add("No fee applied")
|
||||
add(resourceReference(R.string.tangempay_select_plan_confirm_point_no_fee))
|
||||
}
|
||||
}
|
||||
else -> listOf("No fee applied")
|
||||
else -> listOf(resourceReference(R.string.tangempay_select_plan_confirm_point_no_fee))
|
||||
}
|
||||
.map { TangemPaySelectPlanUM.PointUM(title = stringReference(it), body = null) }
|
||||
.map { TangemPaySelectPlanUM.PointUM(title = it, body = null) }
|
||||
.toImmutableList()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import com.tangem.core.ui.R
|
|||
import com.tangem.core.ui.components.bottomsheets.message.*
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.core.ui.message.BottomSheetMessage
|
||||
import com.tangem.core.ui.message.DialogMessage
|
||||
import com.tangem.core.ui.message.bottomSheetMessage
|
||||
|
|
@ -149,7 +149,6 @@ internal object TangemPayMessagesFactory {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO v_rodionov: #[REDACTED_TASK_KEY] fix hardcoded strings
|
||||
fun createStayOnPlanMessage(
|
||||
planName: String,
|
||||
targetPlanName: String,
|
||||
|
|
@ -161,15 +160,18 @@ internal object TangemPayMessagesFactory {
|
|||
type = MessageBottomSheetUM.Icon.Type.Informative
|
||||
backgroundType = MessageBottomSheetUM.Icon.BackgroundType.Informative
|
||||
}
|
||||
title = stringReference("Do you want to stay on $planName?")
|
||||
body = stringReference("Your transition on $targetPlanName will be canceled")
|
||||
title = resourceReference(R.string.tangempay_current_plan_stay_sheet_title, wrappedList(planName))
|
||||
body = resourceReference(
|
||||
R.string.tangempay_current_plan_stay_sheet_body,
|
||||
wrappedList(targetPlanName),
|
||||
)
|
||||
}
|
||||
secondaryButton {
|
||||
text = resourceReference(R.string.common_cancel)
|
||||
onClick { closeBs() }
|
||||
}
|
||||
primaryButton {
|
||||
text = stringReference("Stay on $planName")
|
||||
text = resourceReference(R.string.tangempay_current_plan_stay_button, wrappedList(planName))
|
||||
onClick {
|
||||
onStayClick()
|
||||
closeBs()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.tangem.features.tangempay.cashback.impl.model
|
|||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.domain.models.account.TangemPayTariffPlan
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class TangemPayCashbackDetailsConverterTest {
|
||||
|
|
@ -81,7 +80,7 @@ internal class TangemPayCashbackDetailsConverterTest {
|
|||
min: String? = null,
|
||||
cap: String? = null,
|
||||
) = CashbackTier(
|
||||
planType = TangemPayTariffPlan.Type.UNKNOWN,
|
||||
tierId = "basic",
|
||||
rate = rate,
|
||||
label = label,
|
||||
scope = scope,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ internal class TangemPayCashbackInfoTilesConverterTest {
|
|||
@MethodSource("rateSelectionModels")
|
||||
fun `GIVEN plan WHEN convert THEN rate tile shows the tier rate and the plan subtitle`(model: RateSelectionModel) {
|
||||
// Act
|
||||
val result = converter.convert(twoTiers(), model.plan, model.planName)
|
||||
val result = converter.convert(twoTiers(), model.plan)
|
||||
|
||||
// Assert
|
||||
assertThat(result.rate.title).isEqualTo(stringReference(model.expectedTitle))
|
||||
|
|
@ -29,9 +29,9 @@ internal class TangemPayCashbackInfoTilesConverterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN empty tiers and unknown plan WHEN convert THEN rate tile has no percent and empty subtitle`() {
|
||||
fun `GIVEN empty tiers and no plan WHEN convert THEN rate tile has no percent and empty subtitle`() {
|
||||
// Act
|
||||
val result = converter.convert(emptyList(), TangemPayTariffPlan.Type.UNKNOWN, currentPlanName = null)
|
||||
val result = converter.convert(emptyList(), currentPlan = null)
|
||||
|
||||
// Assert
|
||||
assertThat(result.rate.title).isEqualTo(stringReference("Cashback"))
|
||||
|
|
@ -41,7 +41,7 @@ internal class TangemPayCashbackInfoTilesConverterTest {
|
|||
@Test
|
||||
fun `GIVEN any tiers WHEN convert THEN accruals tile is static`() {
|
||||
// Act
|
||||
val result = converter.convert(twoTiers(), TangemPayTariffPlan.Type.BASIC, currentPlanName = "Basic")
|
||||
val result = converter.convert(twoTiers(), plan(tierId = "basic", name = "Basic"))
|
||||
|
||||
// Assert
|
||||
assertThat(result.accruals.title).isEqualTo(stringReference("Accruals"))
|
||||
|
|
@ -50,43 +50,52 @@ internal class TangemPayCashbackInfoTilesConverterTest {
|
|||
|
||||
private fun rateSelectionModels() = listOf(
|
||||
RateSelectionModel(
|
||||
plan = TangemPayTariffPlan.Type.PLUS,
|
||||
planName = "Plus",
|
||||
plan = plan(tierId = "plus", name = "Plus"),
|
||||
expectedTitle = "Cashback 2%",
|
||||
expectedSubtitle = stringReference("With your Plus plan"),
|
||||
),
|
||||
RateSelectionModel(
|
||||
plan = TangemPayTariffPlan.Type.BASIC,
|
||||
planName = "Basic",
|
||||
plan = plan(tierId = "basic", name = "Basic"),
|
||||
expectedTitle = "Cashback 1%",
|
||||
expectedSubtitle = stringReference("With your Basic plan"),
|
||||
),
|
||||
RateSelectionModel(
|
||||
plan = TangemPayTariffPlan.Type.UNKNOWN,
|
||||
planName = null,
|
||||
plan = plan(tierId = "gold", name = "Gold"),
|
||||
expectedTitle = "Cashback 1%",
|
||||
expectedSubtitle = stringReference("With your Gold plan"),
|
||||
),
|
||||
RateSelectionModel(
|
||||
plan = null,
|
||||
expectedTitle = "Cashback 1%",
|
||||
expectedSubtitle = TextReference.EMPTY,
|
||||
),
|
||||
)
|
||||
|
||||
private fun twoTiers() = listOf(
|
||||
tier(TangemPayTariffPlan.Type.BASIC, rate = 1),
|
||||
tier(TangemPayTariffPlan.Type.PLUS, rate = 2),
|
||||
tier(tierId = "basic", rate = 1),
|
||||
tier(tierId = "plus", rate = 2),
|
||||
)
|
||||
|
||||
private fun tier(planType: TangemPayTariffPlan.Type = TangemPayTariffPlan.Type.UNKNOWN, rate: Int? = null) =
|
||||
CashbackTier(
|
||||
planType = planType,
|
||||
rate = rate,
|
||||
label = "label",
|
||||
scope = "scope",
|
||||
minPurchase = null,
|
||||
monthlyCap = null,
|
||||
)
|
||||
private fun tier(tierId: String, rate: Int? = null) = CashbackTier(
|
||||
tierId = tierId,
|
||||
rate = rate,
|
||||
label = "label",
|
||||
scope = "scope",
|
||||
minPurchase = null,
|
||||
monthlyCap = null,
|
||||
)
|
||||
|
||||
private fun plan(tierId: String, name: String) = TangemPayTariffPlan(
|
||||
id = "plan-$tierId",
|
||||
tierId = tierId,
|
||||
isBasicTier = tierId == "basic",
|
||||
name = name,
|
||||
programName = "program",
|
||||
descriptionItems = emptyList(),
|
||||
)
|
||||
|
||||
data class RateSelectionModel(
|
||||
val plan: TangemPayTariffPlan.Type,
|
||||
val planName: String?,
|
||||
val plan: TangemPayTariffPlan?,
|
||||
val expectedTitle: String,
|
||||
val expectedSubtitle: TextReference,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ internal class TangemPayCashbackModelTest {
|
|||
coEvery { cashbackRepository.getCashbackPromotions(any()) } returns promotions().right()
|
||||
coEvery { cashbackRepository.getCashbackAccrualDocs(any()) } returns docs().right()
|
||||
coEvery { onboardingRepository.getCustomerInfo(any()) } returns
|
||||
customerInfo(TangemPayTariffPlan.Type.BASIC).right()
|
||||
customerInfo(tierId = "basic", planName = "Basic").right()
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
|
|
@ -69,7 +69,7 @@ internal class TangemPayCashbackModelTest {
|
|||
fun `GIVEN PLUS plan WHEN model created THEN rate tile shows the Plus tier rate`() {
|
||||
// Arrange
|
||||
coEvery { onboardingRepository.getCustomerInfo(any()) } returns
|
||||
customerInfo(TangemPayTariffPlan.Type.PLUS).right()
|
||||
customerInfo(tierId = "plus", planName = "Plus").right()
|
||||
|
||||
// Act
|
||||
val model = createModel()
|
||||
|
|
@ -162,12 +162,16 @@ internal class TangemPayCashbackModelTest {
|
|||
CashbackDocument(id = "terms", title = "Full terms of cashback program", url = "https://x/terms.pdf"),
|
||||
)
|
||||
|
||||
private fun customerInfo(planType: TangemPayTariffPlan.Type): CustomerInfo {
|
||||
val tariffPlanMock = mockk<TangemPayTariffPlan> {
|
||||
every { type } returns planType
|
||||
every { name } returns planType.name
|
||||
}
|
||||
val customerTariffPlanMock = mockk<TangemPayCustomerTariffPlan> { every { plan } returns tariffPlanMock }
|
||||
private fun customerInfo(tierId: String, planName: String): CustomerInfo {
|
||||
val currentPlan = TangemPayTariffPlan(
|
||||
id = "plan-$tierId",
|
||||
tierId = tierId,
|
||||
isBasicTier = tierId == "basic",
|
||||
name = planName,
|
||||
programName = "program",
|
||||
descriptionItems = emptyList(),
|
||||
)
|
||||
val customerTariffPlanMock = mockk<TangemPayCustomerTariffPlan> { every { plan } returns currentPlan }
|
||||
return mockk { every { tariffPlan } returns customerTariffPlanMock }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package com.tangem.features.tangempay.cashback.impl.model
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.tangem.domain.models.account.TangemPayTariffPlan
|
||||
import com.tangem.domain.pay.model.CashbackPromotions
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
|
|
@ -38,7 +37,7 @@ internal class TangemPayCashbackTiersConverterTest {
|
|||
// Assert
|
||||
assertThat(result).containsExactly(
|
||||
CashbackTier(
|
||||
planType = TangemPayTariffPlan.Type.BASIC,
|
||||
tierId = "basic",
|
||||
rate = 1,
|
||||
label = "Basic cards",
|
||||
scope = "All purchases",
|
||||
|
|
@ -46,7 +45,7 @@ internal class TangemPayCashbackTiersConverterTest {
|
|||
monthlyCap = "$100",
|
||||
),
|
||||
CashbackTier(
|
||||
planType = TangemPayTariffPlan.Type.PLUS,
|
||||
tierId = "plus",
|
||||
rate = 2,
|
||||
label = "Plus cards",
|
||||
scope = "Everywhere",
|
||||
|
|
@ -57,7 +56,7 @@ internal class TangemPayCashbackTiersConverterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN unknown tier WHEN convert THEN rate null and plan type UNKNOWN`() {
|
||||
fun `GIVEN unknown tier WHEN convert THEN rate is null and tier id kept`() {
|
||||
// Arrange
|
||||
val promotions = promotions(tier(id = "gold", label = "Gold", scope = "All", min = null, cap = null))
|
||||
|
||||
|
|
@ -67,7 +66,7 @@ internal class TangemPayCashbackTiersConverterTest {
|
|||
// Assert
|
||||
assertThat(result).containsExactly(
|
||||
CashbackTier(
|
||||
planType = TangemPayTariffPlan.Type.UNKNOWN,
|
||||
tierId = "gold",
|
||||
rate = null,
|
||||
label = "Gold",
|
||||
scope = "All",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue