woocommerce-ios
woocommerce-ios copied to clipboard
Orders Details: Use common class for Country and State selector in Order Details
Part of https://github.com/woocommerce/woocommerce-ios/issues/6667
Description
CountrySelectorCommand
and StateSelectorCommand
share the majority of its code. To avoid the downsides of having duplicated code, we're abstracting these into one common class.
Changes:
- Create a common
AddressSelectorCommandProtocol
thatCountry
andStateOfACountry
conforms to (These are typealiases ofNetworking.Country
andNetworking.StateOfACountry
respectively) - Collapse
CountrySelectorCommand
andStateSelectorCommand
into a commonAddressSelectorCommand
class. Its implementation details use the commonAddressSelectorCommandProtocol
rather than the specifics of each model. - Now that
CountrySelectorViewModel
andStateSelectorViewModel
useAddressSelectorCommand
, these could be collapsed as well, but will be part of a different PR. - Expanded
setUp
andtearDown
methods toCountrySelectorViewModelTests
Testing instructions
We have not changed the functionality, but the following flow can be used to test the changes where these selectors are used:
- Go to
Orders
>+
>Create Order
> Fill the minimum necessary fields - Tap on
Add Customer Details
> Fill the minimum necessary fields - Confirm that the
Country
andState
fields works as expected by saving new or editing existing data, for example:
- Select US > Select a predefined
State
from the list. Save changes. - Select a non-US country, write down something in
State
, or leave it empty. Save Changes. - Tap on
Add a different shipping address
and fill outCountry
andState
again with different values. Save changes. - When tapping
Country
, confirm that the search bar at the top works by filtering countries. - When selecting US as
Country
and tappingState
, confirm that the search bar at the top works by filtering states.
- Confirm how the Order reflects all changes upon saving.
You can test the changes from this Pull Request by:
- Clicking here or scanning the QR code below to access App Center
- Then installing the build number
pr7713-4caaa7c
on your iPhone
This one from our pairing session fell through the cracks, sorry for that! I just fixed the .xcodeproj
conflicts and is ready to be reviewed when you have the time 🙇
@iamgabrielma nice one, more than 60 lines of code and we avoid duplicated code 👏 I left some non-blocking remarks in the code, let me know what you think. :shipit: