Skip to content

Commit

Permalink
MBL-1991: Pledge Summary | Only show PLOT blurb in manage pledge whil…
Browse files Browse the repository at this point in the history
…e project is live (#2200)

* manage pledge

* test

* linter

---------

Co-authored-by: Leigh Douglas <[email protected]>
  • Loading branch information
leighdouglas and Leigh Douglas authored Jan 15, 2025
1 parent 4eb8989 commit d9873a7
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,14 @@ interface BackingFragmentViewModel {
Backing.STATUS_PLEDGED -> {
if (environment.featureFlagClient()
?.getBoolean(FlagKey.ANDROID_PLEDGE_OVER_TIME) == true && !backing.paymentIncrements()
.isNullOrEmpty()
.isNullOrEmpty() && project.isLive
) {
R.string.You_have_selected_pledge_over_time
} else if (environment.featureFlagClient()
?.getBoolean(FlagKey.ANDROID_PLEDGE_OVER_TIME) == true && !backing.paymentIncrements()
.isNullOrEmpty() && !project.isLive
) {
R.string.We_collected_your_pledge_for_this_project
} else {
R.string.If_your_project_reaches_its_funding_goal_the_backer_will_be_charged_total_on_project_deadline
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ class BackingFragmentViewModelTest : KSRobolectricTestCase() {
}

@Test
fun testPledgeStatusData_whenPlotIsAllowed() {
fun testPledgeStatusData_whenPlotIsAllowedAndProjectLive() {
val mockFeatureFlagClient = object : MockFeatureFlagClient() {
override fun getBoolean(FlagKey: FlagKey): Boolean {
return true
Expand All @@ -834,6 +834,7 @@ class BackingFragmentViewModelTest : KSRobolectricTestCase() {
val backedProject = ProjectFactory.backedProjectWithPlotSelected()
.toBuilder()
.deadline(deadline)
.state(Project.STATE_LIVE)
.build()

val environment = environment()
Expand Down Expand Up @@ -864,6 +865,51 @@ class BackingFragmentViewModelTest : KSRobolectricTestCase() {
)
}

@Test
fun testPledgeStatusData_whenPlotIsAllowedAndProjectEnded() {
val mockFeatureFlagClient = object : MockFeatureFlagClient() {
override fun getBoolean(FlagKey: FlagKey): Boolean {
return true
}
}

val backing =
backingWithPaymentIncrements(PaymentIncrementFactory.samplePaymentIncrements())
val deadline = DateTime.parse("2019-11-11T17:10:04+00:00")
val backedProject = ProjectFactory.backedProjectWithPlotSelected()
.toBuilder()
.deadline(deadline)
.state(Project.STATE_SUCCESSFUL)
.build()

val environment = environment()
.toBuilder()
.featureFlagClient(mockFeatureFlagClient)
.apolloClientV2(mockApolloClientForBacking(backing))
.currentUserV2(MockCurrentUserV2(UserFactory.user()))
.build()
setUpEnvironment(environment)

val config = ConfigFactory.configForUSUser()
val currentConfig = MockCurrentConfigV2()
currentConfig.config(config)
this.vm.inputs.configureWith(ProjectDataFactory.project(backedProject))

this.pledgeStatusData.assertValue(
PledgeStatusData(
R.string.We_collected_your_pledge_for_this_project,
expectedCurrency(environment, backedProject, 20.0),
DateTimeUtils.longDate(deadline),
plotData = PlotData(
plotAmount = backing.paymentIncrements()
?.first()?.paymentIncrementAmount?.formattedAmount(),
plotFirstScheduleCollection = backing.paymentIncrements()
?.first()?.scheduledCollection?.let { DateTimeUtils.longDate(it) },
),
)
)
}

@Test
fun testPledgeStatusData_whenBackingIsPreAuth() {
val backing = backingWithStatus(Backing.STATUS_PREAUTH)
Expand Down

0 comments on commit d9873a7

Please sign in to comment.