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

Issue:
[Jetpack Social] Remove feature flag
Remove Jetpack Social feature flag, since the feature was successfully released.


Discussion hints:
nan

Pull request: [Jetpack Social] Remove feature flag
Fixes #19576 

To test:

Taken from https://github.com/wordpress-mobile/WordPress-Android/pull/18897

1 - Open the app
2 - Go to Posts
3 - Open a Draft post / create a new post
4 - Open the Post Settings
5 - Verify the JP Social section is available
6 - Hit Publish
7 - Verify the JP Social item is available in the pre-publish sheet

## Regression Notes
1. Potential unintended areas of impact
Jetpack social section on edit post flow

2. What I did to test those areas of impact (or what existing automated tests I relied on)
Manual testing and updated unit tests

3. What automated tests I added (or what prevented me from doing so)
Updated `EditorJetpackSocialViewModelTest.kt`

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.posts.EditorJetpackSocialViewModelTest"

Fix patch:
diff --git a/WordPress/build.gradle b/WordPress/build.gradle
index 64b5255f59ea..f5166ba8e345 100644
--- a/WordPress/build.gradle
+++ b/WordPress/build.gradle
@@ -138,7 +138,6 @@ android {
         buildConfigField "boolean", "ENABLE_BLAZE_FEATURE", "false"
         buildConfigField "boolean", "WP_INDIVIDUAL_PLUGIN_OVERLAY", "false"
         buildConfigField "boolean", "SITE_EDITOR_MVP", "false"
-        buildConfigField "boolean", "JETPACK_SOCIAL", "false"
         buildConfigField "boolean", "CONTACT_SUPPORT_CHATBOT", "false"
         buildConfigField "boolean", "ENABLE_DOMAIN_MANAGEMENT_FEATURE", "false"
         buildConfigField "boolean", "PLANS_IN_SITE_CREATION", "false"
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditorJetpackSocialViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditorJetpackSocialViewModel.kt
index 8716b4e72dff..5b13090746c4 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditorJetpackSocialViewModel.kt
+++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditorJetpackSocialViewModel.kt
@@ -29,7 +29,6 @@ import org.wordpress.android.usecase.social.GetJetpackSocialShareMessageUseCase
 import org.wordpress.android.usecase.social.GetPublicizeConnectionsForUserUseCase
 import org.wordpress.android.usecase.social.JetpackSocialFlow
 import org.wordpress.android.usecase.social.ShareLimit
-import org.wordpress.android.util.config.JetpackSocialFeatureConfig
 import org.wordpress.android.util.extensions.doesNotContain
 import org.wordpress.android.util.extensions.updatePublicizeSkipConnections
 import org.wordpress.android.viewmodel.ScopedViewModel
@@ -39,7 +38,6 @@ import javax.inject.Named
 
 class EditorJetpackSocialViewModel @Inject constructor(
     private val dispatcher: Dispatcher,
-    private val jetpackSocialFeatureConfig: JetpackSocialFeatureConfig,
     private val accountStore: AccountStore,
     private val getPublicizeConnectionsForUserUseCase: GetPublicizeConnectionsForUserUseCase,
     private val getJetpackSocialShareMessageUseCase: GetJetpackSocialShareMessageUseCase,
@@ -101,7 +99,6 @@ class EditorJetpackSocialViewModel @Inject constructor(
     }
 
     fun onResume(jetpackSocialFlow: JetpackSocialFlow) {
-        if (!jetpackSocialFeatureConfig.isEnabled()) return
         _jetpackSocialUiState.value?.let { uiState ->
             if (uiState is JetpackSocialUiState.Loaded && uiState.showShareLimitUi) {
                 jetpackSocialSharingTracker.trackShareLimitDisplayed(jetpackSocialFlow)
@@ -190,8 +187,7 @@ class EditorJetpackSocialViewModel @Inject constructor(
         }
     }
 
-    private fun shouldShowJetpackSocial() = jetpackSocialFeatureConfig.isEnabled()
-            && !editPostRepository.isPage
+    private fun shouldShowJetpackSocial() = !editPostRepository.isPage
             && siteModel.supportsPublicize()
             && currentPost?.status != PostStatus.PRIVATE.toString()
 
diff --git a/WordPress/src/main/java/org/wordpress/android/util/config/JetpackSocialFeatureConfig.kt b/WordPress/src/main/java/org/wordpress/android/util/config/JetpackSocialFeatureConfig.kt
deleted file mode 100644
index ed17a64a6129..000000000000
--- a/WordPress/src/main/java/org/wordpress/android/util/config/JetpackSocialFeatureConfig.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.wordpress.android.util.config
-
-import org.wordpress.android.BuildConfig
-import org.wordpress.android.annotation.Feature
-import javax.inject.Inject
-
-private const val JETPACK_SOCIAL_REMOTE_FIELD = "jetpack_social_improvements_v1"
-
-@Feature(JETPACK_SOCIAL_REMOTE_FIELD, defaultValue = true)
-class JetpackSocialFeatureConfig @Inject constructor(
-    appConfig: AppConfig
-) : FeatureConfig(
-    appConfig,
-    BuildConfig.JETPACK_SOCIAL,
-    JETPACK_SOCIAL_REMOTE_FIELD,
-) {
-    override fun isEnabled(): Boolean {
-        return super.isEnabled() && BuildConfig.IS_JETPACK_APP
-    }
-}


Test patch:
diff --git a/WordPress/src/test/java/org/wordpress/android/ui/posts/EditorJetpackSocialViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/posts/EditorJetpackSocialViewModelTest.kt
index 1e05b7d4f486..a7c45b2b0238 100644
--- a/WordPress/src/test/java/org/wordpress/android/ui/posts/EditorJetpackSocialViewModelTest.kt
+++ b/WordPress/src/test/java/org/wordpress/android/ui/posts/EditorJetpackSocialViewModelTest.kt
@@ -9,6 +9,7 @@ import org.mockito.kotlin.any
 import org.mockito.kotlin.doReturn
 import org.mockito.kotlin.mock
 import org.mockito.kotlin.never
+import org.mockito.kotlin.times
 import org.mockito.kotlin.verify
 import org.mockito.kotlin.whenever
 import org.wordpress.android.BaseUnitTest
@@ -36,16 +37,12 @@ import org.wordpress.android.usecase.social.GetJetpackSocialShareMessageUseCase
 import org.wordpress.android.usecase.social.GetPublicizeConnectionsForUserUseCase
 import org.wordpress.android.usecase.social.JetpackSocialFlow
 import org.wordpress.android.usecase.social.ShareLimit
-import org.wordpress.android.util.config.JetpackSocialFeatureConfig
 
 @OptIn(ExperimentalCoroutinesApi::class)
 class EditorJetpackSocialViewModelTest : BaseUnitTest() {
     @Mock
     lateinit var dispatcher: Dispatcher
 
-    @Mock
-    lateinit var jetpackSocialFeatureConfig: JetpackSocialFeatureConfig
-
     @Mock
     lateinit var accountStore: AccountStore
 
@@ -89,7 +86,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
     fun setUp() {
         classToTest = EditorJetpackSocialViewModel(
             dispatcher = dispatcher,
-            jetpackSocialFeatureConfig = jetpackSocialFeatureConfig,
             accountStore = accountStore,
             getPublicizeConnectionsForUserUseCase = getPublicizeConnectionsForUserUseCase,
             getJetpackSocialShareMessageUseCase = getJetpackSocialShareMessageUseCase,
@@ -110,18 +106,8 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
         classToTest.actionEvents.observeForever(actionEventsObserver)
     }
 
-    @Test
-    fun `Should NOT load jetpack social if FF is disabled`() = test {
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(false)
-        classToTest.start(FAKE_SITE_MODEL, editPostRepository)
-        verify(getPublicizeConnectionsForUserUseCase, never()).execute(any(), any(), any())
-    }
-
     @Test
     fun `Should NOT load jetpack social if post is page`() = test {
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         whenever(editPostRepository.isPage).thenReturn(true)
         classToTest.start(FAKE_SITE_MODEL, editPostRepository)
         verify(getPublicizeConnectionsForUserUseCase, never()).execute(any(), any(), any())
@@ -129,8 +115,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
 
     @Test
     fun `Should NOT load jetpack social if PostStatus is PRIVATE`() = test {
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         whenever(editPostRepository.isPage).thenReturn(false)
         whenever(editPostRepository.getPost()).thenReturn(PostModel().apply {
             setStatus(PostStatus.PRIVATE.toString())
@@ -139,55 +123,42 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
         verify(getPublicizeConnectionsForUserUseCase, never()).execute(any(), any(), any())
     }
 
-    @Test
-    fun `Should hide jetpack social container if FF is disabled`() = test {
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(false)
-        classToTest.start(FAKE_SITE_MODEL, editPostRepository)
-        verify(showJetpackSocialContainerObserver).onChanged(JetpackSocialContainerVisibility.ALL_HIDDEN)
-    }
 
     @Test
-    fun `Should show jetpack social container if FF is enabled`() = test {
+    fun `Should show jetpack social container`() = test {
         mockUserId()
         whenever(getPublicizeConnectionsForUserUseCase.execute(any(), any(), any()))
             .thenReturn(emptyList())
         whenever(getJetpackSocialShareLimitStatusUseCase.execute(any()))
             .thenReturn(ShareLimit.Disabled)
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         classToTest.start(fakeSiteModel(true), editPostRepository)
         verify(showJetpackSocialContainerObserver).onChanged(JetpackSocialContainerVisibility.ALL_VISIBLE)
     }
 
     @Test
-    fun `Should get publicize connections for user if jetpack social FF is enabled`() = test {
+    fun `Should get publicize connections for user`() = test {
         mockUserId()
         whenever(getPublicizeConnectionsForUserUseCase.execute(any(), any(), any()))
             .thenReturn(emptyList())
         whenever(getJetpackSocialShareLimitStatusUseCase.execute(any()))
             .thenReturn(ShareLimit.Disabled)
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         classToTest.start(fakeSiteModel(), editPostRepository)
         verify(getPublicizeConnectionsForUserUseCase).execute(FAKE_REMOTE_SITE_ID, FAKE_USER_ID)
     }
 
     @Test
-    fun `Should get jetpack social share limit status if jetpack social FF is enabled`() = test {
+    fun `Should get jetpack social share limit status`() = test {
         mockUserId()
         whenever(getPublicizeConnectionsForUserUseCase.execute(any(), any(), any()))
             .thenReturn(emptyList())
         whenever(getJetpackSocialShareLimitStatusUseCase.execute(any()))
             .thenReturn(ShareLimit.Disabled)
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         classToTest.start(fakeSiteModel(), editPostRepository)
         verify(getJetpackSocialShareLimitStatusUseCase).execute(FAKE_SITE_MODEL)
     }
 
     @Test
-    fun `Should map no connections UI if connections are empty, FF is enabled and never dismissed by user`() = test {
+    fun `Should map no connections UI if connections are empty and never dismissed by user`() = test {
         mockUserId()
         whenever(getPublicizeConnectionsForUserUseCase.execute(any(), any(), any()))
             .thenReturn(emptyList())
@@ -195,8 +166,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
             .thenReturn(ShareLimit.Disabled)
         whenever(publicizeTableWrapper.getServiceList())
             .thenReturn(listOf(PublicizeService().apply { status = PublicizeService.Status.OK }))
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         whenever(appPrefsWrapper.getShouldShowJetpackSocialNoConnections(any(), any()))
             .thenReturn(true)
 
@@ -205,7 +174,7 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
     }
 
     @Test
-    fun `Should emit no connections UI if connections are empty, FF is enabled and never dismissed by user`() = test {
+    fun `Should emit no connections UI if connections are empty and never dismissed by user`() = test {
         val noConnections = JetpackSocialUiState.NoConnections(
             trainOfIconsModels = listOf(),
             message = "message",
@@ -221,8 +190,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
             .thenReturn(ShareLimit.Disabled)
         whenever(publicizeTableWrapper.getServiceList())
             .thenReturn(listOf(PublicizeService().apply { status = PublicizeService.Status.OK }))
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         whenever(jetpackUiStateMapper.mapNoConnections(any(), any()))
             .thenReturn(noConnections)
         whenever(appPrefsWrapper.getShouldShowJetpackSocialNoConnections(any(), any()))
@@ -240,8 +207,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
             .thenReturn(ShareLimit.Disabled)
         whenever(publicizeTableWrapper.getServiceList())
             .thenReturn(listOf(PublicizeService().apply { status = PublicizeService.Status.OK }))
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         whenever(appPrefsWrapper.getShouldShowJetpackSocialNoConnections(any(), any()))
             .thenReturn(false)
 
@@ -250,7 +215,7 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
     }
 
     @Test
-    fun `Should map loaded UI state if connections list is NOT empty and jetpack social FF is enabled`() = test {
+    fun `Should map loaded UI state if connections list is NOT empty`() = test {
         mockUserId()
         whenever(getPublicizeConnectionsForUserUseCase.execute(any(), any(), any()))
             .thenReturn(listOf(FAKE_PUBLICIZE_CONNECTION))
@@ -258,14 +223,12 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
             .thenReturn("Message")
         whenever(getJetpackSocialShareLimitStatusUseCase.execute(any()))
             .thenReturn(ShareLimit.Disabled)
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         classToTest.start(fakeSiteModel(true), editPostRepository)
         verify(jetpackUiStateMapper).mapLoaded(any(), any(), any(), any(), any(), any(), any(), any())
     }
 
     @Test
-    fun `Should emit loaded UI state if connections list is NOT empty and jetpack social FF is enabled`() = test {
+    fun `Should emit loaded UI state if connections list is NOT empty`() = test {
         val loaded = JetpackSocialUiState.Loaded(
             jetpackSocialConnectionDataList = listOf(
                 JetpackSocialConnectionData(
@@ -289,8 +252,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
             .thenReturn(ShareLimit.Disabled)
         whenever(getJetpackSocialShareMessageUseCase.execute(any()))
             .thenReturn("Message")
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         whenever(jetpackUiStateMapper.mapLoaded(any(), any(), any(), any(), any(), any(), any(), any()))
             .thenReturn(loaded)
         classToTest.start(fakeSiteModel(true), editPostRepository)
@@ -322,8 +283,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
             .thenReturn(ShareLimit.Disabled)
         whenever(getJetpackSocialShareMessageUseCase.execute(any()))
             .thenReturn("Message")
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         whenever(jetpackUiStateMapper.mapLoaded(any(), any(), any(), any(), any(), any(), any(), any()))
             .thenReturn(loaded)
 
@@ -340,7 +299,12 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
     }
 
     @Test
-    fun `Should emit OpenSocialConnectionList when onJetpackSocialConnectProfilesClick is called`() {
+    fun `Should emit OpenSocialConnectionList when onJetpackSocialConnectProfilesClick is called`() = test {
+        mockUserId()
+        whenever(getPublicizeConnectionsForUserUseCase.execute(any(), any(), any()))
+            .thenReturn(emptyList())
+        whenever(getJetpackSocialShareLimitStatusUseCase.execute(any()))
+            .thenReturn(ShareLimit.Disabled)
         classToTest.start(fakeSiteModel(), editPostRepository)
         classToTest.onJetpackSocialConnectProfilesClick(JetpackSocialFlow.POST_SETTINGS)
         verify(actionEventsObserver).onChanged(
@@ -368,8 +332,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
             .thenReturn(ShareLimit.Disabled)
         whenever(publicizeTableWrapper.getServiceList())
             .thenReturn(listOf(PublicizeService().apply { status = PublicizeService.Status.OK }))
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         whenever(jetpackUiStateMapper.mapNoConnections(any(), any()))
             .thenReturn(noConnections)
         whenever(appPrefsWrapper.getShouldShowJetpackSocialNoConnections(any(), any()))
@@ -393,8 +355,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
             .thenReturn(ShareLimit.Disabled)
         whenever(publicizeTableWrapper.getServiceList())
             .thenReturn(listOf(PublicizeService().apply { status = PublicizeService.Status.OK }))
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         whenever(appPrefsWrapper.getShouldShowJetpackSocialNoConnections(any(), any()))
             .thenReturn(false)
 
@@ -433,8 +393,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
             .thenReturn(mock())
         whenever(getJetpackSocialShareMessageUseCase.execute(any()))
             .thenReturn("Message")
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         whenever(jetpackUiStateMapper.mapLoaded(any(), any(), any(), any(), any(), any(), any(), any()))
             .thenReturn(loaded)
         classToTest.start(fakeSiteModel(true), editPostRepository)
@@ -472,8 +430,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
             .thenReturn(mock())
         whenever(getJetpackSocialShareMessageUseCase.execute(any()))
             .thenReturn("Message")
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         whenever(jetpackUiStateMapper.mapLoaded(any(), any(), any(), any(), any(), any(), any(), any()))
             .thenReturn(loaded)
         classToTest.start(fakeSiteModel(true), editPostRepository)
@@ -492,8 +448,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
             .thenReturn(emptyList())
         whenever(getJetpackSocialShareLimitStatusUseCase.execute(any()))
             .thenReturn(ShareLimit.Disabled)
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         classToTest.start(fakeSiteModel(true), editPostRepository)
 
         classToTest.onJetpackSocialConnectProfilesClick(JetpackSocialFlow.POST_SETTINGS)
@@ -507,8 +461,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
             .thenReturn(emptyList())
         whenever(getJetpackSocialShareLimitStatusUseCase.execute(any()))
             .thenReturn(ShareLimit.Disabled)
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         classToTest.start(fakeSiteModel(true), editPostRepository)
 
         classToTest.onJetpackSocialNotNowClick(JetpackSocialFlow.POST_SETTINGS)
@@ -522,8 +474,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
             .thenReturn(emptyList())
         whenever(getJetpackSocialShareLimitStatusUseCase.execute(any()))
             .thenReturn(ShareLimit.Disabled)
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         classToTest.start(fakeSiteModel(true), editPostRepository)
 
         classToTest.onJetpackSocialSubscribeClick(JetpackSocialFlow.POST_SETTINGS)
@@ -537,8 +487,6 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
             .thenReturn(emptyList())
         whenever(getJetpackSocialShareLimitStatusUseCase.execute(any()))
             .thenReturn(ShareLimit.Disabled)
-        whenever(jetpackSocialFeatureConfig.isEnabled())
-            .thenReturn(true)
         classToTest.start(fakeSiteModel(true), editPostRepository)
 
         classToTest.onJetpackSocialConnectionClick(mock(), true, JetpackSocialFlow.POST_SETTINGS)
@@ -549,9 +497,18 @@ class EditorJetpackSocialViewModelTest : BaseUnitTest() {
     }
 
     @Test
-    fun `Should start jetpack social if onPostVisibilityChanged is called`() {
+    fun `Should start jetpack social if onPostVisibilityChanged is called`() = test {
+        // Initialize EditPostRepository
+        mockUserId()
+        whenever(getPublicizeConnectionsForUserUseCase.execute(any(), any(), any()))
+            .thenReturn(emptyList())
+        whenever(getJetpackSocialShareLimitStatusUseCase.execute(any()))
+            .thenReturn(ShareLimit.Disabled)
+        classToTest.start(fakeSiteModel(true), editPostRepository)
+        //
         classToTest.onPostStatusChanged()
-        verify(showJetpackSocialContainerObserver).onChanged(any())
+        // verify 2 times: one for start method and another for onPostStatusChanged method
+        verify(showJetpackSocialContainerObserver, times(2)).onChanged(any())
     }
 
     private fun fakeSiteModel(supportsPublicize: Boolean = false): SiteModel = FAKE_SITE_MODEL.apply {