File tree Expand file tree Collapse file tree
main/java/org/wordpress/android/ui/posts/prepublishing/home
test/java/org/wordpress/android/ui/posts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,16 +123,18 @@ class PrepublishingHomeViewModel @Inject constructor(
123123 site
124124 )
125125
126- add(HomeUiState (
127- navigationAction = PrepublishingScreenNavigation .Categories ,
128- actionResult = if (categoriesString.isNotEmpty()) {
129- UiStringText (categoriesString)
130- } else {
131- run { UiStringRes (R .string.prepublishing_nudges_home_categories_not_set) }
132- },
133- actionClickable = true ,
134- onNavigationActionClicked = ::onActionClicked
135- ))
126+ if (! editPostRepository.isPage) {
127+ add(HomeUiState (
128+ navigationAction = PrepublishingScreenNavigation .Categories ,
129+ actionResult = if (categoriesString.isNotEmpty()) {
130+ UiStringText (categoriesString)
131+ } else {
132+ run { UiStringRes (R .string.prepublishing_nudges_home_categories_not_set) }
133+ },
134+ actionClickable = true ,
135+ onNavigationActionClicked = ::onActionClicked
136+ ))
137+ }
136138
137139 add(SocialUiState .Hidden )
138140
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ class PrepublishingHomeViewModelTest : BaseUnitTest() {
112112 @Test
113113 fun `verify that page home actions are propagated to prepublishingHomeUiState once the viewModel is started` () {
114114 // arrange
115- val expectedActionsAmount = 2
115+ val expectedActionsAmount = 1
116116 whenever(editPostRepository.isPage).thenReturn(true )
117117
118118 // act
@@ -148,6 +148,30 @@ class PrepublishingHomeViewModelTest : BaseUnitTest() {
148148 assertThat(getHomeUiState(PrepublishingScreenNavigation .Tags )).isNull()
149149 }
150150
151+ @Test
152+ fun `verify that categories actions is propagated to prepublishingHomeUiState once post is not a page` () {
153+ // arrange
154+ whenever(editPostRepository.isPage).thenReturn(false )
155+
156+ // act
157+ viewModel.start(editPostRepository, site, false )
158+
159+ // assert
160+ assertThat(getHomeUiState(PrepublishingScreenNavigation .Categories )).isNotNull()
161+ }
162+
163+ @Test
164+ fun `verify that categories actions is not propagated to prepublishingHomeUiState once post is a page` () {
165+ // arrange
166+ whenever(editPostRepository.isPage).thenReturn(true )
167+
168+ // act
169+ viewModel.start(editPostRepository, site, false )
170+
171+ // assert
172+ assertThat(getHomeUiState(PrepublishingScreenNavigation .Categories )).isNull()
173+ }
174+
151175 @Test
152176 fun `verify that header ui state is propagated to prepublishingHomeUiState once the viewModel is started` () {
153177 // arrange
You can’t perform that action at this time.
0 commit comments