-
Notifications
You must be signed in to change notification settings - Fork 664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Link default card change ui states #10108
Conversation
Diffuse output:
APK
|
@@ -96,30 +96,34 @@ internal class WalletViewModel @Inject constructor( | |||
} | |||
} | |||
|
|||
private fun loadPaymentDetails(selectedItemId: String? = null) { | |||
private fun loadPaymentDetails() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the updated function is only used in the init block, should we move
_uiState.update {
it.setProcessing()
}
out of the function instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loadPaymentDetails
is only used in the init block, so this is fine. The other calls to load use loadPaymentDetailsHelper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to James' question here. I think we could move the uiState into the init block.
Then we wouldn't need this function which is only intended to be called by the init block. We could rename loadPaymentDetailsHelper to loadPaymentDetails and call it from anywhere.
My concern with the current approach is that it's not easy to tell why you would want to call loadPaymentDetails vs. loadPaymentDetailsHelper, which could lead to confusion/bugs in the future
dispatcher.scheduler.advanceTimeBy(1.1.seconds) | ||
|
||
onWalletPaymentMethodRowLoadingIndicator().assertDoesNotExist() | ||
onWalletPayButton().assertExists() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exist or enabled?
composeTestRule.waitForIdle() | ||
|
||
onWalletPaymentMethodRowLoadingIndicator().assertIsDisplayed() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this introduce flakiness? Should we use waitUntilExists
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we have flakiness after waitForIdle
, then the screen is not behaving as expected. The loader state is changed on the main thread before kicking of any coroutines to update the card
@@ -392,17 +401,21 @@ class WalletViewModelTest { | |||
|
|||
viewModel.onSetDefaultClicked(card1) | |||
|
|||
assertThat(viewModel.uiState.value.cardBeingUpdated).isEqualTo(card1.id) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to simulate processing, maybe test dispatcher?
I don't know. Not a blocker for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to this question.
If the tests are going to continue to rely on the delay, could we at least use a variable for the delay and then reference that variable in the advanceTimeBy
call? Otherwise I was having a hard time figuring out why 1.1 seconds was being used here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of another way to simulate processing. I'll replace the literals with variable names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is the right fix -- on iOS, it looks like the payment methods are not re-ordered when the default payment method changes. Instead, just the default badge moves. I think that this is a better/smoother UI. Could we do the same thing on Android?
36040cb
to
a17477d
Compare
This what it looks like now cc @amk-stripe Screen.Recording.2025-02-11.at.4.55.46.PM.mov |
@@ -392,17 +401,21 @@ class WalletViewModelTest { | |||
|
|||
viewModel.onSetDefaultClicked(card1) | |||
|
|||
assertThat(viewModel.uiState.value.cardBeingUpdated).isEqualTo(card1.id) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to this question.
If the tests are going to continue to rely on the delay, could we at least use a variable for the delay and then reference that variable in the advanceTimeBy
call? Otherwise I was having a hard time figuring out why 1.1 seconds was being used here
@@ -96,30 +96,34 @@ internal class WalletViewModel @Inject constructor( | |||
} | |||
} | |||
|
|||
private fun loadPaymentDetails(selectedItemId: String? = null) { | |||
private fun loadPaymentDetails() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to James' question here. I think we could move the uiState into the init block.
Then we wouldn't need this function which is only intended to be called by the init block. We could rename loadPaymentDetailsHelper to loadPaymentDetails and call it from anywhere.
My concern with the current approach is that it's not easy to tell why you would want to call loadPaymentDetails vs. loadPaymentDetailsHelper, which could lead to confusion/bugs in the future
1066399
to
13cf9d0
Compare
e375c77
to
fa3db55
Compare
Summary
Motivation
Payment Method Update Loading State
Default Card Radio Button Flicker
Testing
Screenshots
Screen.Recording.2025-02-07.at.5.22.56.PM.mov
Changelog