-
Notifications
You must be signed in to change notification settings - Fork 133
[Shipping Labels] Handle marking orders as complete #14321
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
base: release/22.8
Are you sure you want to change the base?
[Shipping Labels] Handle marking orders as complete #14321
Conversation
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
8e53d76
to
a377995
Compare
a377995
to
32d1294
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/22.8 #14321 +/- ##
==================================================
+ Coverage 37.64% 37.66% +0.01%
- Complexity 9082 9086 +4
==================================================
Files 1980 1981 +1
Lines 111396 111431 +35
Branches 14680 14686 +6
==================================================
+ Hits 41940 41970 +30
+ Misses 65618 65615 -3
- Partials 3838 3846 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@@ -154,7 +154,7 @@ class WooShippingLabelRestClient @Inject constructor( | |||
selectedRate: RateDTO, | |||
parentRate: RateDTO?, | |||
selectedRateOptions: Map<WooShippingRateModel.Option, ShippingRateSurchargeDTO>, | |||
markOrderComplete: Boolean, | |||
lastOrderCompleted: Boolean, |
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 argument indicates whether the user has enabled the option and is used to update the account settings, so I renamed it to a clearer name.
onBlocking { | ||
invoke(any(), any(), any(), any(), any(), any(), any(), any(), any(), isNull(), isNull()) | ||
} doReturn Result.success( | ||
PurchasedLabelData( | ||
labels = listOf(shippingLabelModel.copy(status = PURCHASED)), | ||
origin = emptyMap(), | ||
destination = emptyMap(), | ||
rates = emptyMap() | ||
) | ||
) |
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.
I moved the default initialization to the mock declaration and then removed it from the tests, this reduces code duplication.
val ratesState = ( | ||
sut.viewState.runAndCaptureValues { | ||
sut.onPackageSelected(defaultPackageData) | ||
advanceUntilIdle() | ||
}.last() as DataState | ||
).shipmentUIList.first().shippingRatesState as ShippingRatesState.DataState | ||
val ratesState = sut.viewState.runAndCaptureValues { | ||
sut.onPackageSelected(defaultPackageData) | ||
advanceUntilIdle() | ||
}.last().let { viewState -> | ||
(viewState as DataState).shipmentUIList.first().shippingRatesState as ShippingRatesState.DataState | ||
} |
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.
I just improved the formatting here and in similar sections. The parentheses made the code harder to read, and I overlooked them when I first added them.
...e/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/MarkOrderAsComplete.kt
Outdated
Show resolved
Hide resolved
...e/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/MarkOrderAsComplete.kt
Outdated
Show resolved
Hide resolved
...c/test/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/MarkOrderAsCompleteTest.kt
Outdated
Show resolved
Hide resolved
...c/test/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/MarkOrderAsCompleteTest.kt
Outdated
Show resolved
Hide resolved
whenever(markOrderAsComplete(orderId)) doReturn Result.success(Unit) | ||
whenever(observeShippingLabelStatus(eq(orderId), any())) doReturn flowOf( | ||
ObserveShippingLabelStatus.ObserveShippingLabelStatusResult( | ||
status = PURCHASED, | ||
shippingLabelModel = shippingLabelModel.copy(status = PURCHASED) | ||
) | ||
) |
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.
Suggestion: We can add these mocks for markOrderAsComplete
and observeShippingLabelStatus
to the global definitions like you did for the purchaseShippingLabel
mock.
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.
I didn't move these because they are not used in many tests, and also for the observeShippingLabelStatus
returning the PURCHASED
status doesn't seem like a default behavior. WDYT about this thought?
...lin/com/woocommerce/android/ui/orders/wooshippinglabels/WooShippingLabelCreationViewModel.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Irfan Ömür <[email protected]>
Co-authored-by: Irfan Ömür <[email protected]>
Thanks @irfano for the review, I applied all your suggestions except one where I shared my opinion. Regarding the |
Closes WOOMOB-797
Description
This PR implements the logic of marking orders as complete when purchasing a shipping label, it also adds logic to set the default value of the toggle using the account settings, to match the web behavior.
Steps to reproduce
Happy path
Unhappy path
1. Import the following config to the Api Faker
Default value of the toggle
Confirm that the toggle uses the value that was used in last purchase.
Testing information
The above TCs have all the details
The tests that have been performed
The above.
RELEASE-NOTES.txt
if necessary. Use the "[Internal]" label for non-user-facing changes.