@@ -351,6 +351,77 @@ final class ManagePledgeViewControllerTests: TestCase {
351351 controller. tableView. layoutIfNeeded ( )
352352 controller. tableView. reloadData ( )
353353
354+ // Scroll down to top of table view to ensure the fix payment button is on screen.
355+ controller. tableView. selectRow (
356+ at: IndexPath ( item: 0 , section: 0 ) ,
357+ animated: false ,
358+ scrollPosition: . bottom
359+ )
360+
361+ assertSnapshot (
362+ matching: parent. view,
363+ as: . image( perceptualPrecision: 0.98 ) ,
364+ named: " lang_ \( language) _device_ \( device) "
365+ )
366+ }
367+ }
368+ }
369+
370+ // Generally, when a backing is attempted, we expect to know what the payment method was.
371+ // If they somehow have an errored pledge and a missing payment method, we should still show
372+ // the fix pledge button, to give them a chance to fix their pledge.
373+ func testView_ErroredBacking_noPaymentMethod( ) {
374+ let user = User . template
375+ |> User . lens. id .~ 1
376+
377+ let reward = Reward . template
378+ |> Reward . lens. shipping. enabled .~ true
379+ |> Reward . lens. remaining .~ 49
380+ |> Reward . lens. localPickup .~ nil
381+
382+ let addOns = [ Reward . postcards |> Reward . lens. minimum .~ 10 ]
383+
384+ let backing = Backing . template
385+ |> Backing . lens. addOns .~ addOns
386+ |> Backing . lens. amount .~ 22
387+ |> Backing . lens. reward .~ reward
388+ |> Backing . lens. rewardId .~ reward. id
389+ |> Backing . lens. paymentSource .~ nil
390+ |> Backing . lens. status .~ . errored
391+
392+ let project = Project . cosmicSurgery
393+ |> Project . lens. personalization. backing .~ backing
394+
395+ let env = ProjectAndBackingEnvelope ( project: project, backing: backing)
396+
397+ let mockService = MockService (
398+ fetchManagePledgeViewBackingResult: . success( env) ,
399+ fetchProjectResult: . success( project) ,
400+ fetchProjectRewardsResult: . success( [ reward] )
401+ )
402+
403+ orthogonalCombos ( Language . allLanguages, Device . allCases) . forEach { language, device in
404+ withEnvironment ( apiService: mockService, currentUser: user, language: language) {
405+ let controller = ManagePledgeViewController . instantiate ( )
406+ controller. configureWith ( params: ( Param . slug ( " project-slug " ) , Param . id ( 1 ) ) )
407+ let ( parent, _) = traitControllers ( device: device, orientation: . portrait, child: controller)
408+
409+ // Network request completes
410+ self . scheduler. advance ( )
411+
412+ // endRefreshing is delayed by 300ms for animation duration
413+ self . scheduler. advance ( by: . milliseconds( 300 ) )
414+
415+ controller. tableView. layoutIfNeeded ( )
416+ controller. tableView. reloadData ( )
417+
418+ // Scroll down to top of table view to ensure the fix payment button is on screen.
419+ controller. tableView. selectRow (
420+ at: IndexPath ( item: 0 , section: 0 ) ,
421+ animated: false ,
422+ scrollPosition: . bottom
423+ )
424+
354425 assertSnapshot (
355426 matching: parent. view,
356427 as: . image( perceptualPrecision: 0.98 ) ,
0 commit comments