-
Notifications
You must be signed in to change notification settings - Fork 662
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
Link Confirmation Handler #9865
Conversation
paymentDetails: ConsumerPaymentDetails.PaymentDetails, | ||
linkAccount: LinkAccount | ||
): ConfirmationHandler.Args { | ||
configuration.shippingDetails |
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.
Line 59 appears to be a dangling statement that accesses configuration.shippingDetails
without using the value. This line can be safely removed since it has no effect on the program execution.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
7a31caf
to
60d6884
Compare
} | ||
|
||
@Test | ||
fun `null confirmation yields canceled result`() = runTest(dispatcher) { |
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.
The test name doesn't match the assertion being verified - the test confirms that a null
confirmation returns Result.Failed
, not Result.Canceled
. Consider renaming to null confirmation yields failed result
to accurately reflect the test behavior.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
Diffuse output:
APK
|
60d6884
to
092a362
Compare
paymentsheet/src/main/java/com/stripe/android/link/LinkConfiguration.kt
Outdated
Show resolved
Hide resolved
049f1ca
to
20e039d
Compare
val args = confirmationArgs(paymentDetails, linkAccount) | ||
confirmationHandler.start(args) | ||
val result = confirmationHandler.awaitResult() | ||
return transformResult(result) |
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.
The return
keyword here will cause the runCatching
block to exit early, bypassing the error handling logic. Consider removing it to ensure errors are properly caught and processed through the getOrElse
block.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
} | ||
|
||
companion object { | ||
val NO_CLIENT_SECRET_FOUND = IllegalStateException("no client secret found") |
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.
val NO_CLIENT_SECRET_FOUND = IllegalStateException("no client secret found") | |
val NO_CLIENT_SECRET_FOUND = IllegalStateException("No client secret found.") |
paymentDetails: ConsumerPaymentDetails.PaymentDetails, | ||
linkAccount: LinkAccount | ||
): Result { | ||
return kotlin.runCatching { |
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.
return kotlin.runCatching { | |
return runCatching { |
Is it possible to write this this way? Or why do we need to specify kotlin
here?
linkAccount = TestFactory.LINK_ACCOUNT | ||
) | ||
|
||
Truth.assertThat(result).isEqualTo(Result.Succeeded) |
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.
can you import assertThat so that you don't need to specify Truth
with every assertThat
statement?
Truth.assertThat(result).isEqualTo(Result.Succeeded) | ||
Truth.assertThat(confirmationHandler.startTurbine.awaitItem()) | ||
.isEqualTo( | ||
ConfirmationHandler.Args( |
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.
do we need to assert equality on this entire object? Are there particular fields we care more about actually testing?
I think we have lots of tests that do assert equality on the whole object, but they are harder to maintain. If we update the type of ConfirmationHandler.Args
we would need to update all the tests that assert on equality of a ConfirmationHandler.Args object, even if the type update is irrelevant to the impacted test
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 trimmed it a little bit, but almost all the fields are important here
Summary
Abstract confirmation logic used for link screens with
LinkConfirmationHandler
. It will be used inWalletViewModel
PaymentMethodViewModel
The abstraction helps us generate the args needed to kick off confirmation and handle errors without duplicating logic across these screens.
Motivation
JIRA
Testing
Changelog