diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java index 16be31d2a72a..072eb04fb0cc 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java @@ -104,6 +104,7 @@ import org.wordpress.android.ui.uploads.UploadActionUseCase; import org.wordpress.android.ui.uploads.UploadUtils; import org.wordpress.android.ui.uploads.UploadUtilsWrapper; +import org.wordpress.android.ui.whatsnew.FeatureAnnouncementDialogFragment; import org.wordpress.android.util.AniUtils; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; @@ -418,6 +419,11 @@ private void initViewModel() { } }); + mViewModel.getOnFeatureAnnouncementRequested().observe(this, action -> { + new FeatureAnnouncementDialogFragment() + .show(getSupportFragmentManager(), FeatureAnnouncementDialogFragment.TAG); + }); + mFloatingActionButton.setOnClickListener(v -> { mViewModel.onFabClicked(hasFullAccessToContent()); }); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java index fb5579872d8e..a2e57110e9c6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java @@ -215,6 +215,12 @@ public enum UndeletablePrefKey implements PrefKey { // used to indicate that we do not need to show the main FAB tooltip IS_MAIN_FAB_TOOLTIP_DISABLED, + + // version of the last shown feature announcement + FEATURE_ANNOUNCEMENT_SHOWN_VERSION, + + // last app version code feature announcement was shown for + LAST_FEATURE_ANNOUNCEMENT_APP_VERSION_CODE, } private static SharedPreferences prefs() { @@ -1092,6 +1098,22 @@ private static List getPostWithHWAccelerationOff() { return Arrays.asList(idsAsString.split(",")); } + public static void setFeatureAnnouncementShownVersion(int version) { + setInt(UndeletablePrefKey.FEATURE_ANNOUNCEMENT_SHOWN_VERSION, version); + } + + public static int getFeatureAnnouncementShownVersion() { + return getInt(UndeletablePrefKey.FEATURE_ANNOUNCEMENT_SHOWN_VERSION, -1); + } + + public static int getLastFeatureAnnouncementAppVersionCode() { + return getInt(UndeletablePrefKey.LAST_FEATURE_ANNOUNCEMENT_APP_VERSION_CODE); + } + + public static void setLastFeatureAnnouncementAppVersionCode(int version) { + setInt(UndeletablePrefKey.LAST_FEATURE_ANNOUNCEMENT_APP_VERSION_CODE, version); + } + /* * adds a local site ID to the top of list of recently chosen sites */ diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefsWrapper.kt b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefsWrapper.kt index 5b3c038f0843..c75ed51d07fa 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefsWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefsWrapper.kt @@ -30,6 +30,14 @@ class AppPrefsWrapper @Inject constructor() { get() = AppPrefs.getNewsCardShownVersion() set(version) = AppPrefs.setNewsCardShownVersion(version) + var featureAnnouncementShownVersion: Int + get() = AppPrefs.getFeatureAnnouncementShownVersion() + set(version) = AppPrefs.setFeatureAnnouncementShownVersion(version) + + var lastFeatureAnnouncementAppVersionCode: Int + get() = AppPrefs.getLastFeatureAnnouncementAppVersionCode() + set(version) = AppPrefs.setLastFeatureAnnouncementAppVersionCode(version) + var avatarVersion: Int get() = AppPrefs.getAvatarVersion() set(version) = AppPrefs.setAvatarVersion(version) @@ -124,6 +132,8 @@ class AppPrefsWrapper @Inject constructor() { fun getLastReaderKnownUserId() = AppPrefs.getLastReaderKnownUserId() fun setLastReaderKnownUserId(userId: Long) = AppPrefs.setLastReaderKnownUserId(userId) + fun getLastAppVersionCode() = AppPrefs.getLastAppVersionCode() + companion object { private const val LIGHT_MODE_ID = 0 private const val DARK_MODE_ID = 1 diff --git a/WordPress/src/main/java/org/wordpress/android/ui/whatsnew/FeatureAnnouncement.kt b/WordPress/src/main/java/org/wordpress/android/ui/whatsnew/FeatureAnnouncement.kt index a9f4ff91fd44..592595cd13ee 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/whatsnew/FeatureAnnouncement.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/whatsnew/FeatureAnnouncement.kt @@ -4,6 +4,7 @@ import androidx.annotation.DrawableRes data class FeatureAnnouncement( val version: String, + val versionCode: Int, val detailsUrl: String, val features: List ) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/whatsnew/FeatureAnnouncementProvider.kt b/WordPress/src/main/java/org/wordpress/android/ui/whatsnew/FeatureAnnouncementProvider.kt index de7752c4e914..4058d7147935 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/whatsnew/FeatureAnnouncementProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/whatsnew/FeatureAnnouncementProvider.kt @@ -5,7 +5,7 @@ import javax.inject.Inject class FeatureAnnouncementProvider @Inject constructor() { private val localFeatureAnnouncement = FeatureAnnouncement( - "14.7", "https://wordpress.com/blog/2020/04/20/earth-day-live/", listOf( + "14.7", 857, "https://wordpress.com/blog/2020/04/20/earth-day-live/", listOf( FeatureAnnouncementItem( "Super Publishing", "Publish amazing articles using the power of your mind! Concentrate" + @@ -27,7 +27,11 @@ class FeatureAnnouncementProvider @Inject constructor() { ) ) - fun getLatestFeatureAnnouncement(): FeatureAnnouncement { + fun getLatestFeatureAnnouncement(): FeatureAnnouncement? { return localFeatureAnnouncement } + + fun isFeatureAnnouncementAvailable(): Boolean { + return getLatestFeatureAnnouncement() != null + } } diff --git a/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt b/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt new file mode 100644 index 000000000000..4b2c8ab9a0eb --- /dev/null +++ b/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt @@ -0,0 +1,14 @@ +package org.wordpress.android.util + +import org.wordpress.android.BuildConfig +import javax.inject.Inject + +class BuildConfigWrapper @Inject constructor() { + fun getAppVersionCode(): Int { + return BuildConfig.VERSION_CODE + } + + fun isFeatureAnnouncementEnabled(): Boolean { + return BuildConfig.FEATURE_ANNOUNCEMENT_AVAILABLE + } +} diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModel.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModel.kt index a28b2d0e9247..22c42f0c6658 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModel.kt @@ -12,11 +12,17 @@ import org.wordpress.android.ui.main.MainActionListItem.ActionType.NO_ACTION import org.wordpress.android.ui.main.MainActionListItem.CreateAction import org.wordpress.android.ui.main.MainFabUiState import org.wordpress.android.ui.prefs.AppPrefsWrapper +import org.wordpress.android.ui.whatsnew.FeatureAnnouncementProvider +import org.wordpress.android.util.BuildConfigWrapper import org.wordpress.android.viewmodel.Event import org.wordpress.android.viewmodel.SingleLiveEvent import javax.inject.Inject -class WPMainActivityViewModel @Inject constructor(private val appPrefsWrapper: AppPrefsWrapper) : ViewModel() { +class WPMainActivityViewModel @Inject constructor( + private val featureAnnouncementProvider: FeatureAnnouncementProvider, + private val buildConfigWrapper: BuildConfigWrapper, + private val appPrefsWrapper: AppPrefsWrapper +) : ViewModel() { private var isStarted = false private val _fabUiState = MutableLiveData() @@ -34,6 +40,9 @@ class WPMainActivityViewModel @Inject constructor(private val appPrefsWrapper: A private val _startLoginFlow = MutableLiveData>() val startLoginFlow: LiveData> = _startLoginFlow + private val _onFeatureAnnouncementRequested = SingleLiveEvent() + val onFeatureAnnouncementRequested: LiveData = _onFeatureAnnouncementRequested + fun start(isFabVisible: Boolean, hasFullAccessToContent: Boolean) { if (isStarted) return isStarted = true @@ -41,29 +50,39 @@ class WPMainActivityViewModel @Inject constructor(private val appPrefsWrapper: A setMainFabUiState(isFabVisible, hasFullAccessToContent) loadMainActions() + + if (buildConfigWrapper.isFeatureAnnouncementEnabled()) { + checkForFeatureAnnouncements() + } } private fun loadMainActions() { val actionsList = ArrayList() - actionsList.add(CreateAction( - actionType = NO_ACTION, - iconRes = 0, - labelRes = R.string.my_site_bottom_sheet_title, - onClickAction = null - )) - actionsList.add(CreateAction( - actionType = CREATE_NEW_POST, - iconRes = R.drawable.ic_posts_white_24dp, - labelRes = R.string.my_site_bottom_sheet_add_post, - onClickAction = ::onCreateActionClicked - )) - actionsList.add(CreateAction( - actionType = CREATE_NEW_PAGE, - iconRes = R.drawable.ic_pages_white_24dp, - labelRes = R.string.my_site_bottom_sheet_add_page, - onClickAction = ::onCreateActionClicked - )) + actionsList.add( + CreateAction( + actionType = NO_ACTION, + iconRes = 0, + labelRes = R.string.my_site_bottom_sheet_title, + onClickAction = null + ) + ) + actionsList.add( + CreateAction( + actionType = CREATE_NEW_POST, + iconRes = R.drawable.ic_posts_white_24dp, + labelRes = R.string.my_site_bottom_sheet_add_post, + onClickAction = ::onCreateActionClicked + ) + ) + actionsList.add( + CreateAction( + actionType = CREATE_NEW_PAGE, + iconRes = R.drawable.ic_pages_white_24dp, + labelRes = R.string.my_site_bottom_sheet_add_page, + onClickAction = ::onCreateActionClicked + ) + ) _mainActions.postValue(actionsList) } @@ -130,9 +149,9 @@ class WPMainActivityViewModel @Inject constructor(private val appPrefsWrapper: A private fun setMainFabUiState(isFabVisible: Boolean, hasFullAccessToContent: Boolean) { val newState = MainFabUiState( - isFabVisible = isFabVisible, - isFabTooltipVisible = if (appPrefsWrapper.isMainFabTooltipDisabled()) false else isFabVisible, - CreateContentMessageId = getCreateContentMessageId(hasFullAccessToContent) + isFabVisible = isFabVisible, + isFabTooltipVisible = if (appPrefsWrapper.isMainFabTooltipDisabled()) false else isFabVisible, + CreateContentMessageId = getCreateContentMessageId(hasFullAccessToContent) ) _fabUiState.value = newState @@ -144,4 +163,30 @@ class WPMainActivityViewModel @Inject constructor(private val appPrefsWrapper: A else R.string.create_post_page_fab_tooltip_contributors } + + private fun checkForFeatureAnnouncements() { + val currentVersionCode = buildConfigWrapper.getAppVersionCode() + val previousVersionCode = appPrefsWrapper.lastFeatureAnnouncementAppVersionCode + + // only proceed to feature announcement logic if we are upgrading the app + if (previousVersionCode != 0 && previousVersionCode < currentVersionCode) { + if (canShowFeatureAnnouncement()) { + appPrefsWrapper.featureAnnouncementShownVersion = + featureAnnouncementProvider.getLatestFeatureAnnouncement()?.versionCode!! + appPrefsWrapper.lastFeatureAnnouncementAppVersionCode = currentVersionCode + _onFeatureAnnouncementRequested.call() + } +// else { +// // request feature announcement from endpoint to be used on next app start +// } + } else { + appPrefsWrapper.lastFeatureAnnouncementAppVersionCode = currentVersionCode + } + } + + private fun canShowFeatureAnnouncement(): Boolean { + return featureAnnouncementProvider.isFeatureAnnouncementAvailable() && + appPrefsWrapper.featureAnnouncementShownVersion < + featureAnnouncementProvider.getLatestFeatureAnnouncement()?.versionCode!! + } } diff --git a/WordPress/src/test/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModelTest.kt index 03faedcd2dd5..b2cc39c12630 100644 --- a/WordPress/src/test/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModelTest.kt @@ -1,6 +1,10 @@ package org.wordpress.android.viewmodel.main import androidx.arch.core.executor.testing.InstantTaskExecutorRule +import androidx.lifecycle.Observer +import com.nhaarman.mockitokotlin2.anyOrNull +import com.nhaarman.mockitokotlin2.never +import com.nhaarman.mockitokotlin2.times import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.whenever import org.assertj.core.api.Assertions.assertThat @@ -15,6 +19,9 @@ import org.wordpress.android.ui.main.MainActionListItem.ActionType.CREATE_NEW_PA import org.wordpress.android.ui.main.MainActionListItem.ActionType.CREATE_NEW_POST import org.wordpress.android.ui.main.MainActionListItem.CreateAction import org.wordpress.android.ui.prefs.AppPrefsWrapper +import org.wordpress.android.ui.whatsnew.FeatureAnnouncement +import org.wordpress.android.ui.whatsnew.FeatureAnnouncementProvider +import org.wordpress.android.util.BuildConfigWrapper @RunWith(MockitoJUnitRunner::class) class WPMainActivityViewModelTest { @@ -23,42 +30,64 @@ class WPMainActivityViewModelTest { private lateinit var viewModel: WPMainActivityViewModel - @Mock - private lateinit var appPrefsWrapper: AppPrefsWrapper + @Mock private lateinit var appPrefsWrapper: AppPrefsWrapper + @Mock lateinit var featureAnnouncementProvider: FeatureAnnouncementProvider + @Mock lateinit var onFeatureAnnouncementRequestedObserver: Observer + @Mock lateinit var buildConfigWrapper: BuildConfigWrapper + + private val featureAnnouncement = FeatureAnnouncement( + "14.7", + 850, + "https://wordpress.org/", + emptyList() + ) @Before fun setUp() { whenever(appPrefsWrapper.isMainFabTooltipDisabled()).thenReturn(false) - viewModel = WPMainActivityViewModel(appPrefsWrapper) - viewModel.start(isFabVisible = true, hasFullAccessToContent = true) + whenever(buildConfigWrapper.isFeatureAnnouncementEnabled()).thenReturn(true) + whenever(buildConfigWrapper.getAppVersionCode()).thenReturn(850) + viewModel = WPMainActivityViewModel( + featureAnnouncementProvider, + buildConfigWrapper, + appPrefsWrapper + ) + viewModel.onFeatureAnnouncementRequested.observeForever( + onFeatureAnnouncementRequestedObserver + ) } @Test fun `fab visible when asked`() { + startViewModelWithDefaultParameters() viewModel.onPageChanged(showFab = true, hasFullAccessToContent = true) assertThat(viewModel.fabUiState.value?.isFabVisible).isEqualTo(true) } @Test fun `fab hidden when asked`() { + startViewModelWithDefaultParameters() viewModel.onPageChanged(showFab = false, hasFullAccessToContent = true) assertThat(viewModel.fabUiState.value?.isFabVisible).isEqualTo(false) } @Test fun `fab tooltip visible when asked`() { + startViewModelWithDefaultParameters() viewModel.onPageChanged(showFab = true, hasFullAccessToContent = true) assertThat(viewModel.fabUiState.value?.isFabTooltipVisible).isEqualTo(true) } @Test fun `fab tooltip hidden when asked`() { + startViewModelWithDefaultParameters() viewModel.onPageChanged(showFab = false, hasFullAccessToContent = true) assertThat(viewModel.fabUiState.value?.isFabTooltipVisible).isEqualTo(false) } @Test fun `fab tooltip disabled when tapped`() { + startViewModelWithDefaultParameters() viewModel.onTooltipTapped(true) verify(appPrefsWrapper).setMainFabTooltipDisabled(true) assertThat(viewModel.fabUiState.value?.isFabTooltipVisible).isEqualTo(false) @@ -66,6 +95,7 @@ class WPMainActivityViewModelTest { @Test fun `fab tooltip disabled when user without full access to content uses the fab`() { + startViewModelWithDefaultParameters() whenever(appPrefsWrapper.isMainFabTooltipDisabled()).thenReturn(true) viewModel.onFabClicked(false) verify(appPrefsWrapper).setMainFabTooltipDisabled(true) @@ -74,6 +104,7 @@ class WPMainActivityViewModelTest { @Test fun `fab tooltip disabled when bottom sheet opened`() { + startViewModelWithDefaultParameters() whenever(appPrefsWrapper.isMainFabTooltipDisabled()).thenReturn(true) viewModel.onFabClicked(true) verify(appPrefsWrapper).setMainFabTooltipDisabled(true) @@ -82,6 +113,7 @@ class WPMainActivityViewModelTest { @Test fun `fab tooltip disabled when fab long pressed`() { + startViewModelWithDefaultParameters() viewModel.onFabLongPressed(true) verify(appPrefsWrapper).setMainFabTooltipDisabled(true) assertThat(viewModel.fabUiState.value?.isFabTooltipVisible).isEqualTo(false) @@ -89,6 +121,7 @@ class WPMainActivityViewModelTest { @Test fun `bottom sheet action is new post when new post is tapped`() { + startViewModelWithDefaultParameters() val action = viewModel.mainActions.value?.first { it.actionType == CREATE_NEW_POST } as CreateAction assertThat(action).isNotNull action.onClickAction?.invoke(CREATE_NEW_POST) @@ -97,6 +130,7 @@ class WPMainActivityViewModelTest { @Test fun `bottom sheet action is new page when new page is tapped`() { + startViewModelWithDefaultParameters() val action = viewModel.mainActions.value?.first { it.actionType == CREATE_NEW_PAGE } as CreateAction assertThat(action).isNotNull action.onClickAction?.invoke(CREATE_NEW_PAGE) @@ -105,6 +139,7 @@ class WPMainActivityViewModelTest { @Test fun `bottom sheet is visualized when user has full access to content`() { + startViewModelWithDefaultParameters() viewModel.onFabClicked(hasFullAccessToContent = true) assertThat(viewModel.createAction.value).isNull() assertThat(viewModel.isBottomSheetShowing.value!!.peekContent()).isEqualTo(true) @@ -112,6 +147,7 @@ class WPMainActivityViewModelTest { @Test fun `new post action is triggered from FAB when user has not full access to content`() { + startViewModelWithDefaultParameters() viewModel.onFabClicked(hasFullAccessToContent = false) assertThat(viewModel.isBottomSheetShowing.value).isNull() assertThat(viewModel.createAction.value).isEqualTo(CREATE_NEW_POST) @@ -119,6 +155,7 @@ class WPMainActivityViewModelTest { @Test fun `when user taps to open the login page from the bottom sheet empty view cta the correct action is triggered`() { + startViewModelWithDefaultParameters() viewModel.onOpenLoginPage() assertThat(viewModel.startLoginFlow.value!!.peekContent()).isEqualTo(true) @@ -126,14 +163,100 @@ class WPMainActivityViewModelTest { @Test fun `onResume set expected content message when user has full access to content`() { + startViewModelWithDefaultParameters() viewModel.onResume(true) assertThat(viewModel.fabUiState.value!!.CreateContentMessageId).isEqualTo(R.string.create_post_page_fab_tooltip) } @Test fun `onResume set expected content message when user has not full access to content`() { + startViewModelWithDefaultParameters() viewModel.onResume(false) assertThat(viewModel.fabUiState.value!!.CreateContentMessageId) .isEqualTo(R.string.create_post_page_fab_tooltip_contributors) } + + @Test + fun `show feature announcement when it's available and no announcement was not shown before`() { + whenever(appPrefsWrapper.featureAnnouncementShownVersion).thenReturn(-1) + whenever(appPrefsWrapper.lastFeatureAnnouncementAppVersionCode).thenReturn(840) + whenever(featureAnnouncementProvider.getLatestFeatureAnnouncement()).thenReturn( + featureAnnouncement + ) + whenever(featureAnnouncementProvider.isFeatureAnnouncementAvailable()).thenReturn(true) + + startViewModelWithDefaultParameters() + + verify(onFeatureAnnouncementRequestedObserver).onChanged(anyOrNull()) + } + + @Test + fun `show feature announcement when it's available and previous announcement was for older build`() { + whenever(appPrefsWrapper.featureAnnouncementShownVersion).thenReturn(849) + whenever(appPrefsWrapper.lastFeatureAnnouncementAppVersionCode).thenReturn(840) + whenever(featureAnnouncementProvider.getLatestFeatureAnnouncement()).thenReturn( + featureAnnouncement + ) + whenever(featureAnnouncementProvider.isFeatureAnnouncementAvailable()).thenReturn(true) + + startViewModelWithDefaultParameters() + + verify(onFeatureAnnouncementRequestedObserver).onChanged(anyOrNull()) + } + + @Test + fun `don't show feature announcement on fresh app install`() { + whenever(appPrefsWrapper.lastFeatureAnnouncementAppVersionCode).thenReturn(0) + + startViewModelWithDefaultParameters() + + verify(onFeatureAnnouncementRequestedObserver, never()).onChanged(anyOrNull()) + verify(appPrefsWrapper).lastFeatureAnnouncementAppVersionCode = 850 + } + + @Test + fun `don't show feature announcement when it's not available`() { + whenever(appPrefsWrapper.lastFeatureAnnouncementAppVersionCode).thenReturn(840) + whenever(featureAnnouncementProvider.isFeatureAnnouncementAvailable()).thenReturn(false) + + startViewModelWithDefaultParameters() + + verify(onFeatureAnnouncementRequestedObserver, never()).onChanged(anyOrNull()) + } + + @Test + fun `don't show feature announcement when it's available but previous announcement is the same as current`() { + whenever(appPrefsWrapper.lastFeatureAnnouncementAppVersionCode).thenReturn(840) + whenever(appPrefsWrapper.featureAnnouncementShownVersion).thenReturn(850) + whenever(featureAnnouncementProvider.getLatestFeatureAnnouncement()).thenReturn( + featureAnnouncement + ) + whenever(featureAnnouncementProvider.isFeatureAnnouncementAvailable()).thenReturn(true) + + startViewModelWithDefaultParameters() + + verify(onFeatureAnnouncementRequestedObserver, never()).onChanged(anyOrNull()) + } + + @Test + fun `don't show feature announcement after view model starts again`() { + whenever(appPrefsWrapper.lastFeatureAnnouncementAppVersionCode).thenReturn(840) + whenever(appPrefsWrapper.featureAnnouncementShownVersion).thenReturn(-1) + whenever(featureAnnouncementProvider.getLatestFeatureAnnouncement()).thenReturn( + featureAnnouncement + ) + whenever(featureAnnouncementProvider.isFeatureAnnouncementAvailable()).thenReturn(true) + + startViewModelWithDefaultParameters() + + verify(onFeatureAnnouncementRequestedObserver).onChanged(anyOrNull()) + + startViewModelWithDefaultParameters() + + verify(onFeatureAnnouncementRequestedObserver, times(1)).onChanged(anyOrNull()) + } + + private fun startViewModelWithDefaultParameters() { + viewModel.start(isFabVisible = true, hasFullAccessToContent = true) + } } diff --git a/WordPress/src/test/java/org/wordpress/android/viewmodel/whatsnew/FeatureAnnouncementViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/viewmodel/whatsnew/FeatureAnnouncementViewModelTest.kt index 32fabaea9c2f..12366372ba1e 100644 --- a/WordPress/src/test/java/org/wordpress/android/viewmodel/whatsnew/FeatureAnnouncementViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/viewmodel/whatsnew/FeatureAnnouncementViewModelTest.kt @@ -43,7 +43,12 @@ class FeatureAnnouncementViewModelTest : BaseUnitTest() { ) ) - private val featureAnnouncement = FeatureAnnouncement("14.7", "https://wordpress.org/", testFeatures) + private val featureAnnouncement = FeatureAnnouncement( + "14.7", + 850, + "https://wordpress.org/", + testFeatures + ) @Before fun setUp() {