woocommerce / woocommerce-android

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

[POS] Custom payment UI — Part 4 | Switching from `viewStateData` to `paymentState` #12898

Open samiuelson opened 1 week ago

samiuelson commented 1 week ago

Switching from viewStateData to paymentState

Closes: #12825

Description

This PR:

  1. Removes val viewStateData: LiveData<ViewState> from CardReaderPaymentController
  2. Maps CardReaderPaymentController.paymentState to ViewState in CardReaderPaymentViewModel, using the CardReaderPaymentStateToViewStateMapper use case class

The goal of that PR is to make the payment controller independent of the ViewState class, and extract mapping of the CardReaderPaymentOrRefundState emitted by controller to ViewState (UI state of the existing IPP flow) in the target VM. Thanks to such separation, the controller will allow flexible reuse of the payment flow in the POS.

This is part 4 of 5 PRs refactoring the Payment flow:

  1. [POS] Custom payment UI — Part 1 | Separating payment collection management from Android Framework
  2. [POS] Custom payment UI — Part 2 | Separating CardReaderPaymentController's events from MultiLiveEvent
  3. [POS] Custom Payment UI – Part 3 | Emitting UI–agnostic payment states in CardReaderPaymentController
  4. [POS] Custom payment UI — Part 4 | Switch from viewStateData to paymentState
  5. [POS] Custom payment UI — Part 5 | Unit tests clean up

⚠️ Don't merge — the branch will be merged together with the above ones after additional testing of the whole refactor.

Next steps

I'll add unit tests for CardReaderPaymentController, in the next PR.

Testing information

As a result of the refactoring done within this PR, the app should work without any change. It's crucial to test the IPP flow in the store management and POS modes against regression. It may be useful to base on the test plan (pdfdoF-5Jz-p2).

The tests that have been performed

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 1 week ago
2 Errors
:no_entry_sign: Please add tests for class InteracRefundFailure (or add unit-tests-exemption label to ignore this).
:no_entry_sign: This PR is tagged with status: do not merge label(s).
1 Warning
:warning: This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by :no_entry_sign: Danger

wpmobilebot commented 1 week 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
Commit0d3565ba07e27c0976a07fda7f5e2fcab65e863a
Direct Downloadwoocommerce-wear-prototype-build-pr12898-0d3565b.apk
wpmobilebot commented 1 week 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
Commit0d3565ba07e27c0976a07fda7f5e2fcab65e863a
Direct Downloadwoocommerce-prototype-build-pr12898-0d3565b.apk
codecov-commenter commented 1 week ago

Codecov Report

Attention: Patch coverage is 97.43590% with 4 lines in your changes missing coverage. Please review.

Project coverage is 40.65%. Comparing base (44115aa) to head (71e5b37).

Files with missing lines Patch % Lines
...payment/CardReaderPaymentStateToViewStateMapper.kt 97.98% 1 Missing and 2 partials :warning:
.../payment/controller/CardReaderPaymentController.kt 80.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## custom-payment-ui-3 #12898 +/- ## ====================================================== Coverage 40.64% 40.65% + Complexity 5816 5808 -8 ====================================================== Files 1250 1251 +1 Lines 71204 71210 +6 Branches 9916 9937 +21 ====================================================== + Hits 28943 28952 +9 + Misses 39628 39624 -4 - Partials 2633 2634 +1 ```

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