-
Notifications
You must be signed in to change notification settings - Fork 121
Customer search: Fill customer fields on Order screen #7885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
iamgabrielma
merged 17 commits into
trunk
from
issue/7741-fill-order-data-from-customer-search
Nov 1, 2022
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5869ec0
fill Customer fields on Order screen
iamgabrielma d7060dc
Merge branch 'trunk' into issue/7741-fill-order-data-from-customer-se…
iamgabrielma e05a33d
Add shipping fields to EditAddressOrderForm
iamgabrielma db2fb24
Add CustomerSearchUICommand unit tests
iamgabrielma 5419298
Hound: trailing_newline
iamgabrielma fae8db5
Internal comment cleanup
iamgabrielma dff4aed
Skip searchCustomer request for customerID = 0
iamgabrielma 64cb6fe
Remove unnecessary method
iamgabrielma c5fbc90
Add empty view for empty search results
iamgabrielma 1733984
Set empty state for new keyword searches
iamgabrielma 9cf8388
Extract fillCustomerFields method to viewModel
iamgabrielma ed04317
Add Unit Test for fillCustomerFields()
iamgabrielma 5dffa97
Display shipping details form if addresses differ
iamgabrielma 7b58531
Add/improve test case for unregistered customer
iamgabrielma 121ba8a
Populate fields with Address details, not Customer
iamgabrielma d343863
Update WCAnalyticsCustomerMapperTests
iamgabrielma 2b772b7
Update EdirOrderAddressFormViewModel tests
iamgabrielma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Networking/NetworkingTests/Responses/wc-analytics-customers.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,24 @@ | ||
| { "data": | ||
| [ | ||
| { | ||
| "id":0, | ||
| "user_id":0, | ||
| "username":"Matt.the.unregistered", | ||
| "name":"Matt The Unregistered", | ||
| "email":"[email protected]", | ||
| "country":"US", | ||
| "city":"San Francisco", | ||
| "state":"CA", | ||
| "postcode":"94103", | ||
| "date_registered":null, | ||
| "date_last_active":"2022-07-12T08:36:54", | ||
| "date_last_order":"2022-07-12 08:36:54", | ||
| "orders_count":1, | ||
| "total_spend":10, | ||
| "avg_order_value":10, | ||
| "date_registered_gmt":null, | ||
| "date_last_active_gmt":"2022-07-12T08:36:54" | ||
| }, | ||
| { | ||
| "id":1, | ||
| "user_id":1, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -716,6 +716,76 @@ final class EditOrderAddressFormViewModelTests: XCTestCase { | |
| // Then | ||
| XCTAssertEqual(notice, AddressFormViewModel.NoticeFactory.createInvalidEmailNotice()) | ||
| } | ||
|
|
||
| func test_OrderAddressForm_billing_fields_are_updated_when_customerSelectedFromSearch() { | ||
| // Given | ||
| let viewModel = EditOrderAddressFormViewModel(order: Order.fake(), type: .billing) | ||
| let customer = Customer.fake().copy( | ||
| email: "[email protected]", | ||
| firstName: "Johnny", | ||
| lastName: "Appleseed", | ||
| billing: sampleAddressWithEmptyNullableFields(), | ||
| shipping: sampleAddressWithEmptyNullableFields() | ||
| ) | ||
|
|
||
| // When | ||
| viewModel.customerSelectedFromSearch(customer: customer) | ||
|
|
||
| // Then | ||
| XCTAssertEqual(viewModel.fields.email, customer.billing?.email) | ||
| XCTAssertEqual(viewModel.fields.firstName, customer.firstName) | ||
| XCTAssertEqual(viewModel.fields.lastName, customer.lastName) | ||
| XCTAssertEqual(viewModel.fields.company, customer.billing?.company) | ||
| XCTAssertEqual(viewModel.fields.address1, customer.billing?.address1) | ||
| XCTAssertEqual(viewModel.fields.address2, customer.billing?.address2) | ||
| XCTAssertEqual(viewModel.fields.city, customer.billing?.city) | ||
| XCTAssertEqual(viewModel.fields.state, customer.billing?.state) | ||
| XCTAssertEqual(viewModel.fields.postcode, customer.billing?.postcode) | ||
| XCTAssertEqual(viewModel.fields.country, customer.billing?.country) | ||
| XCTAssertEqual(viewModel.fields.phone, customer.billing?.phone) | ||
| } | ||
|
|
||
| func test_OrderAddressForm_shipping_fields_are_updated_when_customerSelectedFromSearch() { | ||
| // Given | ||
| let viewModel = EditOrderAddressFormViewModel(order: Order.fake(), type: .shipping) | ||
| let customer = Customer.fake().copy( | ||
| email: "[email protected]", | ||
| firstName: "Johnny", | ||
| lastName: "Appleseed", | ||
| billing: sampleAddressWithEmptyNullableFields(), | ||
| shipping: sampleAddressWithEmptyNullableFields() | ||
| ) | ||
|
|
||
| // When | ||
| viewModel.customerSelectedFromSearch(customer: customer) | ||
|
|
||
| // Then | ||
| XCTAssertEqual(viewModel.fields.email, customer.shipping?.email) | ||
| XCTAssertEqual(viewModel.fields.firstName, customer.firstName) | ||
| XCTAssertEqual(viewModel.fields.lastName, customer.lastName) | ||
| XCTAssertEqual(viewModel.fields.company, customer.shipping?.company) | ||
| XCTAssertEqual(viewModel.fields.address1, customer.shipping?.address1) | ||
| XCTAssertEqual(viewModel.fields.address2, customer.shipping?.address2) | ||
| XCTAssertEqual(viewModel.fields.city, customer.shipping?.city) | ||
| XCTAssertEqual(viewModel.fields.state, customer.shipping?.state) | ||
| XCTAssertEqual(viewModel.fields.postcode, customer.shipping?.postcode) | ||
| XCTAssertEqual(viewModel.fields.country, customer.shipping?.country) | ||
| XCTAssertEqual(viewModel.fields.phone, customer.shipping?.phone) | ||
| } | ||
|
|
||
| func test_OrderAddressForm_shows_different_address_form_fields_when_addresses_differ_and_customerSelectedFromSearch() { | ||
| // Given | ||
| let viewModel = EditOrderAddressFormViewModel(order: Order.fake(), type: .billing) | ||
| let billing = sampleAddressWithEmptyNullableFields() | ||
| let shipping = Address.fake().copy(address1: "123 different fake street") | ||
| let customer = Customer.fake().copy(billing: billing, shipping: shipping) | ||
|
|
||
| // When | ||
| viewModel.customerSelectedFromSearch(customer: customer) | ||
|
|
||
| // Then | ||
| XCTAssertTrue(viewModel.showDifferentAddressForm) | ||
| } | ||
|
Comment on lines
+776
to
+788
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👏👏👏 So good to be able to test this kind of thing with confidence |
||
| } | ||
|
|
||
| private extension EditOrderAddressFormViewModelTests { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can move to the view model too if you like? Can wait for a future PR