Skip to content

Conversation

@irfano
Copy link
Contributor

@irfano irfano commented Jan 9, 2026

Closes WOOMOB-1921

Description

Adds a new "Never miss a new order" dashboard card that prompts users to connect their store to WordPress.com for push notifications. The card is implemented as a configurable widget that can be hidden and reordered via the Customize screen.

The card is currently gated behind FeatureFlag.WOO_PUSH_NOTIFICATIONS_SYSTEM and will be shown when the flag is enabled. The onClick action is currently a no-op and will be implemented in a follow-up PR.

Test Steps

TC1: Feature flag disabled, authenticated with app passwords to site without support of new PN.

  1. Disable the feature flag WOO_PUSH_NOTIFICATIONS_SYSTEM_M2 and build the app.
  2. Log in to a site without support of new PN with site credentials.
  3. Confirm that the new dashboard card is not available in the Dashboard, and Jetpack banner is displayed.
  4. Confirm that the card is not visible in the Customize screen.

TC2: Feature flag enabled, authenticated with app passwords to site without support of new PN.

  1. Enable the feature flag WOO_PUSH_NOTIFICATIONS_SYSTEM_M2 and build the app.
  2. Log in to a site without support of new PN with site credentials.
  3. Confirm that the new dashboard card is displayed, and Jetpack banner is hidden.
  4. Tap the overflow menu on the card and select "Hide 'Enable push notifications'".
  5. Confirm that the card is hidden and will not display again after refreshing or relaunching.
  6. Confirm the card can be re-enabled from the Customize screen.

TC3: Feature flag enabled, authenticated with app passwords to site with support of new PN.

  1. Enable the feature flag WOO_PUSH_NOTIFICATIONS_SYSTEM_M2 and build the app.
  2. Log in to a site with support of new PN with site credentials.
  3. Confirm that the new dashboard card is not available (site is already registered), and Jetpack banner is not displayed.

TC4: Feature flag enabled, authenticated with WPCom to site without support of new PN.

  1. Enable the feature flag WOO_PUSH_NOTIFICATIONS_SYSTEM_M2 and build the app.
  2. Log in to a site without support of new PN with WPCom credentials.
  3. Confirm that the new dashboard card is not available, and Jetpack banner is not displayed.

Images/gif

Screenshot_20260109_153453 Screenshot_20260109_153457 Screenshot_20260128_154506 Screenshot_20260128_154410
  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

@irfano irfano added this to the 24.0 milestone Jan 9, 2026
@irfano irfano added the feature: notifications Related to notifications or notifs. label Jan 9, 2026
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 9, 2026

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App NameWooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commitde07126
Direct Downloadwoocommerce-wear-prototype-build-pr15180-de07126.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 9, 2026

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commitde07126
Direct Downloadwoocommerce-prototype-build-pr15180-de07126.apk

@codecov-commenter
Copy link

codecov-commenter commented Jan 9, 2026

Codecov Report

❌ Patch coverage is 38.18182% with 68 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.77%. Comparing base (c8afae3) to head (de07126).
⚠️ Report is 35 commits behind head on trunk.

Files with missing lines Patch % Lines
...ushnotifications/DashboardPushNotificationsCard.kt 0.00% 45 Missing ⚠️
...ations/push/ShouldShowEnablePushNotificationsUi.kt 0.00% 7 Missing ⚠️
...ommerce/android/ui/dashboard/DashboardViewModel.kt 81.81% 0 Missing and 4 partials ⚠️
...board/data/ObservePushNotificationsWidgetStatus.kt 0.00% 4 Missing ⚠️
...d/notifications/push/PushNotificationRepository.kt 0.00% 2 Missing and 1 partial ⚠️
...ommerce/android/ui/dashboard/DashboardContainer.kt 0.00% 3 Missing ⚠️
...cations/push/PushNotificationRegistrationStatus.kt 92.85% 0 Missing and 1 partial ⚠️
...e/android/ui/dashboard/data/DashboardRepository.kt 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #15180      +/-   ##
============================================
- Coverage     38.77%   38.77%   -0.01%     
  Complexity    10690    10690              
============================================
  Files          2208     2211       +3     
  Lines        125713   125802      +89     
  Branches      17409    17424      +15     
============================================
+ Hits          48745    48776      +31     
- Misses        72025    72081      +56     
- Partials       4943     4945       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@irfano irfano marked this pull request as ready for review January 14, 2026 11:44
@irfano irfano requested review from JorgeMucientes and removed request for JorgeMucientes January 14, 2026 11:44
@irfano irfano marked this pull request as draft January 15, 2026 12:31
Base automatically changed from issue/woomob-1909-add-new-local-feature-flag-for-woo-notifications-disabled-by to trunk January 16, 2026 16:54
@wpmobilebot wpmobilebot modified the milestones: 24.0, 24.1 Jan 23, 2026
@wpmobilebot
Copy link
Collaborator

