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

refactor: move push click handling to processor #268

Merged
merged 22 commits into from
Oct 6, 2023

Conversation

mrehan27
Copy link
Contributor

@mrehan27 mrehan27 commented Oct 2, 2023

helps: https://github.com/customerio/issues/issues/10830

Changes

  • Moved code out of NotificationClickReceiverActivity to PushMessageProcessor for reusability and better testing
  • Added tests for CustomerIOPushNotificationHandler, ModuleMessagingConfig and PushMessageProcessor

@mrehan27 mrehan27 self-assigned this Oct 2, 2023
@github-actions
Copy link

github-actions bot commented Oct 2, 2023

Sample app builds 📱

Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request.


  • java_layout: rehan/push-click-behavior-tests (1696585078)
  • kotlin_compose: rehan/push-click-behavior-tests (1696585106)

@codecov
Copy link

codecov bot commented Oct 2, 2023

Codecov Report

Merging #268 (c90b120) into rehan/push-click-behavior (8b9f02a) will increase coverage by 3.19%.
Report is 9 commits behind head on rehan/push-click-behavior.
The diff coverage is 63.20%.

@@                       Coverage Diff                       @@
##             rehan/push-click-behavior     #268      +/-   ##
===============================================================
+ Coverage                        50.84%   54.04%   +3.19%     
- Complexity                         249      278      +29     
===============================================================
  Files                              108      109       +1     
  Lines                             2779     2781       +2     
  Branches                           361      349      -12     
===============================================================
+ Hits                              1413     1503      +90     
+ Misses                            1249     1156      -93     
- Partials                           117      122       +5     
Files Coverage Δ
...ustomer/messagingpush/MessagingPushModuleConfig.kt 100.00% <100.00%> (ø)
...o/customer/messagingpush/ModuleMessagingPushFCM.kt 68.00% <ø> (-1.24%) ⬇️
...customer/messagingpush/config/PushClickBehavior.kt 100.00% <100.00%> (ø)
.../customer/messagingpush/di/DiGraphMessagingPush.kt 66.66% <100.00%> (+45.23%) ⬆️
...sagingpush/extensions/ApplicationInfoExtensions.kt 0.00% <ø> (ø)
...ngpush/lifecycle/MessagingPushLifecycleCallback.kt 40.00% <ø> (+18.26%) ⬆️
...er/messagingpush/processor/PushMessageProcessor.kt 100.00% <ø> (ø)
.../src/main/java/io/customer/sdk/CustomerIOConfig.kt 100.00% <ø> (ø)
...messagingpush/CustomerIOPushNotificationHandler.kt 9.75% <80.00%> (+9.75%) ⬆️
...push/activity/NotificationClickReceiverActivity.kt 63.15% <63.15%> (ø)
... and 3 more

... and 1 file with indirect coverage changes

@github-actions
Copy link

github-actions bot commented Oct 2, 2023

Build available to test
Version: rehan-push-click-behavior-tests-SNAPSHOT
Repository: https://s01.oss.sonatype.org/content/repositories/snapshots/

@mrehan27 mrehan27 marked this pull request as ready for review October 2, 2023 13:55
@mrehan27 mrehan27 requested a review from a team October 2, 2023 13:55
} else {
processNotificationIntent(payload = payload)
sdkInstance.diGraph.pushMessageProcessor.processNotificationClick(
Copy link
Contributor

Choose a reason for hiding this comment

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

think this should be covered by 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.

We can. But I avoided because I don't think this adds a lot of value. It mostly relies on Android OS lifecycle and couple of other methods that are already being tested. Also, it requires setting up Activity lifecycle for testing which I plan to improve later to gain more confidence in testing. However, if you think we should still cover this, I can write a test for it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it still alots value because the whole logic revolves around what flags to expect and what behaviour it would display.

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 have pushed more tests, hope it helps.

PS: Github is having issues in PRs, so it might take some time to show new changes.

Copy link
Contributor

@Shahroz16 Shahroz16 left a comment

Choose a reason for hiding this comment

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

getApplicationInfo(String, PackageManager.ApplicationInfoFlags) lets maybe use this, since the other method is deprecated.

Copy link
Contributor

@levibostian levibostian left a comment

Choose a reason for hiding this comment

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

Looking good! I am OK with approving, but with a big PR like this, I would prefer multiple reviews and approvals on this one. So, I'll let Shahroz help me and approve this one.

@mrehan27
Copy link
Contributor Author

mrehan27 commented Oct 4, 2023

@Shahroz16 I can see many warnings on getApplicationInfo, but the part of code using it is not linked with this change and exist in current main branch. I agree we should fix this warning, but it should be done and tested in a separate PR.

@mrehan27
Copy link
Contributor Author

mrehan27 commented Oct 4, 2023

@levibostian Most of the changes are actually copied from NotificationClickReceiverActivity to PushMessageProcessorImpl to facilitate testing. I avoid splitting into multiple PRs because except tests, all other changes are already been approved in #249. But I understand the concern, and will wait for both of you to approve before merging.

} else {
processNotificationIntent(payload = payload)
sdkInstance.diGraph.pushMessageProcessor.processNotificationClick(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it still alots value because the whole logic revolves around what flags to expect and what behaviour it would display.

@mrehan27 mrehan27 merged commit e2acf5b into rehan/push-click-behavior Oct 6, 2023
30 checks passed
@mrehan27 mrehan27 deleted the rehan/push-click-behavior-tests branch October 6, 2023 10:27
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