Skip to content
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

Merged
merged 5 commits into from
Jan 9, 2025
Merged

Conversation

toluo-stripe
Copy link
Contributor

@toluo-stripe toluo-stripe commented Jan 7, 2025

Summary

Abstract confirmation logic used for link screens with LinkConfirmationHandler. It will be used in

  • WalletViewModel
  • 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

  • Added tests
  • Modified tests
  • Manually verified

Changelog

paymentDetails: ConsumerPaymentDetails.PaymentDetails,
linkAccount: LinkAccount
): ConfirmationHandler.Args {
configuration.shippingDetails
Copy link

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.

@toluo-stripe toluo-stripe force-pushed the tolu/link/confirmation_manager branch from 7a31caf to 60d6884 Compare January 7, 2025 16:58
}

@Test
fun `null confirmation yields canceled result`() = runTest(dispatcher) {
Copy link

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.

Copy link
Contributor

github-actions bot commented Jan 7, 2025

Diffuse output:

OLD: identity-example-release-base.apk (signature: V1, V2)
NEW: identity-example-release-pr.apk (signature: V1, V2)

          │          compressed          │         uncompressed         
          ├───────────┬───────────┬──────┼───────────┬───────────┬──────
 APK      │ old       │ new       │ diff │ old       │ new       │ diff 
──────────┼───────────┼───────────┼──────┼───────────┼───────────┼──────
      dex │     2 MiB │     2 MiB │  0 B │   4.1 MiB │   4.1 MiB │  0 B 
     arsc │     1 MiB │     1 MiB │  0 B │     1 MiB │     1 MiB │  0 B 
 manifest │   2.3 KiB │   2.3 KiB │  0 B │     8 KiB │     8 KiB │  0 B 
      res │ 301.8 KiB │ 301.8 KiB │  0 B │ 455.5 KiB │ 455.5 KiB │  0 B 
   native │   6.2 MiB │   6.2 MiB │  0 B │  15.8 MiB │  15.8 MiB │  0 B 
    asset │   7.2 KiB │   7.2 KiB │  0 B │   6.9 KiB │   6.9 KiB │  0 B 
    other │  90.2 KiB │  90.3 KiB │ +7 B │ 170.3 KiB │ 170.3 KiB │  0 B 
──────────┼───────────┼───────────┼──────┼───────────┼───────────┼──────
    total │   9.6 MiB │   9.6 MiB │ +7 B │  21.5 MiB │  21.5 MiB │  0 B 

 DEX     │ old   │ new   │ diff      
─────────┼───────┼───────┼───────────
   files │     1 │     1 │ 0         
 strings │ 19971 │ 19971 │ 0 (+0 -0) 
   types │  6191 │  6191 │ 0 (+0 -0) 
 classes │  4982 │  4982 │ 0 (+0 -0) 
 methods │ 29771 │ 29771 │ 0 (+0 -0) 
  fields │ 17541 │ 17541 │ 0 (+0 -0) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  164 │  164 │  0   
 entries │ 3622 │ 3622 │  0
APK
   compressed    │   uncompressed   │                                           
──────────┬──────┼───────────┬──────┤                                           
 size     │ diff │ size      │ diff │ path                                      
──────────┼──────┼───────────┼──────┼───────────────────────────────────────────
 28.5 KiB │ +4 B │  62.9 KiB │  0 B │ ∆ META-INF/CERT.SF                        
 25.3 KiB │ +3 B │  62.8 KiB │  0 B │ ∆ META-INF/MANIFEST.MF                    
    272 B │ +1 B │     120 B │  0 B │ ∆ META-INF/version-control-info.textproto 
  1.2 KiB │ -1 B │   1.2 KiB │  0 B │ ∆ META-INF/CERT.RSA                       
──────────┼──────┼───────────┼──────┼───────────────────────────────────────────
 55.2 KiB │ +7 B │ 127.1 KiB │  0 B │ (total)

@toluo-stripe toluo-stripe force-pushed the tolu/link/confirmation_manager branch from 60d6884 to 092a362 Compare January 7, 2025 17:03
@toluo-stripe toluo-stripe marked this pull request as ready for review January 7, 2025 17:10
@toluo-stripe toluo-stripe requested review from a team as code owners January 7, 2025 17:10
@toluo-stripe toluo-stripe force-pushed the tolu/link/confirmation_manager branch from 049f1ca to 20e039d Compare January 7, 2025 22:08
val args = confirmationArgs(paymentDetails, linkAccount)
confirmationHandler.start(args)
val result = confirmationHandler.awaitResult()
return transformResult(result)
Copy link

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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Collaborator

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(
Copy link
Collaborator

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

Copy link
Contributor Author

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

@toluo-stripe toluo-stripe merged commit 1b50c6d into master Jan 9, 2025
13 checks passed
@toluo-stripe toluo-stripe deleted the tolu/link/confirmation_manager branch January 9, 2025 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants