File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
WooCommerce/WooCommerceTests/ViewRelated/Orders/Order Creation Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -889,6 +889,32 @@ final class NewOrderViewModelTests: XCTestCase {
889889 XCTAssertTrue ( analytics. receivedEvents. isEmpty)
890890 }
891891
892+ func test_sync_failure_tracked_when_sync_fails( ) {
893+ // Given
894+ let analytics = MockAnalyticsProvider ( )
895+ let stores = MockStoresManager ( sessionManager: . testingInstance)
896+ let viewModel = NewOrderViewModel ( siteID: sampleSiteID, stores: stores, analytics: WooAnalytics ( analyticsProvider: analytics) )
897+
898+ // When
899+ waitForExpectation { expectation in
900+ stores. whenReceivingAction ( ofType: OrderAction . self) { action in
901+ switch action {
902+ case let . createOrder( _, _, onCompletion) :
903+ onCompletion ( . failure( NSError ( domain: " Error " , code: 0 ) ) )
904+ expectation. fulfill ( )
905+ default :
906+ XCTFail ( " Received unsupported action: \( action) " )
907+ }
908+ }
909+
910+ // When remote sync is triggered
911+ viewModel. saveShippingLine ( ShippingLine . fake ( ) )
912+ }
913+
914+ // Then
915+ XCTAssertTrue ( analytics. receivedEvents. contains ( WooAnalyticsStat . orderSyncFailed. rawValue) )
916+ }
917+
892918 // MARK: -
893919
894920 func test_customer_note_section_is_updated_when_note_is_added_to_order( ) {
You can’t perform that action at this time.
0 commit comments