Repository navigation
feat: add a compose friendly constructor to SEPADirectDebit - #1704
Conversation
Dependency Review✅ No vulnerabilities found.Scanned FilesNone |
There was a problem hiding this comment.
🟢 Approval recommended
The only finding is a non-blocking test assertion nit.
Pull request overview
Adds a Compose-friendly ActivityResultRegistry constructor to SEPADirectDebitLauncher, with a unit test and changelog entry.
Changes:
- Added registry-based launcher construction.
- Added constructor test coverage.
- Documented the change in
CHANGELOG.md.
File summaries
| File | Summary |
|---|---|
SEPADirectDebit/src/test/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitLauncherUnitTest.kt |
Tests registry-based construction; includes a minor assertion nit. |
SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitLauncher.kt |
Adds the Compose-compatible constructor. |
CHANGELOG.md |
Documents the new constructor. |
Review details
Suppressed comments (1)
SEPADirectDebit/src/test/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitLauncherUnitTest.kt:43
- This assertion only proves that Kotlin returned a non-null object, so it would still pass if this overload ignored
registryand constructed the defaultBrowserSwitchClient. Please verify the registry-backed browser-switch client is actually used (or remove the test if compile-only coverage is intended), so the new Compose wiring is protected from regressions.
val launcher = SEPADirectDebitLauncher(registry)
assertNotNull(launcher)
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| * Used to launch the SEPA mandate in a web browser and deliver results. Use it in Compose flows | ||
| * or anywhere else an [ActivityResultCaller] is not available. | ||
| * @param registry ActivityResultRegistry parameter. It will be passed to BrowserSwitchClient. | ||
| */ |
There was a problem hiding this comment.
This is a nice, helpful comment!
|
|
||
| assertNotNull(launcher) | ||
| } | ||
|
|
There was a problem hiding this comment.
This is a question coming from my lack of compose knowledge, but is this type of test good enough to confirm the compose constructor is working as intended?
There was a problem hiding this comment.
great question, i think I was mostly trying to test here if the constructor can be constructed with ActivityResultCaller without crashing. Most of the hard work is passed to BrowserSwitchClient so it is hard to test anything besides launcher creation. I can possibly mock the creation of BrowserSwitchClient with the newly created launcher, do you think it will be better?
There was a problem hiding this comment.
I think that question is probably best answered by you and other Android platform specific folks since I don't know the common best practices for compose UI tests and how much is necessary
There was a problem hiding this comment.
When I read the text of the test, "creates a valid launcher", I think here I would at least expect some more assertions on the launcher itself to verify it is "valid". If all we wanted was a test that the launcher gets created when being passed the expected params, that kind of feels like a low value test to me unless there is something specific you're looking for having been set up from calling the constructor.
There was a problem hiding this comment.
Yeah that makes sense and sort of what I was curious about: Are there additional things that could be asserted to see if any attributes can be verified, or is this comprehensive enough
There was a problem hiding this comment.
Hi all, i removed this test, and instead wired a new constructor in the demo app, I dont think we can add a useful unit test for this change since all the constructor is doing is passing the registry to browserSwitchClient, that then does all the job. I feel like wiring the new constructor is comprehensive enough to ensure the flow works as expected. Let me know what you think :)
There was a problem hiding this comment.
🟡 Changes recommended
The test should verify that the supplied registry is actually used.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
saralvasquez
left a comment
There was a problem hiding this comment.
These changes seem simple enough, but could I get a bit of context on why we are adding this? The ticket for this referenced the acceptance criteria but didn't give much explanation otherwise
I think I also second the comments on testing. I wonder if there would be a way to do extra testing on this by possibly adding to the demo app or something
|
hey @saralvasquez , thank you for your question! this ticket came as a follow up for this ask: #1662. Here we are asked to do the compose for GooglePay, but upon investigation I found that SEPADirectDebit and some other launchers can also use compose friendly constructor :) I think adding that compose for the demo might be a good middle ground in testing the constructor out, I will add that! |
| constructor(registry: ActivityResultRegistry) : this( | ||
| browserSwitchClient = BrowserSwitchClient(registry) |
There was a problem hiding this comment.
These constructors match the same pattern that Venmo and PayPal Launchers have today.
There was a problem hiding this comment.
We should still validate (and they may be broken on those other Launchers if this ends up being true)
There was a problem hiding this comment.
Added unit tests to test the behavior outlined by copilot. The code didnt not crash, so I believe we can continue with the merge.
# Conflicts: # CHANGELOG.md
…delete unnecessary test
c54b1c8 to
42ef463
Compare
saralvasquez
left a comment
There was a problem hiding this comment.
Thanks for adding the change to the demo app! I think this is a good approach since testing these changes is challenging


Summary of changes
AI Usage
Which AI Agent Was Used?
How was AI used?
test creation
Estimated AI Code Contribution
Checklist
Authors