Version 24.0 has now entered code-freeze, so the milestone of this PR has been updated to 24.1.

@irfano irfano force-pushed the issue/woomob-1921-replace-jetpack-banner-with-wp-dashboard-card-ui branch from 67446c7 to d72393d Compare January 28, 2026 15:35
…th-wp-dashboard-card-ui

# Conflicts:
#	WooCommerce/src/main/kotlin/com/woocommerce/android/util/FeatureFlag.kt
…th-wp-dashboard-card-ui

# Conflicts:
#	WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/DashboardViewModel.kt
#	WooCommerce/src/main/kotlin/com/woocommerce/android/util/FeatureFlag.kt
@irfano irfano requested a review from JorgeMucientes January 29, 2026 18:34
@irfano irfano marked this pull request as ready for review January 29, 2026 18:34
@JorgeMucientes JorgeMucientes self-assigned this Jan 30, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new configurable “Never miss a new order” dashboard card to encourage enabling push notifications, and wires it into the dynamic dashboard system while gating it behind a new feature flag and existing push-registration state.

Changes:

  • Adds a new DashboardWidget.Type.PUSH_NOTIFICATIONS widget, its strings, icon (wp_woo.xml), Compose UI card, and integration into the configurable dashboard and widget editor.
  • Introduces ShouldShowEnablePushNotificationsUi and ObservePushNotificationsWidgetStatus to determine when the push notifications card and Jetpack benefits banner should be shown, based on feature flag, connection type, and PushNotificationRegistrationStatus.
  • Extends dashboard data/repository/test wiring and feature flags to support the new widget and gating behavior.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
WooCommerce/src/test/kotlin/com/woocommerce/android/ui/dashboard/data/DashboardRepositoryTest.kt Updates repository test constructor wiring to include the new ObservePushNotificationsWidgetStatus dependency.
WooCommerce/src/test/kotlin/com/woocommerce/android/ui/dashboard/DashboardViewModelTest.kt Injects and mocks ShouldShowEnablePushNotificationsUi so the updated DashboardViewModel constructor and Jetpack banner logic can be instantiated in tests.
WooCommerce/src/main/res/values/strings.xml Adds title, menu title, and body copy strings for the new push notifications dashboard card.
WooCommerce/src/main/res/drawable/wp_woo.xml Adds the vector asset used in the push notifications card to visually represent the WordPress.com/Woo integration.
WooCommerce/src/main/kotlin/com/woocommerce/android/util/FeatureFlag.kt Introduces WOO_PUSH_NOTIFICATIONS_SYSTEM_M2 and ensures both push-related flags default to false.
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/pushnotifications/DashboardPushNotificationsCard.kt Implements the Compose UI for the “Never miss a new order” card, including title, description, artwork, and the standard “Hide widget” overflow menu wiring.
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/data/ObservePushNotificationsWidgetStatus.kt Adds a widget-status observer that exposes the push notifications widget as Available or Hidden based on ShouldShowEnablePushNotificationsUi.
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/data/DashboardRepository.kt Wires the push notifications widget status into the combined dashboard widget stream and status mapping so the new widget participates in the dynamic dashboard.
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/data/DashboardDataStore.kt Ensures the new widget type is part of the default dashboard configuration and can be enabled/disabled via the widget editor, while being filtered when not supported.
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/DashboardViewModel.kt Injects ShouldShowEnablePushNotificationsUi and updates jetpackBenefitsBannerState to suppress the Jetpack banner when the new push notifications UI is available.
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/DashboardContainer.kt Renders DashboardPushNotificationsCard whenever a configurable widget of type PUSH_NOTIFICATIONS is present and visible.
WooCommerce/src/main/kotlin/com/woocommerce/android/notifications/push/ShouldShowEnablePushNotificationsUi.kt Adds core business logic for when the “Enable Push Notifications” UI should be shown (feature-flag + app-password connection + registration status), but currently contains a boolean condition that is always true for any single status, so registered sites still see the card.
WooCommerce/src/main/kotlin/com/woocommerce/android/model/DashboardWidget.kt Adds the PUSH_NOTIFICATIONS enum entry, with appropriate title resource and tracking identifier, so it can participate in dashboard configuration and analytics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 297 to 305
.map {
val durationSinceDismissal =
(System.currentTimeMillis() - appPrefsWrapper.getJetpackBenefitsDismissalDate()).milliseconds
val showBanner =
val enablePnUiAvailable = shouldShowEnablePushNotificationsUi()
val showBanner = !enablePnUiAvailable &&
pushNotificationRegistrationStatus(selectedSite.getIfExists()?.siteId) == Status.UNREGISTERED &&
durationSinceDismissal >= DAYS_TO_REDISPLAY_JP_BENEFITS_BANNER.days
durationSinceDismissal >= DAYS_TO_REDISPLAY_JP_BENEFITS_BANNER.days
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The new logic that hides the Jetpack Benefits banner when the "Enable Push Notifications" UI is available (enablePnUiAvailable = shouldShowEnablePushNotificationsUi(), then showBanner = !enablePnUiAvailable && …) is not covered by tests: all existing DashboardViewModelTest cases stub ShouldShowEnablePushNotificationsUi to return false. Given the detailed scenarios in the PR description (TC1–TC4), please add unit tests that exercise cases where ShouldShowEnablePushNotificationsUi() returns true versus false so the banner visibility behavior is validated (e.g., ensuring the Jetpack banner is suppressed when the new push card should be shown).

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@JorgeMucientes JorgeMucientes left a comment

Choose a reason for hiding this comment

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

Hey @irfano I've noticed a few issues that are worth checking particularly around TC3 not working. Some are NPs but some others are blocking issues.

*
* This is part of the Woo Core push notifications system for app-password authenticated sites.
*/
class ShouldShowEnablePushNotificationsUi @Inject constructor(
Copy link
Contributor

Choose a reason for hiding this comment

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

Np, it be nice to have unit tests added for this class.

Copy link
Contributor Author

@irfano irfano Feb 3, 2026

Choose a reason for hiding this comment

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

Since FeatureFlag.WOO_PUSH_NOTIFICATIONS_SYSTEM_M2 is a local feature flag that defaults to false and cannot be mocked in tests, we cannot write meaningful unit tests for this class when the flag is disabled.

We could add a wrapper similar to IsRemoteFeatureFlagEnabled for local feature flags, but given that a feature flag refactor (WOOMOB-2129) is already planned in the near future, I'd prefer not to introduce this change at this point.

val site = selectedSite.getIfExists() ?: return false
if (site.connectionType != SiteConnectionType.ApplicationPasswords) return false

return pushNotificationRegistrationStatus(site.siteId) != Status.WOO_REGISTERED ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Np, pushNotificationRegistrationStatus() function access disk several times via app prefs and datastore. It be nice to call this function only once and keep the returned value in a function variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic has changed in my latest commits.

Comment on lines 31 to 32
modifier: Modifier = Modifier,
onHideClicked: () -> Unit,
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor NP, but modifier should be placed last as it is the first optional parameter:

We will adopt official guidelines on how to pass the Modifier as parameter: "MUST be named "modifier" and MUST appear as the first optional parameter in the element function's parameter list".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍🏻 Done: 194efdd

class ObservePushNotificationsWidgetStatus @Inject constructor(
private val shouldShowEnablePushNotificationsUi: ShouldShowEnablePushNotificationsUi
) {
operator fun invoke(): Flow<DashboardWidget.Status> = flow {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is called from DashboardRepository,kt which has @ActivityRetainedScoped. This means that when we log in with site credentials into a site that supports Woo PN notifications we'll always display the new "connect to WP.com" banner even after registering in Woo core PN system. Basically TC3 doesn't work with the current implementation even after fixing the issue reported above. We probably need to refresh the PNWidgetStatus after successfully registering in Woo system.

Screen_recording_20260203_100654.mp4

Copy link
Contributor Author

@irfano irfano Feb 3, 2026

Choose a reason for hiding this comment

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

Good catch @JorgeMucientes! This isn't actually reproducible in #15283 but I still think it's better to apply your suggestion. Done here: c61cd28

@irfano irfano force-pushed the issue/woomob-1921-replace-jetpack-banner-with-wp-dashboard-card-ui branch from 4f32249 to 2d71511 Compare February 3, 2026 14:44
@irfano irfano force-pushed the issue/woomob-1921-replace-jetpack-banner-with-wp-dashboard-card-ui branch from b7f995e to bd5dac5 Compare February 3, 2026 15:15
@irfano irfano force-pushed the issue/woomob-1921-replace-jetpack-banner-with-wp-dashboard-card-ui branch from 54f95ac to de07126 Compare February 3, 2026 22:57
@irfano
Copy link
Contributor Author

irfano commented Feb 3, 2026

Thanks for your review, @JorgeMucientes! Ready for another round.
While addressing your feedback, I noticed another issue: we weren't clearing the Woo push token when the user was logged in with site credentials. I fixed it here: 0b88f0f

@irfano irfano requested a review from JorgeMucientes February 4, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: notifications Related to notifications or notifs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants