Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

22.1
-----
- [*] Order Creation: Resolved an issue where the exit confirmation was not displayed when there were unsaved changes in a split view [https://github.com/woocommerce/woocommerce-ios/pull/15394].
- [*] Order Creation: Fixed an issue where order recalculation would stop working after canceling a confirmation with unsaved changes [https://github.com/woocommerce/woocommerce-ios/pull/15392].
- [internal] Improve data fetching in Order Details, to avoid I/O performance on the main thread. [https://github.com/woocommerce/woocommerce-ios/pull/14999]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ final class EditableOrderViewModel: ObservableObject {
switch flow {
case .creation: // Creation can be dismissed when there aren't changes pending to commit.
return !hasChanges
case .editing: // Editing can always be dismissed because changes are committed instantly.
return true
case .editing:
// In a single-view layout: Editing can always be dismissed because changes are committed instantly.
// In a split-view layout: Editing can be dismissed when there aren't product changes pending to recalculate.
return !(selectionSyncApproach == .onRecalculateButtonTap && syncRequired)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ private extension OrderFormHostingController {
}

func discardOrderAndDismiss() {
viewModel.discardOrder()
if viewModel.flow == .creation {
viewModel.discardOrder()
}
dismiss(animated: true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
</CommandLineArgument>
<CommandLineArgument
argument = "-simulate-stripe-card-reader"
isEnabled = "NO">
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "-force-crash-logging 1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3312,6 +3312,45 @@ final class EditableOrderViewModelTests: XCTestCase {
assertEqual(customerData.billing, orderToUpdate.billingAddress)
assertEqual(customerData.shipping, orderToUpdate.shippingAddress)
}

func test_canBeDismissed_whenEditing_withNoChanges_returnsTrue() {
// Given
let initialOrder = Order.fake()
let viewModel = EditableOrderViewModel(siteID: 123, flow: .editing(initialOrder: initialOrder))

// When
viewModel.selectionSyncApproach = .onRecalculateButtonTap
viewModel.syncRequired = false

// Then
XCTAssertTrue(viewModel.canBeDismissed)
}

func test_canBeDismissed_whenEditing_withPendingRecalculation_returnsFalse() {
// Given
let initialOrder = Order.fake()
let viewModel = EditableOrderViewModel(siteID: 123, flow: .editing(initialOrder: initialOrder))

// When
viewModel.selectionSyncApproach = .onRecalculateButtonTap
viewModel.syncRequired = true

// Then
XCTAssertFalse(viewModel.canBeDismissed)
}

func test_canBeDismissed_whenEditing_withImmediateSync_returnsTrue() {
// Given
let initialOrder = Order.fake()
let viewModel = EditableOrderViewModel(siteID: 123, flow: .editing(initialOrder: initialOrder))

// When
viewModel.selectionSyncApproach = .immediate
viewModel.syncRequired = true

// Then
XCTAssertTrue(viewModel.canBeDismissed)
}
}

private extension EditableOrderViewModelTests {
Expand Down