Skip to content

Commit

Permalink
MBL-1343: Incorrect routing after login, before it was going to confi…
Browse files Browse the repository at this point in the history
…rm details screen (#2025)
  • Loading branch information
Arkariang authored Apr 25, 2024
1 parent 7ae91f2 commit 86b7ec3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.launch
import kotlinx.coroutines.rx2.asFlow

Expand Down Expand Up @@ -90,10 +89,9 @@ class CheckoutFlowViewModel(val environment: Environment) : ViewModel() {
viewModelScope.launch {
currentUser.isLoggedIn
.asFlow()
.take(1)
.collect { userLoggedIn ->
// - Show pledge page
if (userLoggedIn) mutableFlowUIState.emit(FlowUIState(currentPage = 3, expanded = true))
// - Show checkout page
if (userLoggedIn) mutableFlowUIState.emit(FlowUIState(currentPage = 4, expanded = true))
// - Trigger LoginFlow callback
else logInCallback()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class CheckoutFlowViewModelTest : KSRobolectricTestCase() {

// - make sure empty FlowUISate has been produced, `onConfirmDetailsContinueClicked` will produce states ONLY if user present
assertEquals(state, listOf(FlowUIState()))
assertNotSame(state, listOf(FlowUIState(currentPage = 4, expanded = true)))
assertNotSame(state, listOf(FlowUIState(currentPage = 3, expanded = true)))
assert(state.size == 1)
}
Expand Down Expand Up @@ -70,7 +71,7 @@ class CheckoutFlowViewModelTest : KSRobolectricTestCase() {
}

// - make sure next page FlowUIState has been generated, not just the initial empty state
assertEquals(state, listOf(FlowUIState(), FlowUIState(currentPage = 3, expanded = true)))
assertEquals(state, listOf(FlowUIState(), FlowUIState(currentPage = 4, expanded = true)))
assert(state.size == 2)
}
}

0 comments on commit 86b7ec3

Please sign in to comment.