Repository: wordpress-mobile/WordPress-Android (language: kotlin)

Issue:
🤖 Link up the purchase domain screen to the flow
Link up the implemented "Purchase Domain" screen UI https://github.com/wordpress-mobile/WordPress-Android/pull/19332 to the flow


Discussion hints:

Pull request: Attach Purchase Domain screen to Domain Search flow
Fixes #19502

The PR adds the Purchase Domain screen to the existing flow. 

Note: I also converted `PurchaseDomainViewModel` to assisted injection-friendly implementation for passing domain id to the viewmodel's parameters, which makes the class easily testable. I wasn't sure if we needed the entire `ProposedDomain` entity for passing a selected domain through the further steps, but it should be easy to replace an ID with an entire `ProposedDomain` entity if needed.

To test:
- Make sure you have enabled domain_management feature flag
- Go to "Me" tab -> Domains -> Plus (+) button
- On the "Search for a domain" screen type any query to the text input
- Tap on any domain suggestion
- [x] Make sure you are navigated to the "Purchase Domain" screen

https://github.com/wordpress-mobile/WordPress-Android/assets/16563318/ed0a8b2a-d25b-4dd7-892c-f89323652f29

## Regression Notes
1. Potential unintended areas of impact
Purchase Domain screen since modified the ViewModel implementation

2. What I did to test those areas of impact (or what existing automated tests I relied on)
Manual testing

3. What automated tests I added (or what prevented me from doing so)
N/A

PR submission checklist:

- [x] I have completed the Regression Notes.
- [x] I have considered adding accessibility improvements for my changes.
- [x] I have considered if this change warrants user-facing release notes and have added them to `RELEASE-NOTES.txt` if necessary.

UI Changes testing checklist:

- [ ] Portrait and landscape orientations.
- [ ] Light and dark modes.
- [ ] Fonts: Larger, smaller and bold text.
- [ ] High contrast.
- [ ] Talkback.
- [ ] Languages with large words or with letters/accents not frequently used in English.
- [ ] Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
- [ ] Large and small screen sizes. (Tablet and smaller phones)
- [ ] Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)


Test command: ./gradlew :WordPress:testWordpressVanillaDebugUnitTest --tests "org.wordpress.android.ui.domains.management.purchasedomain.PurchaseDomainViewModelTest" --tests "org.wordpress.android.ui.domains.management.newdomainsearch.domainsfetcher.NewDomainsSearchRepositoryTest" --tests "org.wordpress.android.ui.domains.management.newdomainsearch.NewDomainSearchViewModelTest"

Fix patch:
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ActivityNavigator.kt b/WordPress/src/main/java/org/wordpress/android/ui/ActivityNavigator.kt
index 9ae93dd4e3b6..c6e3cc7aea9e 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/ActivityNavigator.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/ActivityNavigator.kt
@@ -11,6 +11,10 @@ import org.wordpress.android.ui.blaze.blazecampaigns.campaignlisting.CampaignLis
 import org.wordpress.android.ui.blaze.blazepromote.ARG_BLAZE_FLOW_SOURCE
 import org.wordpress.android.ui.blaze.blazepromote.ARG_BLAZE_SHOULD_SHOW_OVERLAY
 import org.wordpress.android.ui.blaze.blazepromote.BlazePromoteParentActivity
+import org.wordpress.android.ui.domains.management.purchasedomain.PurchaseDomainActivity
+import org.wordpress.android.ui.domains.management.purchasedomain.PurchaseDomainActivity.Companion.PICKED_DOMAIN_KEY
+import org.wordpress.android.ui.domains.management.purchasedomain.PurchaseDomainActivity.Companion.PICKED_DOMAIN_PRIVACY
+import org.wordpress.android.ui.domains.management.purchasedomain.PurchaseDomainActivity.Companion.PICKED_PRODUCT_ID
 import org.wordpress.android.ui.mysite.menu.KEY_QUICK_START_EVENT
 import org.wordpress.android.ui.mysite.menu.MenuActivity
 import org.wordpress.android.ui.mysite.personalization.PersonalizationActivity
@@ -79,4 +83,13 @@ class ActivityNavigator @Inject constructor() {
         }
         context.startActivity(Intent(context, MenuActivity::class.java))
     }
+
+    fun openPurchaseDomain(context: Context, productId: Int, domainName: String, domainSupportsPrivacy: Boolean) {
+        context.startActivity(
+            Intent(context, PurchaseDomainActivity::class.java)
+                .putExtra(PICKED_PRODUCT_ID, productId)
+                .putExtra(PICKED_DOMAIN_KEY, domainName)
+                .putExtra(PICKED_DOMAIN_PRIVACY, domainSupportsPrivacy)
+        )
+    }
 }
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/NewDomainSearchActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/NewDomainSearchActivity.kt
index fc37ca4006f7..ceab64625fb9 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/NewDomainSearchActivity.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/NewDomainSearchActivity.kt
@@ -45,8 +45,9 @@ class NewDomainSearchActivity : AppCompatActivity() {
 
     private fun handleActionEvents(actionEvent: NewDomainSearchViewModel.ActionEvent) {
         when (actionEvent) {
-            is NewDomainSearchViewModel.ActionEvent.PurchaseDomain -> { /* TODO */
-            }
+            is NewDomainSearchViewModel.ActionEvent.PurchaseDomain -> activityNavigator.openPurchaseDomain(
+                this, actionEvent.productId, actionEvent.domain, actionEvent.supportsPrivacy
+            )
 
             is NewDomainSearchViewModel.ActionEvent.TransferDomain -> activityNavigator.openDomainTransfer(
                 this, actionEvent.url
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/NewDomainSearchViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/NewDomainSearchViewModel.kt
index 2c6711efb4c8..9c79f4b6a217 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/NewDomainSearchViewModel.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/NewDomainSearchViewModel.kt
@@ -77,7 +77,13 @@ class NewDomainSearchViewModel @Inject constructor(
             mapOf("domain_name" to domain.domain)
         )
         launch {
-            _actionEvents.emit(ActionEvent.PurchaseDomain(domain))
+            _actionEvents.emit(
+                ActionEvent.PurchaseDomain(
+                    productId = domain.productId,
+                    domain = domain.domain,
+                    supportsPrivacy = domain.supportsPrivacy
+                )
+            )
         }
     }
 
@@ -88,7 +94,11 @@ class NewDomainSearchViewModel @Inject constructor(
     }
 
     sealed class ActionEvent {
-        data class PurchaseDomain(val domain: ProposedDomain) : ActionEvent()
+        data class PurchaseDomain(
+            val productId: Int,
+            val domain: String,
+            val supportsPrivacy: Boolean
+        ) : ActionEvent()
         data class TransferDomain(val url: String) : ActionEvent()
         object GoBack : ActionEvent()
     }
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/composable/NewDomainSearchScreen.kt b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/composable/NewDomainSearchScreen.kt
index de67eab60f6e..09c92a4ecabe 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/composable/NewDomainSearchScreen.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/composable/NewDomainSearchScreen.kt
@@ -231,12 +231,14 @@ fun NewDomainSearchScreenPreview() {
                     domain = "example.com",
                     price = "USD 100",
                     salePrice = "USD 30",
+                    supportsPrivacy = true,
                 ),
                 ProposedDomain(
                     productId = 0,
                     domain = "example.blog",
                     price = "USD 100",
                     salePrice = null,
+                    supportsPrivacy = true,
                 ),
             )
         ),
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/domainsfetcher/NewDomainsSearchRepository.kt b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/domainsfetcher/NewDomainsSearchRepository.kt
index 5d2400a8fb98..cdfcb1589a03 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/domainsfetcher/NewDomainsSearchRepository.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/domainsfetcher/NewDomainsSearchRepository.kt
@@ -50,6 +50,7 @@ class NewDomainsSearchRepository @Inject constructor(
                         domain = domain.domain_name,
                         price = domain.cost,
                         salePrice = product?.combinedSaleCostDisplay,
+                        supportsPrivacy = domain.supports_privacy
                     )
                 }
             DomainsResult.Success(suggestions)
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/domainsfetcher/ProposedDomain.kt b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/domainsfetcher/ProposedDomain.kt
index dfaa01a83e8b..61971ac1ccd8 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/domainsfetcher/ProposedDomain.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/newdomainsearch/domainsfetcher/ProposedDomain.kt
@@ -4,7 +4,8 @@ data class ProposedDomain(
     val productId: Int,
     val domain: String,
     val price: String,
-    val salePrice: String?
+    val salePrice: String?,
+    val supportsPrivacy: Boolean,
 ) {
     val domainSuffix: String
         get() = domain.split('.').last()
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/purchasedomain/PurchaseDomainActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/purchasedomain/PurchaseDomainActivity.kt
index f1a1856f921e..cd1d0a6502cf 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/purchasedomain/PurchaseDomainActivity.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/purchasedomain/PurchaseDomainActivity.kt
@@ -11,14 +11,26 @@ import kotlinx.coroutines.flow.onEach
 import org.wordpress.android.ui.domains.management.M3Theme
 import org.wordpress.android.ui.domains.management.purchasedomain.PurchaseDomainViewModel.ActionEvent.GoBack
 import org.wordpress.android.ui.domains.management.purchasedomain.PurchaseDomainViewModel.ActionEvent.GoToDomainPurchasing
-import org.wordpress.android.ui.domains.management.purchasedomain.PurchaseDomainViewModel.ActionEvent.GoToExistingDomain
+import org.wordpress.android.ui.domains.management.purchasedomain.PurchaseDomainViewModel.ActionEvent.GoToExistingSite
 import org.wordpress.android.ui.domains.management.purchasedomain.composable.PurchaseDomainScreen
+import javax.inject.Inject
 
 private typealias NotImplemented = Unit
 
 @AndroidEntryPoint
 class PurchaseDomainActivity : AppCompatActivity() {
-    private val viewModel: PurchaseDomainViewModel by viewModels()
+    @Inject
+    lateinit var viewModelFactory: PurchaseDomainViewModel.Factory
+
+    private val viewModel: PurchaseDomainViewModel by viewModels {
+        PurchaseDomainViewModel.provideFactory(viewModelFactory, productArg, domainArg, privacyArg)
+    }
+
+    private val productArg: Int get() = intent.getIntExtra(PICKED_PRODUCT_ID, 0)
+
+    private val domainArg: String get() = intent.getStringExtra(PICKED_DOMAIN_KEY) ?: error("Domain cannot be null.")
+
+    private val privacyArg: Boolean get() = intent.getBooleanExtra(PICKED_DOMAIN_PRIVACY, false)
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
@@ -26,7 +38,7 @@ class PurchaseDomainActivity : AppCompatActivity() {
             M3Theme {
                 PurchaseDomainScreen(
                     onNewDomainCardSelected = viewModel::onNewDomainSelected,
-                    onExistingDomainCardSelected = viewModel::onExistingDomainSelected,
+                    onExistingSiteCardSelected = viewModel::onExistingSiteSelected,
                     onBackPressed = viewModel::onBackPressed,
                 )
             }
@@ -40,9 +52,15 @@ class PurchaseDomainActivity : AppCompatActivity() {
 
     private fun handleActionEvents(actionEvent: PurchaseDomainViewModel.ActionEvent) {
         when (actionEvent) {
+            is GoToDomainPurchasing -> NotImplemented
+            is GoToExistingSite -> NotImplemented
             GoBack -> onBackPressedDispatcher.onBackPressed()
-            GoToDomainPurchasing -> NotImplemented
-            GoToExistingDomain -> NotImplemented
         }
     }
+
+    companion object {
+        const val PICKED_PRODUCT_ID: String = "picked_product_id"
+        const val PICKED_DOMAIN_KEY: String = "picked_domain_key"
+        const val PICKED_DOMAIN_PRIVACY: String = "picked_domain_privacy"
+    }
 }
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/purchasedomain/PurchaseDomainViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/purchasedomain/PurchaseDomainViewModel.kt
index ded1ed2d991e..57446e99e186 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/purchasedomain/PurchaseDomainViewModel.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/purchasedomain/PurchaseDomainViewModel.kt
@@ -1,6 +1,10 @@
 package org.wordpress.android.ui.domains.management.purchasedomain
 
-import dagger.hilt.android.lifecycle.HiltViewModel
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.ViewModelProvider
+import dagger.assisted.Assisted
+import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
 import kotlinx.coroutines.CoroutineDispatcher
 import kotlinx.coroutines.flow.Flow
 import kotlinx.coroutines.flow.MutableSharedFlow
@@ -8,13 +12,14 @@ import org.wordpress.android.analytics.AnalyticsTracker.Stat
 import org.wordpress.android.modules.UI_THREAD
 import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper
 import org.wordpress.android.viewmodel.ScopedViewModel
-import javax.inject.Inject
 import javax.inject.Named
 
-@HiltViewModel
-class PurchaseDomainViewModel @Inject constructor(
+class PurchaseDomainViewModel @AssistedInject constructor(
     @Named(UI_THREAD) private val mainDispatcher: CoroutineDispatcher,
-    private val analyticsTracker: AnalyticsTrackerWrapper
+    private val analyticsTracker: AnalyticsTrackerWrapper,
+    @Assisted private val productId: Int,
+    @Assisted private val domain: String,
+    @Assisted private val privacy: Boolean,
 ) : ScopedViewModel(mainDispatcher) {
     private val _actionEvents = MutableSharedFlow<ActionEvent>()
     val actionEvents: Flow<ActionEvent> = _actionEvents
@@ -26,14 +31,14 @@ class PurchaseDomainViewModel @Inject constructor(
     fun onNewDomainSelected() {
         analyticsTracker.track(Stat.DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_NEW_DOMAIN_TAPPED)
         launch {
-            _actionEvents.emit(ActionEvent.GoToDomainPurchasing)
+            _actionEvents.emit(ActionEvent.GoToDomainPurchasing(domain = domain))
         }
     }
 
-    fun onExistingDomainSelected() {
-        analyticsTracker.track(Stat.DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_EXISTING_DOMAIN_TAPPED)
+    fun onExistingSiteSelected() {
+        analyticsTracker.track(Stat.DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_EXISTING_SITE_TAPPED)
         launch {
-            _actionEvents.emit(ActionEvent.GoToExistingDomain)
+            _actionEvents.emit(ActionEvent.GoToExistingSite(domain = domain))
         }
     }
 
@@ -45,7 +50,21 @@ class PurchaseDomainViewModel @Inject constructor(
 
     sealed class ActionEvent {
         object GoBack : ActionEvent()
-        object GoToDomainPurchasing : ActionEvent()
-        object GoToExistingDomain : ActionEvent()
+        data class GoToDomainPurchasing(val domain: String) : ActionEvent()
+        data class GoToExistingSite(val domain: String) : ActionEvent()
+    }
+
+    @AssistedFactory
+    interface Factory {
+        fun create(productId: Int, domain: String, privacy: Boolean): PurchaseDomainViewModel
+    }
+
+    companion object {
+        fun provideFactory(assistedFactory: Factory, productId: Int, domain: String, privacy: Boolean) =
+            object : ViewModelProvider.Factory {
+                @Suppress("UNCHECKED_CAST")
+                override fun <T : ViewModel> create(modelClass: Class<T>): T =
+                    assistedFactory.create(productId, domain, privacy) as T
+            }
     }
 }
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/purchasedomain/composable/PurchaseDomainScreen.kt b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/purchasedomain/composable/PurchaseDomainScreen.kt
index 9b79768d7f9b..892229fde584 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/domains/management/purchasedomain/composable/PurchaseDomainScreen.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/domains/management/purchasedomain/composable/PurchaseDomainScreen.kt
@@ -44,7 +44,7 @@ import org.wordpress.android.ui.domains.management.success
 @Composable
 fun PurchaseDomainScreen(
     onNewDomainCardSelected: () -> Unit,
-    onExistingDomainCardSelected: () -> Unit,
+    onExistingSiteCardSelected: () -> Unit,
     onBackPressed: () -> Unit,
     modifier: Modifier = Modifier
 ) {
@@ -80,7 +80,7 @@ fun PurchaseDomainScreen(
                 ) {
                     ScreenHeader()
                     ScreenDescription()
-                    DomainCards(onNewDomainCardSelected, onExistingDomainCardSelected)
+                    DomainCards(onNewDomainCardSelected, onExistingSiteCardSelected)
                     DiscountNotice()
                 }
             }
@@ -91,7 +91,7 @@ fun PurchaseDomainScreen(
 @Composable
 private fun DomainCards(
     onNewDomainCardSelected: () -> Unit,
-    onExistingDomainCardSelected: () -> Unit,
+    onExistingSiteCardSelected: () -> Unit,
     modifier: Modifier = Modifier,
 ) {
     Box(modifier = modifier.padding(top = 24.dp)) {
@@ -99,12 +99,12 @@ private fun DomainCards(
         if (isPortrait) {
             Column(verticalArrangement = arrangement) {
                 NewDomainCard(onNewDomainCardSelected)
-                ExistingDomainCard(onExistingDomainCardSelected)
+                ExistingSiteCard(onExistingSiteCardSelected)
             }
         } else {
             Row(horizontalArrangement = arrangement) {
                 NewDomainCard(onNewDomainCardSelected, modifier = Modifier.weight(1f))
-                ExistingDomainCard(onExistingDomainCardSelected, modifier = Modifier.weight(1f))
+                ExistingSiteCard(onExistingSiteCardSelected, modifier = Modifier.weight(1f))
             }
         }
     }
@@ -163,8 +163,8 @@ private fun NewDomainCard(
 }
 
 @Composable
-private fun ExistingDomainCard(
-    onExistingDomainCardSelected: () -> Unit,
+private fun ExistingSiteCard(
+    onExistingSiteCardSelected: () -> Unit,
     modifier: Modifier = Modifier
 ) {
     DomainOptionCard(
@@ -172,7 +172,7 @@ private fun ExistingDomainCard(
         title = R.string.purchase_domain_screen_existing_domain_card_title,
         description = R.string.purchase_domain_screen_existing_domain_card_description,
         button = R.string.purchase_domain_screen_existing_domain_card_button,
-        onOptionSelected = onExistingDomainCardSelected,
+        onOptionSelected = onExistingSiteCardSelected,
         modifier = modifier,
     )
 }
diff --git a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java
index 20bfd1f1b708..514c5c1df83d 100644
--- a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java
+++ b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java
@@ -1079,7 +1079,7 @@ public enum Stat {
         MORE_MENU_ITEM_TAPPED,
         DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_SHOWN,
         DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_NEW_DOMAIN_TAPPED,
-        DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_EXISTING_DOMAIN_TAPPED,
+        DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_EXISTING_SITE_TAPPED,
         DOMAIN_MANAGEMENT_SEARCH_FOR_A_DOMAIN_SCREEN_SHOWN,
         DOMAIN_MANAGEMENT_SEARCH_DOMAIN_TAPPED,
         DOMAIN_MANAGEMENT_TRANSFER_DOMAIN_TAPPED,
diff --git a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java
index a0c4889ccb00..23fee7eb0bc7 100644
--- a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java
+++ b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java
@@ -2643,8 +2643,8 @@ public static String getEventNameForStat(AnalyticsTracker.Stat stat) {
                 return "domain_management_purchase_domain_screen_shown";
             case DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_NEW_DOMAIN_TAPPED:
                 return "domain_management_purchase_domain_screen_new_domain_tapped";
-            case DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_EXISTING_DOMAIN_TAPPED:
-                return "domain_management_purchase_domain_screen_existing_domain_tapped";
+            case DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_EXISTING_SITE_TAPPED:
+                return "domain_management_purchase_domain_screen_existing_site_tapped";
             case DOMAIN_MANAGEMENT_SEARCH_FOR_A_DOMAIN_SCREEN_SHOWN:
                 return "domain_management_search_for_a_domain_screen_shown";
             case DOMAIN_MANAGEMENT_SEARCH_DOMAIN_TAPPED:


Test patch:
diff --git a/WordPress/src/test/java/org/wordpress/android/ui/domains/management/newdomainsearch/NewDomainSearchViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/domains/management/newdomainsearch/NewDomainSearchViewModelTest.kt
index 123966533a6d..6298a2ee56d5 100644
--- a/WordPress/src/test/java/org/wordpress/android/ui/domains/management/newdomainsearch/NewDomainSearchViewModelTest.kt
+++ b/WordPress/src/test/java/org/wordpress/android/ui/domains/management/newdomainsearch/NewDomainSearchViewModelTest.kt
@@ -53,17 +53,17 @@ class NewDomainSearchViewModelTest : BaseUnitTest() {
 
     @Test
     fun `WHEN a domain is tapped THEN send PurchaseDomain action event`() = testWithActionEvents { events ->
-        val domain = ProposedDomain(1, "test.com", "1", null)
+        val domain = ProposedDomain(1, "test.com", "1", null, true)
         viewModel.onDomainTapped(domain)
         advanceUntilIdle()
 
-        val expectedEvent = ActionEvent.PurchaseDomain(domain)
+        val expectedEvent = ActionEvent.PurchaseDomain(domain.productId, domain.domain, domain.supportsPrivacy)
         assertThat(events.last()).isEqualTo(expectedEvent)
     }
 
     @Test
     fun `WHEN a domain is tapped THEN track DOMAIN_MANAGEMENT_SEARCH_DOMAIN_TAPPED event`() = test {
-        val domain = ProposedDomain(1, "test.com", "1", null)
+        val domain = ProposedDomain(1, "test.com", "1", null, true)
         viewModel.onDomainTapped(domain)
         advanceUntilIdle()
 
@@ -149,7 +149,8 @@ class NewDomainSearchViewModelTest : BaseUnitTest() {
                     productId = 0,
                     domain = "domain.com",
                     price = "USD 100",
-                    salePrice = null
+                    salePrice = null,
+                    supportsPrivacy = true
                 )
             )
             val result = DomainsResult.Success(domains)
diff --git a/WordPress/src/test/java/org/wordpress/android/ui/domains/management/newdomainsearch/domainsfetcher/NewDomainsSearchRepositoryTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/domains/management/newdomainsearch/domainsfetcher/NewDomainsSearchRepositoryTest.kt
index 7375e9080d3e..f2ecdee912b8 100644
--- a/WordPress/src/test/java/org/wordpress/android/ui/domains/management/newdomainsearch/domainsfetcher/NewDomainsSearchRepositoryTest.kt
+++ b/WordPress/src/test/java/org/wordpress/android/ui/domains/management/newdomainsearch/domainsfetcher/NewDomainsSearchRepositoryTest.kt
@@ -47,7 +47,8 @@ class NewDomainsSearchRepositoryTest : BaseUnitTest() {
                             productId = 0,
                             domain = "example.com",
                             price = "USD 50",
-                            salePrice = "USD 10"
+                            salePrice = "USD 10",
+                            supportsPrivacy = true
                         )
                     )
                 )
@@ -69,13 +70,15 @@ class NewDomainsSearchRepositoryTest : BaseUnitTest() {
                             productId = 0,
                             domain = "example.com",
                             price = "USD 50",
-                            salePrice = null
+                            salePrice = null,
+                            supportsPrivacy = true
                         )
                     )
                 )
             )
         }
 
+    @Suppress("LongMethod")
     @Test
     fun `GIVEN few domains with different relevance WHEN searchForDomains THEN sort domains by descending by relevance`() =
         test {
@@ -90,6 +93,7 @@ class NewDomainsSearchRepositoryTest : BaseUnitTest() {
                             is_free = false
                             relevance = 1f
                             cost = "USD 30"
+                            supports_privacy = true
                         },
                         DomainSuggestionResponse().apply {
                             product_id = 1
@@ -97,6 +101,7 @@ class NewDomainsSearchRepositoryTest : BaseUnitTest() {
                             is_free = false
                             relevance = 2f
                             cost = "USD 40"
+                            supports_privacy = true
                         },
                         DomainSuggestionResponse().apply {
                             product_id = 2
@@ -104,6 +109,7 @@ class NewDomainsSearchRepositoryTest : BaseUnitTest() {
                             is_free = false
                             relevance = 0f
                             cost = "USD 50"
+                            supports_privacy = true
                         },
                     )
                 )
@@ -118,19 +124,21 @@ class NewDomainsSearchRepositoryTest : BaseUnitTest() {
                             productId = 1,
                             domain = "second.com",
                             price = "USD 40",
-                            salePrice = null
+                            salePrice = null,
+                            supportsPrivacy = true
                         ),
                         ProposedDomain(
                             productId = 0,
                             domain = "first.com",
                             price = "USD 30",
-                            salePrice = null
+                            salePrice = null,
+                            supportsPrivacy = true
                         ),
-                        ProposedDomain(
-                            productId = 2,
+                        ProposedDomain(productId = 2,
                             domain = "third.com",
                             price = "USD 50",
-                            salePrice = null
+                            salePrice = null,
+                            supportsPrivacy = true
                         ),
                     )
                 )
@@ -151,6 +159,7 @@ class NewDomainsSearchRepositoryTest : BaseUnitTest() {
                             is_free = false
                             relevance = 1f
                             cost = "USD 30"
+                            supports_privacy = true
                         },
                         DomainSuggestionResponse().apply {
                             product_id = 1
@@ -158,6 +167,7 @@ class NewDomainsSearchRepositoryTest : BaseUnitTest() {
                             is_free = false
                             relevance = 2f
                             cost = "USD 40"
+                            supports_privacy = true
                         },
                         DomainSuggestionResponse().apply {
                             product_id = 2
@@ -165,6 +175,7 @@ class NewDomainsSearchRepositoryTest : BaseUnitTest() {
                             is_free = true
                             relevance = 0f
                             cost = "USD 50"
+                            supports_privacy = true
                         },
                     )
                 )
@@ -179,13 +190,15 @@ class NewDomainsSearchRepositoryTest : BaseUnitTest() {
                             productId = 1,
                             domain = "second.com",
                             price = "USD 40",
-                            salePrice = null
+                            salePrice = null,
+                            supportsPrivacy = true
                         ),
                         ProposedDomain(
                             productId = 0,
                             domain = "first.com",
                             price = "USD 30",
-                            salePrice = null
+                            salePrice = null,
+                            supportsPrivacy = true
                         ),
                     )
                 )
@@ -207,7 +220,8 @@ class NewDomainsSearchRepositoryTest : BaseUnitTest() {
                             productId = 0,
                             domain = "example.com",
                             price = "USD 50",
-                            salePrice = null
+                            salePrice = null,
+                            supportsPrivacy = true
                         )
                     )
                 )
@@ -251,7 +265,7 @@ class NewDomainsSearchRepositoryTest : BaseUnitTest() {
     private suspend fun mockProductWithSaleResponse(productId: Int = 0) {
         whenever(productsStore.fetchProducts(Constants.TYPE_DOMAINS_PRODUCT)).thenReturn(
             ProductsStore.OnProductsFetched(
-                products = listOf(Product(productId = productId, combinedSaleCostDisplay = "USD 10"))
+                products = listOf(Product(productId = productId, combinedSaleCostDisplay = "USD 10",))
             )
         )
     }
@@ -278,6 +292,7 @@ class NewDomainsSearchRepositoryTest : BaseUnitTest() {
                         is_free = isFree
                         relevance = 0f
                         cost = "USD 50"
+                        supports_privacy = true
                     }
                 )
             )
diff --git a/WordPress/src/test/java/org/wordpress/android/ui/domains/management/purchasedomain/PurchaseDomainViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/domains/management/purchasedomain/PurchaseDomainViewModelTest.kt
index b375dbe69e84..2d66066b0e2f 100644
--- a/WordPress/src/test/java/org/wordpress/android/ui/domains/management/purchasedomain/PurchaseDomainViewModelTest.kt
+++ b/WordPress/src/test/java/org/wordpress/android/ui/domains/management/purchasedomain/PurchaseDomainViewModelTest.kt
@@ -11,19 +11,23 @@ import org.mockito.Mock
 import org.mockito.MockitoAnnotations
 import org.mockito.kotlin.verify
 import org.wordpress.android.BaseUnitTest
-import org.wordpress.android.analytics.AnalyticsTracker.Stat.DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_EXISTING_DOMAIN_TAPPED
+import org.wordpress.android.analytics.AnalyticsTracker.Stat.DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_EXISTING_SITE_TAPPED
 import org.wordpress.android.analytics.AnalyticsTracker.Stat.DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_NEW_DOMAIN_TAPPED
 import org.wordpress.android.analytics.AnalyticsTracker.Stat.DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_SHOWN
 import org.wordpress.android.ui.domains.management.purchasedomain.PurchaseDomainViewModel.ActionEvent
 import org.wordpress.android.ui.domains.management.purchasedomain.PurchaseDomainViewModel.ActionEvent.GoBack
 import org.wordpress.android.ui.domains.management.purchasedomain.PurchaseDomainViewModel.ActionEvent.GoToDomainPurchasing
-import org.wordpress.android.ui.domains.management.purchasedomain.PurchaseDomainViewModel.ActionEvent.GoToExistingDomain
+import org.wordpress.android.ui.domains.management.purchasedomain.PurchaseDomainViewModel.ActionEvent.GoToExistingSite
 import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper
 
 @ExperimentalCoroutinesApi
 class PurchaseDomainViewModelTest : BaseUnitTest() {
     @Mock
     private lateinit var analyticsTracker: AnalyticsTrackerWrapper
+    private val productId = 8
+    private val domain = "domain.com"
+    private val supportsPrivacy = true
+
     private lateinit var viewModel: PurchaseDomainViewModel
 
     @Before
@@ -31,7 +35,10 @@ class PurchaseDomainViewModelTest : BaseUnitTest() {
         MockitoAnnotations.openMocks(this)
         viewModel = PurchaseDomainViewModel(
             mainDispatcher = testDispatcher(),
-            analyticsTracker = analyticsTracker
+            analyticsTracker = analyticsTracker,
+            productId = productId,
+            domain = domain,
+            privacy = supportsPrivacy,
         )
     }
 
@@ -49,8 +56,8 @@ class PurchaseDomainViewModelTest : BaseUnitTest() {
     @Test
     @Suppress("MaxLineLength")
     fun `WHEN existing domain selected THEN track DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_EXISTING_DOMAIN_TAPPED event`() {
-        viewModel.onExistingDomainSelected()
-        verify(analyticsTracker).track(DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_EXISTING_DOMAIN_TAPPED)
+        viewModel.onExistingSiteSelected()
+        verify(analyticsTracker).track(DOMAIN_MANAGEMENT_PURCHASE_DOMAIN_SCREEN_EXISTING_SITE_TAPPED)
     }
 
     @Test
@@ -58,15 +65,15 @@ class PurchaseDomainViewModelTest : BaseUnitTest() {
         viewModel.onNewDomainSelected()
         advanceUntilIdle()
 
-        assertThat(events.last()).isEqualTo(GoToDomainPurchasing)
+        assertThat(events.last()).isEqualTo(GoToDomainPurchasing(domain))
     }
 
     @Test
-    fun `WHEN existing domain selected THEN send GoToExistingDomain action event`() = testWithActionEvents { events ->
-        viewModel.onExistingDomainSelected()
+    fun `WHEN existing site selected THEN send GoToExistingSite action event`() = testWithActionEvents { events ->
+        viewModel.onExistingSiteSelected()
         advanceUntilIdle()
 
-        assertThat(events.last()).isEqualTo(GoToExistingDomain)
+        assertThat(events.last()).isEqualTo(GoToExistingSite(domain))
     }
 
     @Test