Skip to content

Conversation

@samiuelson
Copy link
Contributor

@samiuelson samiuelson commented Nov 4, 2025

💡 Don't merge until parent branch is trunk

Description

This pull request refactors the sync requirement logic to introduce a more granular distinction between "overdue" and "required but not yet overdue" sync states. It replaces the previous Overdue state with a new NonBlockingRequired state that includes an isOverdue boolean flag, allowing the system to differentiate between syncs that are simply due (between 2-7 days) versus those that are overdue (>7 days).

Key changes:

  • Introduced a DateTimeProvider dependency and fixed timestamp in tests to eliminate flaky time-dependent test behavior
  • Replaced WooPosFullSyncRequirement.Overdue with NonBlockingRequired(lastSyncTimestamp, isOverdue) to support intermediate sync states
  • Added a new FULL_SYNC_NOT_REQUIRED_THRESHOLD (2 days) to complement the existing FULL_SYNC_OVERDUE_THRESHOLD (7 days)

Test Steps

N/A

Images/gif

N/A

  • 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.

Refactors the local catalog full sync logic by replacing the `Overdue` state with a more descriptive `NonBlockingRequired` state.

The new `NonBlockingRequired` state includes a boolean flag, `isOverdue`, to indicate when the sync has passed the 7-day threshold, making states more granular.
Introduced a `DateTimeProvider` mock to ensure consistent and predictable time-based calculations within the tests. This change replaces `System.currentTimeMillis()` with the mock's `now()` method, improving the reliability and determinism of the test suite.
@samiuelson samiuelson changed the base branch from trunk to woomob-1327-woo-poslocal-catalog-do-not-run-full-sync-on-site-switch November 4, 2025 12:33
@samiuelson samiuelson requested a review from Copilot November 4, 2025 12:33
@samiuelson samiuelson added this to the 23.7 milestone Nov 4, 2025
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 pull request refactors the sync requirement logic to introduce a more granular distinction between "overdue" and "required but not yet overdue" sync states. It replaces the previous Overdue state with a new NonBlockingRequired state that includes an isOverdue boolean flag, allowing the system to differentiate between syncs that are simply due (between 2-7 days) versus those that are overdue (>7 days).

Key changes:

  • Introduced a DateTimeProvider dependency and fixed timestamp in tests to eliminate flaky time-dependent test behavior
  • Replaced WooPosFullSyncRequirement.Overdue with NonBlockingRequired(lastSyncTimestamp, isOverdue) to support intermediate sync states
  • Added a new FULL_SYNC_NOT_REQUIRED_THRESHOLD (2 days) to complement the existing FULL_SYNC_OVERDUE_THRESHOLD (7 days)

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
WooPosFullSyncStatusChecker.kt Refactored sync requirement logic to use NonBlockingRequired with isOverdue flag; injected DateTimeProvider for testability; added threshold for "not required" state
WooPosFullSyncStatusCheckerTest.kt Replaced System.currentTimeMillis() with mocked DateTimeProvider and constant NOW for deterministic testing; updated assertions for new NonBlockingRequired state
WooPosProductsDataSourceTest.kt Updated test to use NonBlockingRequired instead of Overdue
WooPosProductsDataSource.kt Updated pattern matching to use NonBlockingRequired instead of Overdue
WooPosLocalCatalogSyncWorker.kt Updated pattern matching to use NonBlockingRequired instead of Overdue
WooPosItemsViewModel.kt Added conditional logic to show banner only when isOverdue is true within NonBlockingRequired state

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

@samiuelson samiuelson added type: bug A confirmed bug. status: do not merge Dependent on another PR, ready for review but not ready for merge. labels Nov 4, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 4, 2025

📲 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
Commitd24aeea
Direct Downloadwoocommerce-wear-prototype-build-pr14894-d24aeea.apk

@samiuelson samiuelson marked this pull request as ready for review November 4, 2025 12:47
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 4, 2025

📲 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
Commitd24aeea
Direct Downloadwoocommerce-prototype-build-pr14894-d24aeea.apk

@malinajirka malinajirka self-assigned this Nov 5, 2025
Copy link
Contributor

@malinajirka malinajirka left a comment

Choose a reason for hiding this comment

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

Thanks @samiuelson ! The approach looks solid, I've left a note about the threshold.

companion object {
private val FULL_SYNC_OVERDUE_THRESHOLD = 7.days
private val FULL_SYNC_OVERDUE_THRESHOLD = 7.days.inWholeMilliseconds
private val FULL_SYNC_NOT_REQUIRED_THRESHOLD = 2.days.inWholeMilliseconds
Copy link
Contributor

Choose a reason for hiding this comment

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

💬 Two notes here

  1. According to the test plan, we should run periodic full sync every 24 hours. So we should either update the test plan and sync with iOS folks or change this to one-ish day.
  2. If we set it exactly to 1 day, it won't work either -> the worker might be run some time before the exact 24 hours, that's up to to the system to determine when to run the worker => I'd set it to 23 hours.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I changed FULL_SYNC_NOT_REQUIRED_THRESHOLD to 23 hours: 309cbbc

@samiuelson samiuelson removed the status: do not merge Dependent on another PR, ready for review but not ready for merge. label Nov 5, 2025
Base automatically changed from woomob-1327-woo-poslocal-catalog-do-not-run-full-sync-on-site-switch to trunk November 5, 2025 11:58
@samiuelson samiuelson enabled auto-merge November 5, 2025 12:22
@samiuelson samiuelson merged commit dbfd5b0 into trunk Nov 5, 2025
18 checks passed
@samiuelson samiuelson deleted the update-status-checker-states branch November 5, 2025 12:37
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 80.00000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.27%. Comparing base (2568ebc) to head (d24aeea).
⚠️ Report is 93 commits behind head on trunk.

Files with missing lines Patch % Lines
...droid/ui/woopos/home/items/WooPosItemsViewModel.kt 20.00% 3 Missing and 1 partial ⚠️
...oopos/localcatalog/WooPosLocalCatalogSyncWorker.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #14894      +/-   ##
============================================
- Coverage     38.27%   38.27%   -0.01%     
+ Complexity    10103    10102       -1     
============================================
  Files          2137     2137              
  Lines        121017   121024       +7     
  Branches      16584    16587       +3     
============================================
  Hits          46318    46318              
- Misses        69985    69991       +6     
- Partials       4714     4715       +1     

☔ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug A confirmed bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants