MBL-2842: Only show 'manage pledge' menu if backing the project (#2435)

This commit is contained in:
Tony Teate
2025-10-21 14:30:26 -04:00
committed by GitHub
parent 69c1fd4405
commit 172be4b653
2 changed files with 30 additions and 6 deletions

View File

@@ -24,12 +24,12 @@ fun createManagePledgeMenuOptions(
val isFeatureFlagOn = ffClient.getBoolean(FlagKey.ANDROID_PLOT_EDIT_PLEDGE) == true
val isPlotProject = project.isPledgeOverTimeAllowed() == true // If the project allows pledge over time, it is considered a plot project.
val isPledgeOverTime = !backing?.paymentIncrements.isNullOrEmpty() // If the backing has payment increments, it is considered a pledge over time.
val showEditPledge = when {
val showEditPledge = project.isBacking() && when {
isFeatureFlagOn && isPlotProject -> project.isLive && !isBackingStatusPreAuth
else -> false
}
val showChooseAnotherReward = when {
val showChooseAnotherReward = project.isBacking() && when {
!isFeatureFlagOn -> !isPledgeOverTime
isFeatureFlagOn -> !isPlotProject
else -> false
@@ -38,9 +38,9 @@ fun createManagePledgeMenuOptions(
return ManagePledgeMenuOptions(
showEditPledge = showEditPledge,
showChooseAnotherReward = showChooseAnotherReward,
showUpdatePayment = project.isLive && !isBackingStatusPreAuth,
showSeeRewards = !project.isLive,
showCancelPledge = project.isLive && !isBackingStatusPreAuth,
showContactCreator = true
showUpdatePayment = project.isBacking() && project.isLive && !isBackingStatusPreAuth,
showSeeRewards = project.isBacking() && !project.isLive,
showCancelPledge = project.isBacking() && project.isLive && !isBackingStatusPreAuth,
showContactCreator = project.isBacking()
)
}

View File

@@ -2445,6 +2445,8 @@ class ProjectPageViewModelTest : KSRobolectricTestCase() {
assertTrue(callbackInvoked.get())
}
/* TODO: 2025-10-21 Refactor the tests using a mocked Activity to use the ViewModel directly */
@Test
fun `manage pledge menu is inflated when project is backed`() {
val project = ProjectFactory.backedProject()
@@ -2578,6 +2580,28 @@ class ProjectPageViewModelTest : KSRobolectricTestCase() {
assertFalse(options.showChooseAnotherReward)
}
@Test
fun `manage pledge options are hidden when project is not backed`() {
val project = ProjectFactory.project()
val mockFeatureFlagClient = object : MockFeatureFlagClient() {
override fun getBoolean(flagKey: FlagKey): Boolean {
return when (flagKey) {
FlagKey.ANDROID_PLOT_EDIT_PLEDGE -> true
else -> false
}
}
}
val options = createManagePledgeMenuOptions(project, mockFeatureFlagClient)
assertFalse(options.showEditPledge)
assertFalse(options.showChooseAnotherReward)
assertFalse(options.showUpdatePayment)
assertFalse(options.showSeeRewards)
assertFalse(options.showCancelPledge)
assertFalse(options.showContactCreator)
}
private fun deepLinkIntent(): Intent {
val uri = Uri.parse("https://www.kickstarter.com/projects/1186238668/skull-graphic-tee")
return Intent(Intent.ACTION_VIEW, uri)