@@ -96,7 +96,7 @@ final class OrderDetailsViewModelTests: XCTestCase {
9696 storesManager. reset ( )
9797 XCTAssertEqual ( storesManager. receivedActions. count, 0 )
9898
99- let plugin = insertSystemPlugin ( name : SitePlugin . SupportedPlugin . LegacyWCShip, siteID: order. siteID, isActive: true )
99+ let plugin = insertSystemPlugin ( path : SitePlugin . SupportedPluginPath . LegacyWCShip, siteID: order. siteID, isActive: true )
100100 whenFetchingSystemPlugin ( thenReturn: plugin)
101101 whenSyncingShippingLabels ( thenReturn: . success( [ ] ) )
102102
@@ -108,13 +108,13 @@ final class OrderDetailsViewModelTests: XCTestCase {
108108
109109 // SystemStatusAction.fetchSystemPlugin
110110 let firstAction = try XCTUnwrap ( storesManager. receivedActions. first as? SystemStatusAction )
111- guard case let SystemStatusAction . fetchSystemPluginListWithNameList ( siteID, systemPluginNameList , _) = firstAction else {
111+ guard case let SystemStatusAction . fetchSystemPluginWithPath ( siteID, path , _) = firstAction else {
112112 XCTFail ( " Expected \( firstAction) to be \( SystemStatusAction . self) " )
113113 return
114114 }
115115
116116 XCTAssertEqual ( siteID, order. siteID)
117- XCTAssertEqual ( systemPluginNameList , [ SitePlugin . SupportedPlugin . LegacyWCShip] )
117+ XCTAssertEqual ( path , SitePlugin . SupportedPluginPath . LegacyWCShip)
118118
119119 // ShippingLabelAction.synchronizeShippingLabels
120120 let secondAction = try XCTUnwrap ( storesManager. receivedActions. last as? ShippingLabelAction )
@@ -143,7 +143,7 @@ final class OrderDetailsViewModelTests: XCTestCase {
143143 func test_checkShippingLabelCreationEligibility_with_a_non_virtual_product_returns_value_from_action( ) async throws {
144144 // Given
145145 configureOrderWithProductsInStorage ( products: [ . fake( ) . copy ( productID: 6 , virtual: false ) ] )
146- let plugin = insertSystemPlugin ( name : SitePlugin . SupportedPlugin . LegacyWCShip, siteID: order. siteID, isActive: true )
146+ let plugin = insertSystemPlugin ( path : SitePlugin . SupportedPluginPath . LegacyWCShip, siteID: order. siteID, isActive: true )
147147 whenFetchingSystemPlugin ( thenReturn: plugin)
148148 whenCheckingShippingLabelCreationEligibility ( thenReturn: true )
149149
@@ -174,7 +174,8 @@ final class OrderDetailsViewModelTests: XCTestCase {
174174 XCTAssertEqual ( storesManager. receivedActions. count, 0 )
175175
176176 // Make sure the are plugins synced
177- let plugin = insertSystemPlugin ( name: SitePlugin . SupportedPlugin. LegacyWCShip, siteID: order. siteID, isActive: true )
177+ let path = SitePlugin . SupportedPluginPath. LegacyWCShip
178+ let plugin = insertSystemPlugin ( path: path, siteID: order. siteID, isActive: true )
178179 whenFetchingSystemPlugin ( thenReturn: plugin)
179180 whenCheckingShippingLabelCreationEligibility ( thenReturn: true )
180181
@@ -186,13 +187,13 @@ final class OrderDetailsViewModelTests: XCTestCase {
186187
187188 // SystemStatusAction.fetchSystemPlugin
188189 let firstAction = try XCTUnwrap ( storesManager. receivedActions. first as? SystemStatusAction )
189- guard case let SystemStatusAction . fetchSystemPluginListWithNameList ( siteID, systemPluginNameList , _) = firstAction else {
190+ guard case let SystemStatusAction . fetchSystemPluginWithPath ( siteID: siteID , pluginPath : path , onCompletion : _) = firstAction else {
190191 XCTFail ( " Expected \( firstAction) to be \( SystemStatusAction . self) " )
191192 return
192193 }
193194
194195 XCTAssertEqual ( siteID, order. siteID)
195- XCTAssertEqual ( systemPluginNameList , [ SitePlugin . SupportedPlugin . LegacyWCShip] )
196+ XCTAssertEqual ( path , SitePlugin . SupportedPluginPath . LegacyWCShip)
196197
197198 // ShippingLabelAction.synchronizeShippingLabels
198199 let secondAction = try XCTUnwrap ( storesManager. receivedActions. last as? ShippingLabelAction )
@@ -430,7 +431,7 @@ final class OrderDetailsViewModelTests: XCTestCase {
430431 // Given
431432 let featureFlagService = MockFeatureFlagService ( revampedShippingLabelCreation: true )
432433 let viewModel = OrderDetailsViewModel ( order: order, stores: storesManager, storageManager: storageManager, featureFlagService: featureFlagService)
433- let plugin = insertSystemPlugin ( name : SitePlugin . SupportedPlugin . WooShipping [ 0 ] , siteID: order. siteID, isActive: true , version: " 1.0.5 " )
434+ let plugin = insertSystemPlugin ( path : SitePlugin . SupportedPluginPath . WooShipping, siteID: order. siteID, isActive: true , version: " 1.0.5 " )
434435 whenFetchingSystemPlugin ( thenReturn: plugin)
435436
436437 // When
@@ -444,7 +445,7 @@ final class OrderDetailsViewModelTests: XCTestCase {
444445 // Given
445446 let featureFlagService = MockFeatureFlagService ( revampedShippingLabelCreation: false )
446447 let viewModel = OrderDetailsViewModel ( order: order, stores: storesManager, storageManager: storageManager, featureFlagService: featureFlagService)
447- let plugin = insertSystemPlugin ( name : SitePlugin . SupportedPlugin . WooShipping [ 0 ] , siteID: order. siteID, isActive: true , version: " 1.0.5 " )
448+ let plugin = insertSystemPlugin ( path : SitePlugin . SupportedPluginPath . WooShipping, siteID: order. siteID, isActive: true , version: " 1.0.5 " )
448449 whenFetchingSystemPlugin ( thenReturn: plugin)
449450
450451 // When
@@ -458,7 +459,7 @@ final class OrderDetailsViewModelTests: XCTestCase {
458459 // Given
459460 let featureFlagService = MockFeatureFlagService ( revampedShippingLabelCreation: true )
460461 let viewModel = OrderDetailsViewModel ( order: order, stores: storesManager, storageManager: storageManager, featureFlagService: featureFlagService)
461- let plugin = insertSystemPlugin ( name : SitePlugin . SupportedPlugin . WooShipping [ 0 ] , siteID: order. siteID, isActive: false , version: " 1.0.5 " )
462+ let plugin = insertSystemPlugin ( path : SitePlugin . SupportedPluginPath . WooShipping, siteID: order. siteID, isActive: false , version: " 1.0.5 " )
462463 whenFetchingSystemPlugin ( thenReturn: plugin)
463464
464465 // When
@@ -472,7 +473,7 @@ final class OrderDetailsViewModelTests: XCTestCase {
472473 // Given
473474 let featureFlagService = MockFeatureFlagService ( revampedShippingLabelCreation: true )
474475 let viewModel = OrderDetailsViewModel ( order: order, stores: storesManager, storageManager: storageManager, featureFlagService: featureFlagService)
475- let plugin = insertSystemPlugin ( name : SitePlugin . SupportedPlugin . WooShipping [ 0 ] , siteID: order. siteID, isActive: false , version: " 1.0.4 " )
476+ let plugin = insertSystemPlugin ( path : SitePlugin . SupportedPluginPath . WooShipping, siteID: order. siteID, isActive: false , version: " 1.0.4 " )
476477 whenFetchingSystemPlugin ( thenReturn: plugin)
477478
478479 // When
@@ -491,6 +492,13 @@ private extension OrderDetailsViewModelTests {
491492 return plugin
492493 }
493494
495+ @discardableResult
496+ func insertSystemPlugin( path: String , siteID: Int64 , isActive: Bool , version: String ? = nil ) -> SystemPlugin {
497+ let plugin = SystemPlugin . fake ( ) . copy ( siteID: siteID, plugin: path, version: version, active: isActive)
498+ storageManager. insertSampleSystemPlugin ( readOnlySystemPlugin: plugin)
499+ return plugin
500+ }
501+
494502 func configureOrderWithProductsInStorage( products: [ Product ] ) {
495503 order = MockOrders ( ) . sampleOrder ( ) . copy ( items: products. map { OrderItem . fake ( ) . copy ( productID: $0. productID) } )
496504 viewModel = OrderDetailsViewModel ( order: order, stores: storesManager, storageManager: storageManager)
@@ -508,8 +516,10 @@ private extension OrderDetailsViewModelTests {
508516 onCompletion ( plugin)
509517 case let . fetchSystemPluginListWithNameList( _, _, onCompletion) :
510518 onCompletion ( plugin)
511- default :
512- break
519+ case let . fetchSystemPluginWithPath( _, _, onCompletion) :
520+ onCompletion ( plugin)
521+ default :
522+ break
513523 }
514524 }
515525 }
0 commit comments