@@ -2,12 +2,10 @@ package com.woocommerce.android.ui.woopos.localcatalog
22
33import com.woocommerce.android.tools.SelectedSite
44import com.woocommerce.android.ui.woopos.common.util.WooPosLogWrapper
5- import com.woocommerce.android.ui.woopos.featureflags.WooPosLocalCatalogM1Enabled
65import com.woocommerce.android.ui.woopos.util.WooPosCoroutineTestRule
76import com.woocommerce.android.ui.woopos.util.WooPosNetworkStatus
87import com.woocommerce.android.ui.woopos.util.datastore.WooPosPreferencesRepository
98import com.woocommerce.android.ui.woopos.util.datastore.WooPosSyncTimestampManager
10- import com.woocommerce.android.util.GetWooCorePluginCachedVersion
119import kotlinx.coroutines.ExperimentalCoroutinesApi
1210import kotlinx.coroutines.test.runTest
1311import org.assertj.core.api.Assertions.assertThat
@@ -33,17 +31,11 @@ class WooPosFullSyncStatusCheckerTest {
3331 private val syncTimestampManager: WooPosSyncTimestampManager = mock()
3432 private val selectedSite: SelectedSite = mock()
3533 private val networkStatus: WooPosNetworkStatus = mock()
36- private val wooPosLocalCatalogM1Enabled: WooPosLocalCatalogM1Enabled = mock()
3734 private val localCatalogStore: WooPosLocalCatalogStore = mock()
3835 private val wooPosLogWrapper: WooPosLogWrapper = mock()
3936 private val prefsRepo: WooPosPreferencesRepository = mock()
4037 private val checkCatalogSizeAction: WooPosCheckCatalogSizeAction = mock()
41- private val getWooVersion: GetWooCorePluginCachedVersion = mock()
42- private val variationsEndpointChecker: WooPosIsLocalCatalogVariationsEndpointAvailable =
43- WooPosIsLocalCatalogVariationsEndpointAvailable (
44- getWooVersion = getWooVersion,
45- logger = wooPosLogWrapper
46- )
38+ private val isLocalCatalogSupported: WooPosIsLocalCatalogSupported = mock()
4739
4840 private val siteModel = SiteModel ().apply {
4941 id = 123
@@ -54,21 +46,18 @@ class WooPosFullSyncStatusCheckerTest {
5446 syncTimestampManager = syncTimestampManager,
5547 selectedSite = selectedSite,
5648 networkStatus = networkStatus,
57- wooPosLocalCatalogM1Enabled = wooPosLocalCatalogM1Enabled,
5849 localCatalogStore = localCatalogStore,
5950 prefsRepo = prefsRepo,
6051 checkCatalogSizeAction = checkCatalogSizeAction,
61- isVariationsEndpointAvailable = variationsEndpointChecker ,
52+ isLocalCatalogSupported = isLocalCatalogSupported ,
6253 wooPosLogWrapper = wooPosLogWrapper
6354 )
6455
6556 @Before
6657 fun setup () = runTest {
6758 val recentTimestamp = System .currentTimeMillis() - 1 .days.inWholeMilliseconds
68- whenever(wooPosLocalCatalogM1Enabled()).thenReturn(true )
69- whenever(getWooVersion()).thenReturn(" 10.3.0" )
7059 whenever(selectedSite.getOrNull()).thenReturn(siteModel)
71- whenever(prefsRepo.isPeriodicSyncEnabledForSite(any() )).thenReturn(true )
60+ whenever(isLocalCatalogSupported(siteModel.siteId )).thenReturn(true )
7261 whenever(syncTimestampManager.getFullSyncLastCompletedTimestamp()).thenReturn(recentTimestamp)
7362 whenever(networkStatus.isConnected()).thenReturn(true )
7463 whenever(localCatalogStore.getProductCount(LocalOrRemoteId .LocalId (siteModel.id)))
@@ -78,10 +67,10 @@ class WooPosFullSyncStatusCheckerTest {
7867 }
7968
8069 @Test
81- fun `given feature flag disabled , when checkSyncRequirement called, then should return LocalCatalogDisabled` () =
70+ fun `given local catalog not supported , when checkSyncRequirement called, then should return LocalCatalogDisabled` () =
8271 runTest {
8372 // GIVEN
84- whenever(wooPosLocalCatalogM1Enabled( )).thenReturn(false )
73+ whenever(isLocalCatalogSupported(siteModel.siteId )).thenReturn(false )
8574
8675 val sut = createSut()
8776
@@ -106,21 +95,6 @@ class WooPosFullSyncStatusCheckerTest {
10695 // Exception is expected
10796 }
10897
109- @Test
110- fun `given periodic sync disabled for site, when checkSyncRequirement called, then should return LocalCatalogDisabled` () =
111- runTest {
112- // GIVEN
113- whenever(prefsRepo.isPeriodicSyncEnabledForSite(any())).thenReturn(false )
114-
115- val sut = createSut()
116-
117- // WHEN
118- val result = sut.checkSyncRequirement()
119-
120- // THEN
121- assertThat(result).isInstanceOf(WooPosFullSyncRequirement .LocalCatalogDisabled ::class .java)
122- }
123-
12498 @Test
12599 fun `given never synced before and network connected, when checkSyncRequirement called, then should return BlockingRequired` () =
126100 runTest {
@@ -254,36 +228,6 @@ class WooPosFullSyncStatusCheckerTest {
254228 assertThat(result).isEqualTo(WooPosFullSyncRequirement .NotRequired )
255229 }
256230
257- @Test
258- fun `given variations endpoint not available, when checkSyncRequirement called, then should return LocalCatalogDisabled` () =
259- runTest {
260- // GIVEN
261- whenever(getWooVersion()).thenReturn(" 10.2.0" ) // Version below 10.3.0
262-
263- val sut = createSut()
264-
265- // WHEN
266- val result = sut.checkSyncRequirement()
267-
268- // THEN
269- assertThat(result).isInstanceOf(WooPosFullSyncRequirement .LocalCatalogDisabled ::class .java)
270- }
271-
272- @Test
273- fun `given woo version null, when checkSyncRequirement called, then should return LocalCatalogDisabled` () =
274- runTest {
275- // GIVEN
276- whenever(getWooVersion()).thenReturn(null )
277-
278- val sut = createSut()
279-
280- // WHEN
281- val result = sut.checkSyncRequirement()
282-
283- // THEN
284- assertThat(result).isInstanceOf(WooPosFullSyncRequirement .LocalCatalogDisabled ::class .java)
285- }
286-
287231 @Test
288232 fun `given empty catalog and catalog too large, when checkSyncRequirement called, then should disable sync and return LocalCatalogDisabled` () =
289233 runTest {
0 commit comments