woocommerce / woocommerce-android

WooCommerce Android app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
277 stars 135 forks source link

Refactor existing products list to hold more generic items #12864

Closed AnirudhBhat closed 2 weeks ago

AnirudhBhat commented 2 weeks ago

Closes: #12841

Description

The existing ProductList model used in POS is currently limited to holding only "Product" type items. However, with ongoing work to support Variable products and anticipated needs to add a broader range of item types (such as coupons, discounts, custom amounts, categories ...etc), the ProductList needs a more flexible structure to accommodate these variations. This refactor aims to create a generic list structure that can dynamically support various item types on the POS home screen, setting a foundation for future feature expansion.

What’s Changed

  1. Generic Item List Model: Introduced a new WooPosItem model that can accommodate multiple item types, including but not limited to Products, Coupons, Discounts, Custom Amounts, Variable Products, Variations, and Categories.

  2. Generic item navigation model: Introduced a new WooPosItemNavigationData model that holds data required for selected product types while navigating to different screens from the POS items list - For instance, passing just an ID would be sufficient when simple physical product is clicked whereas we need to pass in the variation quantity and ID for Variable products as we navigate to a different screen in this case.

  3. Rename product screen, view model, and UI event to item screen, view model, and UI event

  4. Rename Products package name into items

Testing information

  1. Test the POS flow from loading products, adding them to cart, and completing a transaction to ensure the refactor did not break anything
  2. Ensure unit tests have passed in the CI pipeline.

The tests that have been performed

Smoke tested the POS flow end to end

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

dangermattic commented 2 weeks ago
1 Warning
:warning: Class WooPosItemNavigationData is missing tests, but unit-tests-exemption label was set to ignore this.

Generated by :no_entry_sign: Danger

wpmobilebot commented 2 weeks ago
📲 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 Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commitd9787942468ef5ed82f091aa92ae5fe857e7f857
Direct Downloadwoocommerce-wear-prototype-build-pr12864-d978794.apk
wpmobilebot commented 2 weeks ago

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

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commitd9787942468ef5ed82f091aa92ae5fe857e7f857
Direct Downloadwoocommerce-prototype-build-pr12864-d978794.apk
codecov-commenter commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 83.87097% with 10 lines in your changes missing coverage. Please review.

Project coverage is 40.25%. Comparing base (995e65a) to head (d978794). Report is 20 commits behind head on trunk.

Files with missing lines Patch % Lines
...droid/ui/woopos/home/items/WooPosItemsViewModel.kt 72.22% 3 Missing and 7 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## trunk #12864 +/- ## ============================================ + Coverage 40.24% 40.25% +0.01% - Complexity 5784 5786 +2 ============================================ Files 1247 1249 +2 Lines 71160 71174 +14 Branches 9933 9934 +1 ============================================ + Hits 28638 28651 +13 Misses 39889 39889 - Partials 2633 2634 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.