diff --git a/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt b/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt index b547ba613c..a5c6ef16f1 100644 --- a/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt +++ b/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt @@ -71,7 +71,7 @@ class RewardsSelectionViewModel(environment: Environment) : ViewModel() { viewModelScope.launch { val pledgeDataAndReason = pledgeDataAndPledgeReason(currentProjectData, reward) newUserReward = pledgeDataAndReason.first.reward() - + emitCurrentState() analytics.trackSelectRewardCTA(pledgeDataAndReason.first) when (pledgeDataAndReason.second) { @@ -182,6 +182,7 @@ class RewardsSelectionViewModel(environment: Environment) : ViewModel() { initialRewardIndex = indexOfBackedReward, project = currentProjectData, showAlertDialog = showAlertDialog, + selectedReward = newUserReward ) ) } diff --git a/app/src/test/java/com/kickstarter/viewmodels/RewardsSelectionViewModelTest.kt b/app/src/test/java/com/kickstarter/viewmodels/RewardsSelectionViewModelTest.kt index ace33f67a1..e92097602a 100644 --- a/app/src/test/java/com/kickstarter/viewmodels/RewardsSelectionViewModelTest.kt +++ b/app/src/test/java/com/kickstarter/viewmodels/RewardsSelectionViewModelTest.kt @@ -95,7 +95,7 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { viewModel.onUserRewardSelection(testRewards[2]) - assert(uiState.size == 2) + assert(uiState.size == 3) assert(flowState.size == 1) assertEquals( flowState.last(), @@ -141,7 +141,7 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { viewModel.onUserRewardSelection(testRewards[2]) - assert(uiState.size == 2) + assert(uiState.size == 3) assert(flowState.size == 1) assertEquals( flowState.last(), @@ -191,7 +191,7 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { viewModel.onUserRewardSelection(testRewards[2]) - assert(uiState.size == 2) + assert(uiState.size == 3) assert(flowState.size == 1) assertEquals( flowState.last(), @@ -241,7 +241,7 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { viewModel.onUserRewardSelection(testRewards[2]) - assert(uiState.size == 2) + assert(uiState.size == 3) assert(flowState.size == 1) assertEquals( flowState.last(), @@ -299,7 +299,8 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { rewardList = testRewards, initialRewardIndex = 3, project = testProjectData, - showAlertDialog = true + showAlertDialog = true, + selectedReward = testRewards[2] ) ) @@ -346,7 +347,7 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { viewModel.onUserRewardSelection(testRewards[2]) - assert(uiState.size == 2) + assert(uiState.size == 3) assert(flowState.size == 1) assertEquals( flowState.last(), @@ -407,7 +408,8 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { rewardList = testRewards, initialRewardIndex = 3, project = testProjectData, - showAlertDialog = true + showAlertDialog = true, + selectedReward = testRewards[2] ) ) @@ -464,7 +466,8 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { rewardList = testRewards, initialRewardIndex = 3, project = testProjectData, - showAlertDialog = true + showAlertDialog = true, + selectedReward = testRewards[2] ) ) @@ -530,7 +533,8 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { rewardList = testRewards, initialRewardIndex = 3, project = testProjectData, - showAlertDialog = true + showAlertDialog = true, + selectedReward = testRewards[2] ) ) @@ -596,7 +600,8 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { rewardList = testRewards, initialRewardIndex = 3, project = testProjectData, - showAlertDialog = true + showAlertDialog = true, + selectedReward = testRewards[2] ) ) @@ -610,7 +615,8 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { rewardList = testRewards, initialRewardIndex = 3, project = testProjectData, - showAlertDialog = false + showAlertDialog = false, + selectedReward = testRewards[2] ) )