Updated on 2026-08-14
This commit is contained in:
parent
50332186fa
commit
5f6767abaf
58 changed files with 85 additions and 717 deletions
|
|
@ -1,7 +0,0 @@
|
|||
package com.tangem.features.pushnotifications
|
||||
|
||||
interface PushNotificationsFeatureToggles {
|
||||
|
||||
/** Kill switch for the onboarding "Double Ask" A/B experiment (`twi_1403_onboarding_push_notification_double_ask`). */
|
||||
val isOnboardingPushDoubleAskAbEnabled: Boolean
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package com.tangem.features.pushnotifications.impl
|
||||
|
||||
import com.tangem.core.configtoggle.FeatureToggles
|
||||
import com.tangem.core.configtoggle.feature.FeatureTogglesManager
|
||||
import com.tangem.features.pushnotifications.PushNotificationsFeatureToggles
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class DefaultPushNotificationsFeatureToggles @Inject constructor(
|
||||
private val featureTogglesManager: FeatureTogglesManager,
|
||||
) : PushNotificationsFeatureToggles {
|
||||
|
||||
override val isOnboardingPushDoubleAskAbEnabled: Boolean
|
||||
get() = featureTogglesManager.isFeatureEnabled(
|
||||
FeatureToggles.AND_15596_ONBOARDING_PUSH_NOTIFICATION_DOUBLE_ASK_AB_ENABLED,
|
||||
)
|
||||
}
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
package com.tangem.features.pushnotifications.impl.di
|
||||
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.features.pushnotifications.PushNotificationsFeatureToggles
|
||||
import com.tangem.features.pushnotifications.api.PushNotificationsBottomSheetComponent
|
||||
import com.tangem.features.pushnotifications.api.PushNotificationsComponent
|
||||
import com.tangem.features.pushnotifications.impl.DefaultPushNotificationsBottomSheetComponent
|
||||
import com.tangem.features.pushnotifications.impl.DefaultPushNotificationsComponent
|
||||
import com.tangem.features.pushnotifications.impl.DefaultPushNotificationsFeatureToggles
|
||||
import com.tangem.features.pushnotifications.impl.model.PushNotificationsModel
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
|
|
@ -14,7 +12,6 @@ import dagger.hilt.InstallIn
|
|||
import dagger.hilt.components.SingletonComponent
|
||||
import dagger.multibindings.ClassKey
|
||||
import dagger.multibindings.IntoMap
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
|
|
@ -32,8 +29,4 @@ internal interface PushNotificationsModule {
|
|||
@IntoMap
|
||||
@ClassKey(PushNotificationsModel::class)
|
||||
fun bindModel(model: PushNotificationsModel): Model
|
||||
|
||||
@Binds
|
||||
@Singleton
|
||||
fun bindFeatureToggles(impl: DefaultPushNotificationsFeatureToggles): PushNotificationsFeatureToggles
|
||||
}
|
||||
|
|
@ -1,18 +1,13 @@
|
|||
package com.tangem.features.pushnotifications.impl.domain
|
||||
|
||||
import com.tangem.core.abtests.manager.ABTestsManager
|
||||
import com.tangem.features.pushnotifications.PushNotificationsFeatureToggles
|
||||
import javax.inject.Inject
|
||||
|
||||
class GetPushNotificationsDoubleAskVariantUseCase @Inject constructor(
|
||||
private val pushNotificationsFeatureToggles: PushNotificationsFeatureToggles,
|
||||
private val abTestsManager: ABTestsManager,
|
||||
) {
|
||||
|
||||
suspend operator fun invoke(): DoubleAskVariant {
|
||||
if (!pushNotificationsFeatureToggles.isOnboardingPushDoubleAskAbEnabled) {
|
||||
return DoubleAskVariant.Off
|
||||
}
|
||||
val variant = abTestsManager.getValue(AMPLITUDE_ID, DoubleAskVariant.Off.key)
|
||||
return DoubleAskVariant.fromKey(variant)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,37 +2,22 @@ package com.tangem.features.pushnotifications.impl.domain
|
|||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.tangem.core.abtests.manager.ABTestsManager
|
||||
import com.tangem.features.pushnotifications.PushNotificationsFeatureToggles
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.coVerify
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class GetPushNotificationsDoubleAskVariantUseCaseTest {
|
||||
|
||||
private val featureToggles: PushNotificationsFeatureToggles = mockk()
|
||||
private val abTestsManager: ABTestsManager = mockk()
|
||||
|
||||
private val useCase = GetPushNotificationsDoubleAskVariantUseCase(
|
||||
pushNotificationsFeatureToggles = featureToggles,
|
||||
abTestsManager = abTestsManager,
|
||||
)
|
||||
|
||||
@Test
|
||||
fun `GIVEN toggle disabled WHEN invoke THEN returns Off and AB not queried`() = runTest {
|
||||
every { featureToggles.isOnboardingPushDoubleAskAbEnabled } returns false
|
||||
|
||||
val result = useCase()
|
||||
|
||||
assertThat(result).isEqualTo(DoubleAskVariant.Off)
|
||||
coVerify(exactly = 0) { abTestsManager.getValue(any(), any()) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN toggle enabled AND AB returns treatment WHEN invoke THEN returns On`() = runTest {
|
||||
every { featureToggles.isOnboardingPushDoubleAskAbEnabled } returns true
|
||||
fun `GIVEN AB returns treatment WHEN invoke THEN returns On`() = runTest {
|
||||
coEvery { abTestsManager.getValue(KEY, "control") } returns "treatment"
|
||||
|
||||
val result = useCase()
|
||||
|
|
@ -42,16 +27,14 @@ internal class GetPushNotificationsDoubleAskVariantUseCaseTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN toggle enabled AND AB returns control WHEN invoke THEN returns Off`() = runTest {
|
||||
every { featureToggles.isOnboardingPushDoubleAskAbEnabled } returns true
|
||||
fun `GIVEN AB returns control WHEN invoke THEN returns Off`() = runTest {
|
||||
coEvery { abTestsManager.getValue(KEY, "control") } returns "control"
|
||||
|
||||
assertThat(useCase()).isEqualTo(DoubleAskVariant.Off)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN toggle enabled AND AB returns unknown WHEN invoke THEN returns Off`() = runTest {
|
||||
every { featureToggles.isOnboardingPushDoubleAskAbEnabled } returns true
|
||||
fun `GIVEN AB returns unknown WHEN invoke THEN returns Off`() = runTest {
|
||||
coEvery { abTestsManager.getValue(KEY, "control") } returns "unexpected_value"
|
||||
|
||||
assertThat(useCase()).isEqualTo(DoubleAskVariant.Off)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue