mirror of
https://github.com/ProtonMail/android-mail.git
synced 2026-06-14 09:54:47 +00:00
Create use cases to track upselling telemetry events
ET-5952
(cherry picked from commit 05c2f0e8cd)
This commit is contained in:
+40
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
+40
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
+40
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
+40
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
+35
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
+68
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<UpsellingTelemetryRepository>(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
|
||||
)
|
||||
}
|
||||
}
|
||||
+68
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<UpsellingTelemetryRepository>(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
|
||||
)
|
||||
}
|
||||
}
|
||||
+68
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<UpsellingTelemetryRepository>(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
|
||||
)
|
||||
}
|
||||
}
|
||||
+68
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<UpsellingTelemetryRepository>(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
|
||||
)
|
||||
}
|
||||
}
|
||||
+62
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<UpsellingTelemetryRepository>(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"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user