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

Add Completed result to LinkActivityResult #9855

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

toluo-stripe
Copy link
Contributor

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

Summary

Current result set is [completed(paymentMethod), canceled, failed].
New result set is [completed, paymentMethodObtained(paymentMethod), canceled, failed].

This accounts for Link handling the payment confirmation. In this scenario, we don't need to send a payment method as part of the result.

Motivation

JIRA

Testing

  • Added tests
  • Modified tests
  • Manually verified

Copy link
Contributor

github-actions bot commented Jan 4, 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.2 KiB │ -8 B │ 170.3 KiB │ 170.3 KiB │  0 B 
──────────┼───────────┼───────────┼──────┼───────────┼───────────┼──────
    total │   9.6 MiB │   9.6 MiB │ -8 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.4 KiB │ -6 B │  62.9 KiB │  0 B │ ∆ META-INF/CERT.SF                        
 25.3 KiB │ -4 B │  62.8 KiB │  0 B │ ∆ META-INF/MANIFEST.MF                    
    272 B │ +2 B │     120 B │  0 B │ ∆ META-INF/version-control-info.textproto 
──────────┼──────┼───────────┼──────┼───────────────────────────────────────────
   54 KiB │ -8 B │ 125.8 KiB │  0 B │ (total)

@toluo-stripe toluo-stripe marked this pull request as ready for review January 6, 2025 17:12
@toluo-stripe toluo-stripe requested review from a team as code owners January 6, 2025 17:12
is LinkActivityResult.Failed -> {
linkEventsReporter.onPopupError(linkActivityResult.error)
}
LinkActivityResult.Completed -> Unit
Copy link
Collaborator

Choose a reason for hiding this comment

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

why does completed not also get a onPopupSuccess event?

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 a test for when LinkActivityResult is the new Completed type?

@@ -12,10 +12,16 @@ import org.json.JSONObject

internal sealed class LinkActivityResult : Parcelable {
/**
* Indicates that the flow was completed successfully.
* Indicates that the flow was completed successfully
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
* Indicates that the flow was completed successfully
* Indicates that the flow was completed successfully.

data object Completed : LinkActivityResult()

/**
* Indicates that the user selected a payment method. This payment method should be used for confirmation.
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
* Indicates that the user selected a payment method. This payment method should be used for confirmation.
* Indicates that the user selected a payment method. This payment method has not yet been confirmed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you look into a few things to clean up these tests:

  • Are all of the mocks here necessary? Can we swap any for fakes?
  • Is it possible to share more setup between tests? It looks like the set up to many of these tests is the exact same. It'd be nice to factor that out to make it easier to update these tests in the future and to make them more readable

Comment on lines +273 to +282
private open class LauncherLinkAnalyticsHelper : FakeLinkAnalyticsHelper() {
override fun onLinkLaunched() = Unit
}

private class TrackingLinkAnalyticsHelper : LauncherLinkAnalyticsHelper() {
var lastResult: LinkActivityResult? = null
override fun onLinkResult(linkResult: LinkActivityResult) {
lastResult = linkResult
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wdyt of just making FakeLinkAnalyticsHelper functional so that you don't have to create these custom overrides? By "functional" I just mean take whatever implementation you needed in these tests and add that implementation to the fake directly. It should simplify this code and also make it easier to test with that fake going forward

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also to add, it would be nice if TrackingLinkAnalyticsHelper worked similar to RecordingLinkStore.test so that we can ensure that all the interactions with LauncherLinkAnalyticsHelper are consumed and we have no unexpected calls.

intent = confirmationParameters.intent,
deferredIntentConfirmationType = deferredIntentConfirmationType
)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Happy to see that this was easy to do with the changes we made to the ConfirmationDefinition design!

Comment on lines +273 to +282
private open class LauncherLinkAnalyticsHelper : FakeLinkAnalyticsHelper() {
override fun onLinkLaunched() = Unit
}

private class TrackingLinkAnalyticsHelper : LauncherLinkAnalyticsHelper() {
var lastResult: LinkActivityResult? = null
override fun onLinkResult(linkResult: LinkActivityResult) {
lastResult = linkResult
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also to add, it would be nice if TrackingLinkAnalyticsHelper worked similar to RecordingLinkStore.test so that we can ensure that all the interactions with LauncherLinkAnalyticsHelper are consumed and we have no unexpected calls.

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