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

Issue:
Plans in Site Creation: Remove DOMAIN_PURCHASING feature flag
There is a local only feature flag for domain purchasing in the site creation feature. Since we bind domain purchasing feature into "Plans in Site Creation" project, we should remove [SiteCreationDomainPurchasing](https://github.com/wordpress-mobile/WordPress-Android/blob/trunk/WordPress/src/main/java/org/wordpress/android/util/config/SiteCreationDomainPurchasingFeatureConfig.kt) flag.


Discussion hints:

Pull request: Plans in site creation: Remove domain purchasing feature flag
Fixes #19230 

This PR removes domain purchasing in site creation feature flag, and replaces it with plans in site creation feature flag.


To test:

Test 1

- `Launch` JP app
- `Go` to Me-> Debug settings
- `Switch` to `Features in Development` tab
- `Verify` there's no `SiteCreationDomainPurchasing` feature flag is listed there
- `Switch` to `Remote Feature` tab, find `plans_in_site_creation` and enable it

Test 2

- `Go` to **My Site** tab
- `Tap` the down arrow to the right of the site name on the My Site screen
- `Tap` the + icon at the top right on the Site picker screen
- `Select` ⊕ **Create WordPress.com site** on the modal dialog
- `Tap` Skip at top right on the first step (topic screen)
- `Tap` Skip at top right on the next step (theme screen)
- `Enter` a search query (whatever you want here)
- `Verify` that result domains have either `Free` or `Price are no prices or "free" listed next to the domains on the right side

>**Note**
> Selecting a custom domain (with price) will launch, site assembly followed by checkout
> Selecting a free domain will launch site assembly an done

## Regression Notes
1. Potential unintended areas of impact
N/A

2. What I did to test those areas of impact (or what existing automated tests I relied on)
Manual and unit tests

3. What automated tests I added (or what prevented me from doing so)
Update existing unit tests

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.


Test command: ./gradlew :WordPress:testWordpressVanillaDebugUnitTest --tests "org.wordpress.android.ui.sitecreation.domains.SiteCreationDomainsViewModelTest"

Fix patch:
diff --git a/WordPress/build.gradle b/WordPress/build.gradle
index 0036a3717d78..23921af71fd4 100644
--- a/WordPress/build.gradle
+++ b/WordPress/build.gradle
@@ -158,7 +158,6 @@ android {
         buildConfigField "boolean", "ENABLE_MY_SITE_DASHBOARD_TABS", "true"
         buildConfigField "boolean", "ENABLE_QRCODE_AUTH_FLOW", "true"
         buildConfigField "boolean", "ENABLE_OPEN_WEB_LINKS_WITH_JP_FLOW", "true"
-        buildConfigField "boolean", "ENABLE_SITE_CREATION_DOMAIN_PURCHASING", "false"
         buildConfigField "boolean", "BLAZE_MANAGE_CAMPAIGNS", "false"
         buildConfigField "boolean", "DASHBOARD_PERSONALIZATION", "false"
 
@@ -187,7 +186,6 @@ android {
             buildConfigField "String", "PUSH_NOTIFICATIONS_APP_KEY", '"org.wordpress.android"'
             buildConfigField "boolean", "ENABLE_QRCODE_AUTH_FLOW", "false"
             buildConfigField "boolean", "ENABLE_OPEN_WEB_LINKS_WITH_JP_FLOW", "true"
-            buildConfigField "boolean", "ENABLE_SITE_CREATION_DOMAIN_PURCHASING", "false"
 
             manifestPlaceholders = [magicLinkScheme:"wordpress"]
         }
@@ -209,7 +207,6 @@ android {
             buildConfigField "String", "PUSH_NOTIFICATIONS_APP_KEY", '"com.jetpack.android"'
             buildConfigField "boolean", "ENABLE_QRCODE_AUTH_FLOW", "true"
             buildConfigField "boolean", "ENABLE_OPEN_WEB_LINKS_WITH_JP_FLOW", "false"
-            buildConfigField "boolean", "ENABLE_SITE_CREATION_DOMAIN_PURCHASING", "false"
 
             manifestPlaceholders = [magicLinkScheme:"jetpack"]
 
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainsRegistrationTracker.kt b/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainsRegistrationTracker.kt
index a65e18a75ccf..a246a5d2d2ff 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainsRegistrationTracker.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainsRegistrationTracker.kt
@@ -3,14 +3,14 @@ package org.wordpress.android.ui.domains
 import org.wordpress.android.analytics.AnalyticsTracker
 import org.wordpress.android.fluxc.model.SiteModel
 import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper
-import org.wordpress.android.util.config.SiteCreationDomainPurchasingFeatureConfig
+import org.wordpress.android.util.config.PlansInSiteCreationFeatureConfig
 import javax.inject.Inject
 import javax.inject.Singleton
 
 @Singleton
 class DomainsRegistrationTracker @Inject constructor(
     val tracker: AnalyticsTrackerWrapper,
-    private val purchasingFeatureConfig: SiteCreationDomainPurchasingFeatureConfig,
+    private val plansInSiteCreationFeatureConfig: PlansInSiteCreationFeatureConfig
 ) {
     private enum class PROPERTY(val key: String) {
         ORIGIN("origin"),
@@ -22,7 +22,7 @@ class DomainsRegistrationTracker @Inject constructor(
     }
 
     fun trackDomainsPurchaseWebviewViewed(site: SiteModel?, isSiteCreation: Boolean) {
-        if (purchasingFeatureConfig.isEnabledOrManuallyOverridden()) {
+        if (plansInSiteCreationFeatureConfig.isEnabled()) {
             val origin = if (isSiteCreation) VALUE.ORIGIN_SITE_CREATION.key else VALUE.ORIGIN_MENU.key
             tracker.track(
                 AnalyticsTracker.Stat.DOMAINS_PURCHASE_WEBVIEW_VIEWED, site, mutableMapOf(PROPERTY.ORIGIN.key to origin)
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModel.kt
index 8fad81d3aaf5..5143e65b36c6 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModel.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModel.kt
@@ -47,7 +47,7 @@ import org.wordpress.android.ui.utils.UiString.UiStringRes
 import org.wordpress.android.ui.utils.UiString.UiStringText
 import org.wordpress.android.util.AppLog
 import org.wordpress.android.util.NetworkUtilsWrapper
-import org.wordpress.android.util.config.SiteCreationDomainPurchasingFeatureConfig
+import org.wordpress.android.util.config.PlansInSiteCreationFeatureConfig
 import org.wordpress.android.util.extensions.isOnSale
 import org.wordpress.android.viewmodel.SingleLiveEvent
 import javax.inject.Inject
@@ -65,7 +65,7 @@ class SiteCreationDomainsViewModel @Inject constructor(
     private val domainSanitizer: SiteCreationDomainSanitizer,
     private val fetchDomainsUseCase: FetchDomainsUseCase,
     private val productsStore: ProductsStore,
-    private val purchasingFeatureConfig: SiteCreationDomainPurchasingFeatureConfig,
+    private val plansInSiteCreationFeatureConfig: PlansInSiteCreationFeatureConfig,
     private val tracker: SiteCreationTracker,
     @Named(BG_THREAD) private val bgDispatcher: CoroutineDispatcher,
     @Named(UI_THREAD) private val mainDispatcher: CoroutineDispatcher
@@ -111,7 +111,7 @@ class SiteCreationDomainsViewModel @Inject constructor(
         isStarted = true
         tracker.trackDomainsAccessed()
         resetUiState()
-        if (purchasingFeatureConfig.isEnabledOrManuallyOverridden()) fetchAndCacheProducts()
+        if (plansInSiteCreationFeatureConfig.isEnabled()) fetchAndCacheProducts()
     }
 
     private fun fetchAndCacheProducts() {
@@ -178,7 +178,7 @@ class SiteCreationDomainsViewModel @Inject constructor(
     }
 
     private suspend fun fetchDomainsByPurchasingFeatureConfig(query: String): OnSuggestedDomains {
-        val onlyWordpressCom = !purchasingFeatureConfig.isEnabledOrManuallyOverridden()
+        val onlyWordpressCom = !plansInSiteCreationFeatureConfig.isEnabled()
         val vendor = if (onlyWordpressCom) FETCH_DOMAINS_VENDOR_DOT else FETCH_DOMAINS_VENDOR_MOBILE
 
         return fetchDomainsUseCase.fetchDomains(query, vendor, onlyWordpressCom)
@@ -252,7 +252,7 @@ class SiteCreationDomainsViewModel @Inject constructor(
     }
 
     private fun getCreateSiteButtonState() = selectedDomain?.run {
-        when (purchasingFeatureConfig.isEnabledOrManuallyOverridden()) {
+        when (plansInSiteCreationFeatureConfig.isEnabled()) {
             true -> if (isFree) CreateSiteButtonState.Free else CreateSiteButtonState.Paid
             else -> CreateSiteButtonState.Old
         }
@@ -276,7 +276,7 @@ class SiteCreationDomainsViewModel @Inject constructor(
         return if (items.isEmpty()) {
             if (isNonEmptyUserQuery(query) && (state is Success || state is Ready)) {
                 DomainsUiContentState.Empty(emptyListMessage)
-            } else DomainsUiContentState.Initial(purchasingFeatureConfig.isEnabledOrManuallyOverridden())
+            } else DomainsUiContentState.Initial(plansInSiteCreationFeatureConfig.isEnabled())
         } else {
             DomainsUiContentState.VisibleItems(items)
         }
@@ -313,7 +313,7 @@ class SiteCreationDomainsViewModel @Inject constructor(
     }
 
     private fun createAvailableItemUiState(domain: DomainModel, index: Int): ListItemUiState {
-        return when (purchasingFeatureConfig.isEnabledOrManuallyOverridden()) {
+        return when (plansInSiteCreationFeatureConfig.isEnabled()) {
             true -> {
                 val product = products[domain.productId]
                 New.DomainUiState(
@@ -353,7 +353,7 @@ class SiteCreationDomainsViewModel @Inject constructor(
         domains: List<DomainModel>
     ): ListItemUiState? {
         if (domains.isEmpty()) return null
-        if (purchasingFeatureConfig.isEnabledOrManuallyOverridden()) return null // TODO: Add FQDN availability check
+        if (plansInSiteCreationFeatureConfig.isEnabled()) return null // TODO: Add FQDN availability check
         val sanitizedQuery = domainSanitizer.sanitizeDomainQuery(query)
         val isDomainUnavailable = domains.none { it.domainName.startsWith("$sanitizedQuery.") }
         return if (isDomainUnavailable) {
@@ -366,15 +366,13 @@ class SiteCreationDomainsViewModel @Inject constructor(
     }
 
     private fun createHeaderUiState(isVisible: Boolean) = if (!isVisible) null else
-        purchasingFeatureConfig.isEnabledOrManuallyOverridden().let { isPurchasingEnabled ->
-            SiteCreationHeaderUiState(
-                title = UiStringRes(R.string.new_site_creation_domain_header_title),
-                subtitle = UiStringRes(
-                    if (isPurchasingEnabled) R.string.site_creation_domain_header_subtitle
-                    else R.string.new_site_creation_domain_header_subtitle,
-                ),
-            )
-        }
+        SiteCreationHeaderUiState(
+            title = UiStringRes(R.string.new_site_creation_domain_header_title),
+            subtitle = UiStringRes(
+                if (plansInSiteCreationFeatureConfig.isEnabled()) R.string.site_creation_domain_header_subtitle
+                else R.string.new_site_creation_domain_header_subtitle,
+            ),
+        )
 
 private fun createSearchInputUiState(
         showProgress: Boolean,
@@ -382,7 +380,7 @@ private fun createSearchInputUiState(
         showDivider: Boolean,
     ): SiteCreationSearchInputUiState {
         val hint = UiStringRes(
-            if (purchasingFeatureConfig.isEnabledOrManuallyOverridden())
+            if (plansInSiteCreationFeatureConfig.isEnabled())
                 R.string.site_creation_domain_search_input_hint
             else
                 R.string.new_site_creation_search_domain_input_hint
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/misc/SiteCreationTracker.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/misc/SiteCreationTracker.kt
index af0ecc0741a3..d33852fc0007 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/misc/SiteCreationTracker.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/misc/SiteCreationTracker.kt
@@ -16,7 +16,7 @@ import org.wordpress.android.ui.sitecreation.misc.SiteCreationTracker.PROPERTY.T
 import org.wordpress.android.ui.sitecreation.misc.SiteCreationTracker.PROPERTY.THUMBNAIL_MODE
 import org.wordpress.android.ui.sitecreation.misc.SiteCreationTracker.PROPERTY.VERTICAL_SLUG
 import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper
-import org.wordpress.android.util.config.SiteCreationDomainPurchasingFeatureConfig
+import org.wordpress.android.util.config.PlansInSiteCreationFeatureConfig
 import javax.inject.Inject
 import javax.inject.Singleton
 
@@ -32,7 +32,7 @@ private const val SITE_CREATION_SOURCE = "source"
 @Singleton
 class SiteCreationTracker @Inject constructor(
     val tracker: AnalyticsTrackerWrapper,
-    private val purchasingFeatureConfig: SiteCreationDomainPurchasingFeatureConfig,
+    private val plansInSiteCreationFeatureConfig: PlansInSiteCreationFeatureConfig
 ) : LayoutPickerTracker {
     private enum class PROPERTY(val key: String) {
         TEMPLATE("template"),
@@ -63,7 +63,7 @@ class SiteCreationTracker @Inject constructor(
     }
 
     fun trackDomainSelected(chosenDomain: String, searchTerm: String, domainCost: String = "free") {
-        if(purchasingFeatureConfig.isEnabledOrManuallyOverridden()) {
+        if(plansInSiteCreationFeatureConfig.isEnabled()) {
             tracker.track(
                 AnalyticsTracker.Stat.ENHANCED_SITE_CREATION_DOMAINS_SELECTED,
                 mapOf(
diff --git a/WordPress/src/main/java/org/wordpress/android/util/config/SiteCreationDomainPurchasingFeatureConfig.kt b/WordPress/src/main/java/org/wordpress/android/util/config/SiteCreationDomainPurchasingFeatureConfig.kt
deleted file mode 100644
index da13b7b00260..000000000000
--- a/WordPress/src/main/java/org/wordpress/android/util/config/SiteCreationDomainPurchasingFeatureConfig.kt
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.wordpress.android.util.config
-
-import org.wordpress.android.BuildConfig
-import org.wordpress.android.annotation.FeatureInDevelopment
-import org.wordpress.android.util.config.AppConfig.FeatureState.ManuallyOverriden
-import javax.inject.Inject
-
-@FeatureInDevelopment
-class SiteCreationDomainPurchasingFeatureConfig
-@Inject constructor(
-    appConfig: AppConfig,
-) : FeatureConfig(
-    appConfig,
-    BuildConfig.ENABLE_SITE_CREATION_DOMAIN_PURCHASING,
-) {
-    fun isEnabledOrManuallyOverridden() = (featureState() as? ManuallyOverriden)?.isEnabled ?: isEnabled()
-}


Test patch:
diff --git a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModelTest.kt
index 6d43f782cbab..e761a7ee74b3 100644
--- a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModelTest.kt
+++ b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModelTest.kt
@@ -45,7 +45,7 @@ import org.wordpress.android.ui.sitecreation.usecases.FETCH_DOMAINS_VENDOR_MOBIL
 import org.wordpress.android.ui.sitecreation.usecases.FetchDomainsUseCase
 import org.wordpress.android.ui.utils.UiString.UiStringRes
 import org.wordpress.android.util.NetworkUtilsWrapper
-import org.wordpress.android.util.config.SiteCreationDomainPurchasingFeatureConfig
+import org.wordpress.android.util.config.PlansInSiteCreationFeatureConfig
 import kotlin.test.assertIs
 
 private const val MULTI_RESULT_DOMAIN_FETCH_RESULT_SIZE = 20
@@ -66,7 +66,7 @@ class SiteCreationDomainsViewModelTest : BaseUnitTest() {
     private lateinit var productsStore: ProductsStore
 
     @Mock
-    lateinit var purchasingFeatureConfig: SiteCreationDomainPurchasingFeatureConfig
+    lateinit var plansInSiteCreationFeatureConfig: PlansInSiteCreationFeatureConfig
 
     @Mock
     private lateinit var tracker: SiteCreationTracker
@@ -99,7 +99,7 @@ class SiteCreationDomainsViewModelTest : BaseUnitTest() {
             dispatcher = dispatcher,
             fetchDomainsUseCase = fetchDomainsUseCase,
             productsStore = productsStore,
-            purchasingFeatureConfig = purchasingFeatureConfig,
+            plansInSiteCreationFeatureConfig = plansInSiteCreationFeatureConfig,
             tracker = tracker,
             bgDispatcher = testDispatcher(),
             mainDispatcher = testDispatcher()
@@ -353,7 +353,7 @@ class SiteCreationDomainsViewModelTest : BaseUnitTest() {
     // region New UI
 
     private fun testNewUi(block: suspend CoroutineScope.() -> Unit) = test {
-        whenever(purchasingFeatureConfig.isEnabledOrManuallyOverridden()).thenReturn(true)
+        whenever(plansInSiteCreationFeatureConfig.isEnabled()).thenReturn(true)
         whenever(productsStore.fetchProducts(any())).thenReturn(mock())
         block()
     }