Skip to content

[WOOMOB-1949] Wire file-based sync action and use shared result type#15174

Merged
samiuelson merged 9 commits intotrunkfrom
issue/woomob-1949-poslocal-catalog-switch-between-file-and-paginated-download
Jan 12, 2026
Merged

[WOOMOB-1949] Wire file-based sync action and use shared result type#15174
samiuelson merged 9 commits intotrunkfrom
issue/woomob-1949-poslocal-catalog-switch-between-file-and-paginated-download

Conversation

@malinajirka
Copy link
Contributor

@malinajirka malinajirka commented Jan 8, 2026

Fixes WOOMOB-1949

Description

Wires WooPosFileBasedSyncAction into the repository when WOO_POS_LOCAL_CATALOG_FILE_APPROACH feature flag is enabled, and refactors it to return wrapper around PosLocalCatalogSyncResult instead of Result<FileBasedSyncResult>.

This eliminates the need for error mapping in the repository layer - the action now handles all error cases and returns the appropriate PosLocalCatalogSyncResult.Failure types directly (NetworkError, InvalidResponse, DatabaseError, CatalogGenerationTimeout).

Note: There are still a lot of things that need to be done before this code is ready for production. For example:

  • The 1000 products limit must be removed
  • Background worker needs to properly handle scenario in which polling runs out of maximum attempts
  • Checks for catalog size must be skipped when file based approach is enabled
  • The flag stored in data store for skipping local catalog must be reseted on store with catalog large then 1000 items
  • ....

Test Steps

IMPORTANT - Make sure to use supported version of Woo on your site. You can use Jetpack Beta plugin and select issue/woomob-1894-add-pos-visibility-taxonomy-to-core branch of Woo core.

Test file-based sync (new behavior):

  1. Enable WOO_POS_LOCAL_CATALOG_FILE_APPROACH feature flag
  2. Clear app data
  3. Log in
  4. Observer network requests and verify the file is downloaded and incremental update fetches just first page with 0 results.
  5. Open POS and verify products are visible

Test for regressions (paginated sync):

  1. Disable WOO_POS_LOCAL_CATALOG_FILE_APPROACH feature flag
  2. Clear app data
  3. Log in and open POS
  4. Verify products load successfully

Images/gif

N/A - Internal sync logic changes

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

…and-paginated-download' into issue/woomob-1949-poslocal-catalog-switch-between-file-and-paginated-download

# Conflicts:
#	WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosFileBasedSyncAction.kt
#	WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosFileBasedSyncActionTest.kt
…etween-file-and-paginated-download

# Conflicts:
#	WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosFileBasedSyncAction.kt
…and-paginated-download' into issue/woomob-1949-poslocal-catalog-switch-between-file-and-paginated-download

# Conflicts:
#	WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosFileBasedSyncAction.kt
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 8, 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
Commitf3424a8
Direct Downloadwoocommerce-wear-prototype-build-pr15174-f3424a8.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 8, 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
Commitf3424a8
Direct Downloadwoocommerce-prototype-build-pr15174-f3424a8.apk

Base automatically changed from issue/woomob-1945-poslocal-catalog-switch-between-file-and-paginated-download to trunk January 8, 2026 13:38
@malinajirka malinajirka added this to the 24.0 milestone Jan 8, 2026
@malinajirka malinajirka requested a review from Copilot January 8, 2026 14:32
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 wires the WooPosFileBasedSyncAction into the WooPosLocalCatalogSyncRepository and refactors it to return PosLocalCatalogSyncResult directly instead of wrapping results in Result<FileBasedSyncResult>. This eliminates error mapping at the repository level and makes the file-based sync action consistent with the existing paginated sync action.

Key changes:

  • Feature flag-based conditional routing between file-based and paginated sync approaches
  • Direct return of PosLocalCatalogSyncResult types with specific failure subtypes (NetworkError, InvalidResponse, DatabaseError, CatalogGenerationTimeout)
  • Removal of intermediate FileBasedSyncResult data class

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
WooPosLocalCatalogSyncRepository.kt Added dependency injection for WooPosFileBasedSyncAction and feature flag-based conditional logic to route sync requests
WooPosFileBasedSyncAction.kt Refactored return type from Result<FileBasedSyncResult> to PosLocalCatalogSyncResult with improved error handling and logging consistency
WooPosFileBasedSyncActionTest.kt Updated test assertions to match new return type, removed obsolete test for fields no longer in the result
WooPosLocalCatalogSyncRepositoryTest.kt Added mock for WooPosFileBasedSyncAction

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

…localcatalog/WooPosFileBasedSyncAction.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 74.32432% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.65%. Comparing base (1b570f5) to head (f3424a8).
⚠️ Report is 10 commits behind head on trunk.

Files with missing lines Patch % Lines
...s/localcatalog/WooPosLocalCatalogSyncRepository.kt 36.84% 11 Missing and 1 partial ⚠️
...i/woopos/localcatalog/WooPosFileBasedSyncAction.kt 87.27% 0 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##              trunk   #15174   +/-   ##
=========================================
  Coverage     38.65%   38.65%           
  Complexity    10520    10520           
=========================================
  Files          2189     2189           
  Lines        124369   124400   +31     
  Branches      17189    17196    +7     
=========================================
+ Hits          48069    48091   +22     
- Misses        71449    71455    +6     
- Partials       4851     4854    +3     

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

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


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

class WooPosLocalCatalogSyncRepositoryTest : BaseUnitTest() {
private lateinit var sut: WooPosLocalCatalogSyncRepository
private var posSyncAction: WooPosSyncAction = mock()
private var posFileBasedSyncAction: WooPosFileBasedSyncAction = mock()
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The new file-based sync path added to syncLocalCatalogFull when the feature flag is enabled lacks test coverage. Consider adding test cases that verify:

  • The file-based sync action is called when the feature flag is enabled
  • Timestamps are properly stored from the lastModifiedDate when file-based sync succeeds
  • Failure scenarios from file-based sync are properly handled
  • The regular paginated sync is still used when the feature flag is disabled

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@samiuelson samiuelson left a comment

Choose a reason for hiding this comment

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

LGTM!

@samiuelson samiuelson enabled auto-merge January 12, 2026 20:08
@samiuelson samiuelson merged commit 7dc21fc into trunk Jan 12, 2026
16 of 17 checks passed
@samiuelson samiuelson deleted the issue/woomob-1949-poslocal-catalog-switch-between-file-and-paginated-download branch January 12, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants