diff --git a/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeAttempt.kt b/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeAttempt.kt new file mode 100644 index 0000000000..918e35b314 --- /dev/null +++ b/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeAttempt.kt @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2026 Proton Technologies AG + * This file is part of Proton Technologies AG and Proton Mail. + * + * Proton Mail is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Proton Mail is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Proton Mail. If not, see . + */ + +package ch.protonmail.android.mailtelemetry.domain.usecase + +import ch.protonmail.android.mailtelemetry.domain.model.GeneralDimensions +import ch.protonmail.android.mailtelemetry.domain.model.PlanSpecificDimensions +import ch.protonmail.android.mailtelemetry.domain.repository.UpsellingTelemetryRepository +import me.proton.core.domain.entity.UserId +import javax.inject.Inject + +class RecordUpgradeAttempt @Inject constructor( + private val upsellingTelemetryRepository: UpsellingTelemetryRepository +) { + + suspend operator fun invoke( + userId: UserId, + generalDimensions: GeneralDimensions, + planSpecificDimensions: PlanSpecificDimensions + ) = upsellingTelemetryRepository.recordUpgradeAttempt( + userId = userId, + general = generalDimensions, + planSpecific = planSpecificDimensions + ) +} diff --git a/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeCancelledByUser.kt b/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeCancelledByUser.kt new file mode 100644 index 0000000000..f7fff89f31 --- /dev/null +++ b/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeCancelledByUser.kt @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2026 Proton Technologies AG + * This file is part of Proton Technologies AG and Proton Mail. + * + * Proton Mail is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Proton Mail is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Proton Mail. If not, see . + */ + +package ch.protonmail.android.mailtelemetry.domain.usecase + +import ch.protonmail.android.mailtelemetry.domain.model.GeneralDimensions +import ch.protonmail.android.mailtelemetry.domain.model.PlanSpecificDimensions +import ch.protonmail.android.mailtelemetry.domain.repository.UpsellingTelemetryRepository +import me.proton.core.domain.entity.UserId +import javax.inject.Inject + +class RecordUpgradeCancelledByUser @Inject constructor( + private val upsellingTelemetryRepository: UpsellingTelemetryRepository +) { + + suspend operator fun invoke( + userId: UserId, + generalDimensions: GeneralDimensions, + planSpecificDimensions: PlanSpecificDimensions + ) = upsellingTelemetryRepository.recordUpgradeCancelledByUser( + userId = userId, + general = generalDimensions, + planSpecific = planSpecificDimensions + ) +} diff --git a/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeError.kt b/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeError.kt new file mode 100644 index 0000000000..10260aad45 --- /dev/null +++ b/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeError.kt @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2026 Proton Technologies AG + * This file is part of Proton Technologies AG and Proton Mail. + * + * Proton Mail is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Proton Mail is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Proton Mail. If not, see . + */ + +package ch.protonmail.android.mailtelemetry.domain.usecase + +import ch.protonmail.android.mailtelemetry.domain.model.GeneralDimensions +import ch.protonmail.android.mailtelemetry.domain.model.PlanSpecificDimensions +import ch.protonmail.android.mailtelemetry.domain.repository.UpsellingTelemetryRepository +import me.proton.core.domain.entity.UserId +import javax.inject.Inject + +class RecordUpgradeError @Inject constructor( + private val upsellingTelemetryRepository: UpsellingTelemetryRepository +) { + + suspend operator fun invoke( + userId: UserId, + generalDimensions: GeneralDimensions, + planSpecificDimensions: PlanSpecificDimensions + ) = upsellingTelemetryRepository.recordUpgradeError( + userId = userId, + general = generalDimensions, + planSpecific = planSpecificDimensions + ) +} diff --git a/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeSuccess.kt b/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeSuccess.kt new file mode 100644 index 0000000000..2648ff3119 --- /dev/null +++ b/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeSuccess.kt @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2026 Proton Technologies AG + * This file is part of Proton Technologies AG and Proton Mail. + * + * Proton Mail is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Proton Mail is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Proton Mail. If not, see . + */ + +package ch.protonmail.android.mailtelemetry.domain.usecase + +import ch.protonmail.android.mailtelemetry.domain.model.GeneralDimensions +import ch.protonmail.android.mailtelemetry.domain.model.PlanSpecificDimensions +import ch.protonmail.android.mailtelemetry.domain.repository.UpsellingTelemetryRepository +import me.proton.core.domain.entity.UserId +import javax.inject.Inject + +class RecordUpgradeSuccess @Inject constructor( + private val upsellingTelemetryRepository: UpsellingTelemetryRepository +) { + + suspend operator fun invoke( + userId: UserId, + generalDimensions: GeneralDimensions, + planSpecificDimensions: PlanSpecificDimensions + ) = upsellingTelemetryRepository.recordUpgradeSuccess( + userId = userId, + general = generalDimensions, + planSpecific = planSpecificDimensions + ) +} diff --git a/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpsellButtonTapped.kt b/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpsellButtonTapped.kt new file mode 100644 index 0000000000..35e8d37d76 --- /dev/null +++ b/mail-telemetry/domain/src/main/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpsellButtonTapped.kt @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2026 Proton Technologies AG + * This file is part of Proton Technologies AG and Proton Mail. + * + * Proton Mail is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Proton Mail is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Proton Mail. If not, see . + */ + +package ch.protonmail.android.mailtelemetry.domain.usecase + +import ch.protonmail.android.mailtelemetry.domain.model.GeneralDimensions +import ch.protonmail.android.mailtelemetry.domain.repository.UpsellingTelemetryRepository +import me.proton.core.domain.entity.UserId +import javax.inject.Inject + +class RecordUpsellButtonTapped @Inject constructor( + private val upsellingTelemetryRepository: UpsellingTelemetryRepository +) { + + suspend operator fun invoke(userId: UserId, generalDimensions: GeneralDimensions) = + upsellingTelemetryRepository.recordUpsellButtonTapped( + userId = userId, + general = generalDimensions + ) +} diff --git a/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeAttemptTest.kt b/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeAttemptTest.kt new file mode 100644 index 0000000000..a1baa9b5e4 --- /dev/null +++ b/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeAttemptTest.kt @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2026 Proton Technologies AG + * This file is part of Proton Technologies AG and Proton Mail. + * + * Proton Mail is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Proton Mail is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Proton Mail. If not, see . + */ + +package ch.protonmail.android.mailtelemetry.domain.usecase + +import ch.protonmail.android.mailtelemetry.domain.model.GeneralDimensions +import ch.protonmail.android.mailtelemetry.domain.model.PlanSpecificDimensions +import ch.protonmail.android.mailtelemetry.domain.model.UpsellEntryPoint +import ch.protonmail.android.mailtelemetry.domain.model.UpsellFeatureFlags +import ch.protonmail.android.mailtelemetry.domain.model.UpsellModalVariant +import ch.protonmail.android.mailtelemetry.domain.repository.UpsellingTelemetryRepository +import ch.protonmail.android.testdata.user.UserIdTestData +import io.mockk.coVerify +import io.mockk.mockk +import kotlinx.coroutines.test.runTest +import kotlin.test.Test + +class RecordUpgradeAttemptTest { + + private val upsellingTelemetryRepository = mockk(relaxUnitFun = true) + + private val recordUpgradeAttempt = RecordUpgradeAttempt(upsellingTelemetryRepository) + + @Test + fun `call repository method when use case is invoked`() = runTest { + // When + recordUpgradeAttempt(userId, generalDimensions, planSpecificDimensions) + + // Then + coVerify { + upsellingTelemetryRepository.recordUpgradeAttempt(userId, generalDimensions, planSpecificDimensions) + } + } + + companion object { + + val userId = UserIdTestData.userId + val generalDimensions = GeneralDimensions( + upsellEntryPoint = UpsellEntryPoint.NAVBAR_UPSELL, + planBeforeUpgrade = "Free plan", + modalVariant = UpsellModalVariant.COMPARISON_PLUS, + upsellFeatureFlags = UpsellFeatureFlags( + parentFlagName = "MailAndroidV7UnlimitedPlanPlacementRegions", + childFlagName = "MailAndroidV7UnlimitedPlanPlacementExperiment" + ) + ) + val planSpecificDimensions = PlanSpecificDimensions( + selectedPlan = "Mail Plus", + selectedCycle = "Monthly", + upsellIsPromotional = false + ) + } +} diff --git a/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeCancelledByUserTest.kt b/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeCancelledByUserTest.kt new file mode 100644 index 0000000000..c78a6e98d5 --- /dev/null +++ b/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeCancelledByUserTest.kt @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2026 Proton Technologies AG + * This file is part of Proton Technologies AG and Proton Mail. + * + * Proton Mail is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Proton Mail is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Proton Mail. If not, see . + */ + +package ch.protonmail.android.mailtelemetry.domain.usecase + +import ch.protonmail.android.mailtelemetry.domain.model.GeneralDimensions +import ch.protonmail.android.mailtelemetry.domain.model.PlanSpecificDimensions +import ch.protonmail.android.mailtelemetry.domain.model.UpsellEntryPoint +import ch.protonmail.android.mailtelemetry.domain.model.UpsellFeatureFlags +import ch.protonmail.android.mailtelemetry.domain.model.UpsellModalVariant +import ch.protonmail.android.mailtelemetry.domain.repository.UpsellingTelemetryRepository +import ch.protonmail.android.testdata.user.UserIdTestData +import io.mockk.coVerify +import io.mockk.mockk +import kotlinx.coroutines.test.runTest +import kotlin.test.Test + +class RecordUpgradeCancelledByUserTest { + + private val upsellingTelemetryRepository = mockk(relaxUnitFun = true) + + private val recordUpgradeCancelledByUser = RecordUpgradeCancelledByUser(upsellingTelemetryRepository) + + @Test + fun `call repository method when use case is invoked`() = runTest { + // When + recordUpgradeCancelledByUser(userId, generalDimensions, planSpecificDimensions) + + // Then + coVerify { + upsellingTelemetryRepository.recordUpgradeCancelledByUser(userId, generalDimensions, planSpecificDimensions) + } + } + + companion object { + + val userId = UserIdTestData.userId + val generalDimensions = GeneralDimensions( + upsellEntryPoint = UpsellEntryPoint.NAVBAR_UPSELL, + planBeforeUpgrade = "Free plan", + modalVariant = UpsellModalVariant.COMPARISON_PLUS, + upsellFeatureFlags = UpsellFeatureFlags( + parentFlagName = "MailAndroidV7UnlimitedPlanPlacementRegions", + childFlagName = "MailAndroidV7UnlimitedPlanPlacementExperiment" + ) + ) + val planSpecificDimensions = PlanSpecificDimensions( + selectedPlan = "Mail Plus", + selectedCycle = "Monthly", + upsellIsPromotional = false + ) + } +} diff --git a/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeErrorTest.kt b/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeErrorTest.kt new file mode 100644 index 0000000000..92e843f295 --- /dev/null +++ b/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeErrorTest.kt @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2026 Proton Technologies AG + * This file is part of Proton Technologies AG and Proton Mail. + * + * Proton Mail is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Proton Mail is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Proton Mail. If not, see . + */ + +package ch.protonmail.android.mailtelemetry.domain.usecase + +import ch.protonmail.android.mailtelemetry.domain.model.GeneralDimensions +import ch.protonmail.android.mailtelemetry.domain.model.PlanSpecificDimensions +import ch.protonmail.android.mailtelemetry.domain.model.UpsellEntryPoint +import ch.protonmail.android.mailtelemetry.domain.model.UpsellFeatureFlags +import ch.protonmail.android.mailtelemetry.domain.model.UpsellModalVariant +import ch.protonmail.android.mailtelemetry.domain.repository.UpsellingTelemetryRepository +import ch.protonmail.android.testdata.user.UserIdTestData +import io.mockk.coVerify +import io.mockk.mockk +import kotlinx.coroutines.test.runTest +import kotlin.test.Test + +class RecordUpgradeErrorTest { + + private val upsellingTelemetryRepository = mockk(relaxUnitFun = true) + + private val recordUpgradeError = RecordUpgradeError(upsellingTelemetryRepository) + + @Test + fun `call repository method when use case is invoked`() = runTest { + // When + recordUpgradeError(userId, generalDimensions, planSpecificDimensions) + + // Then + coVerify { + upsellingTelemetryRepository.recordUpgradeError(userId, generalDimensions, planSpecificDimensions) + } + } + + companion object { + + val userId = UserIdTestData.userId + val generalDimensions = GeneralDimensions( + upsellEntryPoint = UpsellEntryPoint.NAVBAR_UPSELL, + planBeforeUpgrade = "Free plan", + modalVariant = UpsellModalVariant.COMPARISON_PLUS, + upsellFeatureFlags = UpsellFeatureFlags( + parentFlagName = "MailAndroidV7UnlimitedPlanPlacementRegions", + childFlagName = "MailAndroidV7UnlimitedPlanPlacementExperiment" + ) + ) + val planSpecificDimensions = PlanSpecificDimensions( + selectedPlan = "Mail Plus", + selectedCycle = "Monthly", + upsellIsPromotional = false + ) + } +} diff --git a/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeSuccessTest.kt b/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeSuccessTest.kt new file mode 100644 index 0000000000..4fe733126f --- /dev/null +++ b/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpgradeSuccessTest.kt @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2026 Proton Technologies AG + * This file is part of Proton Technologies AG and Proton Mail. + * + * Proton Mail is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Proton Mail is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Proton Mail. If not, see . + */ + +package ch.protonmail.android.mailtelemetry.domain.usecase + +import ch.protonmail.android.mailtelemetry.domain.model.GeneralDimensions +import ch.protonmail.android.mailtelemetry.domain.model.PlanSpecificDimensions +import ch.protonmail.android.mailtelemetry.domain.model.UpsellEntryPoint +import ch.protonmail.android.mailtelemetry.domain.model.UpsellFeatureFlags +import ch.protonmail.android.mailtelemetry.domain.model.UpsellModalVariant +import ch.protonmail.android.mailtelemetry.domain.repository.UpsellingTelemetryRepository +import ch.protonmail.android.testdata.user.UserIdTestData +import io.mockk.coVerify +import io.mockk.mockk +import kotlinx.coroutines.test.runTest +import kotlin.test.Test + +class RecordUpgradeSuccessTest { + + private val upsellingTelemetryRepository = mockk(relaxUnitFun = true) + + private val recordUpgradeSuccess = RecordUpgradeSuccess(upsellingTelemetryRepository) + + @Test + fun `call repository method when use case is invoked`() = runTest { + // When + recordUpgradeSuccess(userId, generalDimensions, planSpecificDimensions) + + // Then + coVerify { + upsellingTelemetryRepository.recordUpgradeSuccess(userId, generalDimensions, planSpecificDimensions) + } + } + + companion object { + + val userId = UserIdTestData.userId + val generalDimensions = GeneralDimensions( + upsellEntryPoint = UpsellEntryPoint.NAVBAR_UPSELL, + planBeforeUpgrade = "Free plan", + modalVariant = UpsellModalVariant.COMPARISON_PLUS, + upsellFeatureFlags = UpsellFeatureFlags( + parentFlagName = "MailAndroidV7UnlimitedPlanPlacementRegions", + childFlagName = "MailAndroidV7UnlimitedPlanPlacementExperiment" + ) + ) + val planSpecificDimensions = PlanSpecificDimensions( + selectedPlan = "Mail Plus", + selectedCycle = "Monthly", + upsellIsPromotional = false + ) + } +} diff --git a/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpsellButtonTappedTest.kt b/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpsellButtonTappedTest.kt new file mode 100644 index 0000000000..c16ae67f9e --- /dev/null +++ b/mail-telemetry/domain/src/test/kotlin/ch/protonmail/android/mailtelemetry/domain/usecase/RecordUpsellButtonTappedTest.kt @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2026 Proton Technologies AG + * This file is part of Proton Technologies AG and Proton Mail. + * + * Proton Mail is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Proton Mail is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Proton Mail. If not, see . + */ + +package ch.protonmail.android.mailtelemetry.domain.usecase + +import ch.protonmail.android.mailtelemetry.domain.model.GeneralDimensions +import ch.protonmail.android.mailtelemetry.domain.model.UpsellEntryPoint +import ch.protonmail.android.mailtelemetry.domain.model.UpsellFeatureFlags +import ch.protonmail.android.mailtelemetry.domain.model.UpsellModalVariant +import ch.protonmail.android.mailtelemetry.domain.repository.UpsellingTelemetryRepository +import ch.protonmail.android.testdata.user.UserIdTestData +import io.mockk.coVerify +import io.mockk.mockk +import kotlinx.coroutines.test.runTest +import kotlin.test.Test + +class RecordUpsellButtonTappedTest { + + private val upsellingTelemetryRepository = mockk(relaxUnitFun = true) + + private val recordUpsellButtonTapped = RecordUpsellButtonTapped(upsellingTelemetryRepository) + + @Test + fun `call repository method when use case is invoked`() = runTest { + // When + recordUpsellButtonTapped(userId, generalDimensions) + + // Then + coVerify { + upsellingTelemetryRepository.recordUpsellButtonTapped(userId, generalDimensions) + } + } + + companion object { + + val userId = UserIdTestData.userId + val generalDimensions = GeneralDimensions( + upsellEntryPoint = UpsellEntryPoint.NAVBAR_UPSELL, + planBeforeUpgrade = "Free plan", + modalVariant = UpsellModalVariant.COMPARISON_PLUS, + upsellFeatureFlags = UpsellFeatureFlags( + parentFlagName = "MailAndroidV7UnlimitedPlanPlacementRegions", + childFlagName = "MailAndroidV7UnlimitedPlanPlacementExperiment" + ) + ) + } +}