Skip to content

Conversation

@wzieba
Copy link
Contributor

@wzieba wzieba commented May 24, 2023

Closes: #8949

Description

This PR adds behavior after pressing "Settings" button on the Privacy Banner. The behavior is described in #8949 and should match iOS described in woocommerce/woocommerce-ios#9802

It targets feature/new_privacy_screen because I needed to provide changes in the Privacy Screen to make it possible to show an error message.

Testing instructions

Every test case should start with opening the Privacy Banner: you should use VPN connection if needed to any European country. To show the banner at the next fresh app launch without reinstalling the app, please use option in Developer Settings.

WPCOM account

All tests in this section should be performed when logged in as WPCOM user

TC 1 Not updating settings
  1. Tap on "Settings"
  2. Assert that you're redirected to the Privacy Settings screen
  3. Restart the app and assert that the Privacy Banner doesn't appear again
TC 2 Updating settings
  1. Be logged-in into WPCOM account
  2. Alternate the current Analytics preference value
  3. Tap on "Settings"
  4. Assert that you're redirected to the Privacy Settings and the Analytics setting was updated (validate by going to https://wordpress.com/me/privacy)
  5. Restart the app and assert that the Privacy Banner doesn't appear again
TC 3 Not updating settings + error
  1. Turn off the internet connection
  2. Tap on "Settings"
  3. Assert that you're redirected to the Privacy Settings screen and there's Snackbar: "There was an error fetching(...)
  4. Restart the app and assert that the Privacy Banner doesn't appear again
TC 4 Updating settings + error
  1. Turn off the internet connection
  2. Alternate the current Analytics preference value
  3. Tap on "Settings"
  4. Assert that you're redirected to the Privacy Settings screen and there's Snackbar: "There was an error updating(...) with retry button
  5. Restart the app and assert that the Privacy Banner does appear again
  6. Alternate the current Analytics preference value
  7. Tap on "Settings" again
  8. Assert that you're redirected to the Privacy Settings screen and there's Snackbar: "There was an error updating(...) with retry button
  9. Turn on the internet connection
  10. Tap on "Retry"
  11. Restart the app and assert that the Privacy Banner doesn't appear again

Non-WPCOM account

In the case of non-WPCOM account, it doesn't matter whether we change the initial setting or not, there's also no chance for the error.

TC1
  1. Change Analytics setting
  2. Tap on "Settings"
  3. Assert that you're redirected to the Privacy Settings screen and the new Analytics setting is checked
  4. Restart the app and assert that the Privacy Banner doesn't appear again

Images/gif

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@wzieba wzieba linked an issue May 24, 2023 that may be closed by this pull request
7 tasks
@wpmobilebot
Copy link
Collaborator

You can test the changes on this Pull Request by downloading an installable build, or scanning this QR code:

@codecov-commenter
Copy link

codecov-commenter commented May 24, 2023

Codecov Report

Patch coverage: 4.00% and project coverage change: -0.05 ⚠️

Comparison is base (2a17991) 43.75% compared to head (b7efeee) 43.71%.

Additional details and impacted files
@@                       Coverage Diff                        @@
##             feature/new_privacy_screen    #9107      +/-   ##
================================================================
- Coverage                         43.75%   43.71%   -0.05%     
  Complexity                         4136     4136              
================================================================
  Files                               845      846       +1     
  Lines                             44323    44369      +46     
  Branches                           5820     5831      +11     
================================================================
+ Hits                              19394    19395       +1     
- Misses                            23225    23270      +45     
  Partials                           1704     1704              
Impacted Files Coverage Δ
...in/com/woocommerce/android/ui/main/MainActivity.kt 0.00% <ø> (ø)
...ocommerce/android/ui/main/MainActivityViewModel.kt 64.11% <0.00%> (-2.35%) ⬇️
...mmerce/android/ui/prefs/RequestedAnalyticsValue.kt 0.00% <0.00%> (ø)
.../ui/prefs/privacy/banner/PrivacyBannerViewModel.kt 0.00% <0.00%> (ø)
...tlin/com/woocommerce/android/util/ActivityUtils.kt 0.00% <ø> (ø)
...merce/android/ui/prefs/PrivacySettingsViewModel.kt 55.00% <22.22%> (-5.57%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@wzieba wzieba marked this pull request as ready for review May 25, 2023 10:02
@wzieba wzieba requested a review from atorresveiga May 25, 2023 10:03
@wzieba wzieba added the feature: privacy Related to the privacy choice projects label May 25, 2023
@peril-woocommerce
Copy link

peril-woocommerce bot commented May 25, 2023

Warnings
⚠️ PR is not assigned to a milestone.

Generated by 🚫 dangerJS

@atorresveiga atorresveiga self-assigned this May 25, 2023
Comment on lines +47 to +74
launch {
if (repository.isUserWPCOM()) {
_state.value = _state.value?.copy(loading = true)
val event =
repository.updateTracksSetting(_state.value?.analyticsSwitchEnabled ?: false)
_state.value = _state.value?.copy(loading = false)

event.fold(
onSuccess = {
appPrefsWrapper.savedPrivacyBannerSettings = true
analyticsTrackerWrapper.sendUsageStats = analyticsPreference
triggerEvent(ShowSettings)
},
onFailure = {
triggerEvent(
ShowErrorOnSettings(
requestedAnalyticsValue = if (analyticsPreference) RequestedAnalyticsValue.ENABLED
else RequestedAnalyticsValue.DISABLE
)
)
}
)
} else {
appPrefsWrapper.savedPrivacyBannerSettings = true
analyticsTrackerWrapper.sendUsageStats = analyticsPreference
triggerEvent(ShowSettings)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

np: We might want to unit test this in the future

}
}

@Suppress("MagicNumber")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

@atorresveiga atorresveiga left a comment

Choose a reason for hiding this comment

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

Great work @wzieba. Everything worked as expected!

LGTM! :shipit:

@atorresveiga atorresveiga merged commit 07b88bb into feature/new_privacy_screen May 25, 2023
@atorresveiga atorresveiga deleted the issue/8949_handle_settings_cta branch May 25, 2023 20:12
@wzieba wzieba mentioned this pull request May 26, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: privacy Related to the privacy choice projects

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Privacy Choices] Handle "Go to Settings" CTA

5 participants