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
AddressSelectorCommandProtocolthatCountryandStateOfACountryconforms to (These are typealiases ofNetworking.CountryandNetworking.StateOfACountryrespectively) - Collapse
CountrySelectorCommandandStateSelectorCommandinto a commonAddressSelectorCommandclass. Its implementation details use the commonAddressSelectorCommandProtocolrather than the specifics of each model. - Now that
CountrySelectorViewModelandStateSelectorViewModeluseAddressSelectorCommand, these could be collapsed as well, but will be part of a different PR. - Expanded
setUpandtearDownmethods 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
CountryandStatefields works as expected by saving new or editing existing data, for example:
- Select US > Select a predefined
Statefrom 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 addressand fill outCountryandStateagain with different values. Save changes. - When tapping
Country, confirm that the search bar at the top works by filtering countries. - When selecting US as
Countryand 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-4caaa7con 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: