diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/sitepicker/SitePickerViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/sitepicker/SitePickerViewModel.kt index 6c60dc24bdb..3abf64135cd 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/sitepicker/SitePickerViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/sitepicker/SitePickerViewModel.kt @@ -337,7 +337,10 @@ class SitePickerViewModel @Inject constructor( loadAndDisplaySites() } ) - sitePickerViewState = sitePickerViewState.copy(isSkeletonViewVisible = false, isPrimaryBtnVisible = true) + sitePickerViewState = sitePickerViewState.copy( + isSkeletonViewVisible = false, + isPrimaryBtnVisible = sites.value!!.any { it is WooSiteUiModel } + ) } private fun loadWooNotFoundView(site: SiteModel) { diff --git a/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/sitepicker/SitePickerViewModelTest.kt b/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/sitepicker/SitePickerViewModelTest.kt index 26088227c0c..65eb575f4b3 100644 --- a/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/sitepicker/SitePickerViewModelTest.kt +++ b/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/sitepicker/SitePickerViewModelTest.kt @@ -376,6 +376,31 @@ class SitePickerViewModelTest : BaseUnitTest() { assertThat(viewModel.event.value).isEqualTo(NavigateToAccountMismatchScreen(CONNECT_JETPACK, url)) } + @Test + fun `given the site address does not match the user account and there is no woo site, continue button is hidden`() = + testBlocking { + givenThatUserLoggedInFromEnteringSiteAddress(null) + whenever(repository.fetchSiteInfo(any())).thenReturn( + Result.success( + ConnectSiteInfoPayload( + url = SitePickerTestUtils.loginSiteAddress, + isWordPress = true, + isWPCom = false + ) + ) + ) + val nonWooSite = SiteModel().apply { + id = 1 + siteId = 1 + hasWooCommerce = false + } + val siteList = listOf(nonWooSite) + whenSitesAreFetched(sitesFromApi = siteList, sitesFromDb = siteList) + whenViewModelIsCreated() + + assertThat(viewModel.sitePickerViewState.isPrimaryBtnVisible).isEqualTo(false) + } + @Test fun `given that the site address entered during login does not have Woo, no woo error screen is displayed`() = testBlocking {