@@ -42,13 +42,13 @@ import org.wordpress.android.util.SiteUtils.GB_EDITOR_NAME
4242import org.wordpress.android.viewmodel.mlp.ModalLayoutPickerViewModel.PageRequest.Blank
4343import org.wordpress.android.viewmodel.mlp.ModalLayoutPickerViewModel.PageRequest.Create
4444
45- @RunWith(MockitoJUnitRunner ::class )
4645@InternalCoroutinesApi
46+ @ExperimentalCoroutinesApi
47+ @RunWith(MockitoJUnitRunner ::class )
4748class ModalLayoutPickerViewModelTest {
4849 @Rule
4950 @JvmField val rule = InstantTaskExecutorRule ()
5051
51- @ExperimentalCoroutinesApi
5252 @Rule
5353 @JvmField val coroutineScope = MainCoroutineScopeRule ()
5454
@@ -104,7 +104,6 @@ class ModalLayoutPickerViewModelTest {
104104 )
105105 }
106106
107- @ExperimentalCoroutinesApi
108107 private fun <T > mockFetchingSelectedSite (
109108 isError : Boolean = false,
110109 isSiteUnavailable : Boolean = false,
@@ -144,67 +143,58 @@ class ModalLayoutPickerViewModelTest {
144143 }
145144 }
146145
147- @ExperimentalCoroutinesApi
148146 @Test
149147 fun `when the user scroll beyond a threshold the title becomes visible` () = mockFetchingSelectedSite {
150148 viewModel.createPageFlowTriggered()
151149 viewModel.onAppBarOffsetChanged(9 , 10 )
152150 assertThat(requireNotNull(viewModel.uiState.value as Content ).isHeaderVisible).isEqualTo(true )
153151 }
154152
155- @ExperimentalCoroutinesApi
156153 @Test
157154 fun `when the user scroll bellow a threshold the title remains hidden` () = mockFetchingSelectedSite {
158155 viewModel.createPageFlowTriggered()
159156 viewModel.onAppBarOffsetChanged(11 , 10 )
160157 assertThat(requireNotNull(viewModel.uiState.value as Content ).isHeaderVisible).isEqualTo(false )
161158 }
162159
163- @ExperimentalCoroutinesApi
164160 @Test
165161 fun `when modal layout picker starts the categories are loaded` () = mockFetchingSelectedSite {
166162 viewModel.createPageFlowTriggered()
167163 assertThat(requireNotNull(viewModel.uiState.value as Content ).categories.size).isGreaterThan(0 )
168164 }
169165
170- @ExperimentalCoroutinesApi
171166 @Test
172167 fun `when modal layout picker starts the layouts are loaded` () = mockFetchingSelectedSite {
173168 viewModel.createPageFlowTriggered()
174169 assertThat(requireNotNull(viewModel.uiState.value as Content ).layoutCategories.size).isGreaterThan(0 )
175170 }
176171
177- @ExperimentalCoroutinesApi
178172 @Test
179173 fun `when modal layout picker starts fetch errors are handled` () = mockFetchingSelectedSite(true ) {
180174 viewModel.createPageFlowTriggered()
181175 assertThat(viewModel.uiState.value is Error ).isEqualTo(true )
182176 }
183177
184- @ExperimentalCoroutinesApi
185178 @Test
186179 fun `when modal layout picker starts and the site is unavailable errors are handled` () =
187180 mockFetchingSelectedSite(isSiteUnavailable = true ) {
188181 viewModel.createPageFlowTriggered()
189182 assertThat(viewModel.uiState.value is Error ).isEqualTo(true )
190183 }
191184
192- @ExperimentalCoroutinesApi
193185 @Test
194186 fun `modal layout picker is shown when triggered` () = mockFetchingSelectedSite {
195187 viewModel.createPageFlowTriggered()
196188 assertThat(viewModel.isModalLayoutPickerShowing.value!! .peekContent()).isEqualTo(true )
197189 }
198190
199- @ExperimentalCoroutinesApi
200191 @Test
201192 fun `modal layout picker is dismissed when the user hits the back button` () = mockFetchingSelectedSite {
202193 viewModel.createPageFlowTriggered()
203194 viewModel.dismiss()
204195 assertThat(viewModel.isModalLayoutPickerShowing.value!! .peekContent()).isEqualTo(false )
205196 }
206197
207- @ExperimentalCoroutinesApi
208198 @Test
209199 fun `when no layout is selected and the create page is triggered the blank page creation flow starts` () =
210200 mockFetchingSelectedSite {
@@ -215,7 +205,6 @@ class ModalLayoutPickerViewModelTest {
215205 assertThat(captor.value).isEqualTo(Blank )
216206 }
217207
218- @ExperimentalCoroutinesApi
219208 @Test
220209 fun `when a layout is selected and the create page is triggered the page creation flow starts with a template` () =
221210 mockFetchingSelectedSite {
@@ -228,14 +217,12 @@ class ModalLayoutPickerViewModelTest {
228217 assertThat(captor.value.template).isEqualTo(" about" )
229218 }
230219
231- @ExperimentalCoroutinesApi
232220 @Test
233221 fun `when modal layout picker starts no layout is selected` () = mockFetchingSelectedSite {
234222 viewModel.createPageFlowTriggered()
235223 assertThat(requireNotNull(viewModel.uiState.value as Content ).selectedLayoutSlug).isNull()
236224 }
237225
238- @ExperimentalCoroutinesApi
239226 @Test
240227 fun `when the user taps on a layout the layout is selected if the thumbnail has loaded` () =
241228 mockFetchingSelectedSite {
@@ -246,7 +233,6 @@ class ModalLayoutPickerViewModelTest {
246233 .isEqualTo(" about-1" )
247234 }
248235
249- @ExperimentalCoroutinesApi
250236 @Test
251237 fun `when the user taps on a layout the layout is selected if the thumbnail has not loaded` () =
252238 mockFetchingSelectedSite {
@@ -256,7 +242,6 @@ class ModalLayoutPickerViewModelTest {
256242 .isNotEqualTo(" about-1" )
257243 }
258244
259- @ExperimentalCoroutinesApi
260245 @Test
261246 fun `when the user taps on a selected layout the layout is deselected` () = mockFetchingSelectedSite {
262247 viewModel.createPageFlowTriggered()
@@ -265,7 +250,6 @@ class ModalLayoutPickerViewModelTest {
265250 assertThat(requireNotNull(viewModel.uiState.value as Content ).selectedLayoutSlug).isNull()
266251 }
267252
268- @ExperimentalCoroutinesApi
269253 @Test
270254 fun `when the modal layout picker is dismissed the layout is deselected` () = mockFetchingSelectedSite {
271255 viewModel.createPageFlowTriggered()
@@ -274,14 +258,12 @@ class ModalLayoutPickerViewModelTest {
274258 assertThat(requireNotNull(viewModel.uiState.value as Content ).selectedLayoutSlug).isNull()
275259 }
276260
277- @ExperimentalCoroutinesApi
278261 @Test
279262 fun `when modal layout picker starts no category is selected` () = mockFetchingSelectedSite {
280263 viewModel.createPageFlowTriggered()
281264 assertThat(requireNotNull(viewModel.uiState.value as Content ).selectedCategoriesSlugs).isEmpty()
282265 }
283266
284- @ExperimentalCoroutinesApi
285267 @Test
286268 fun `when the user taps on a category the category is selected` () = mockFetchingSelectedSite {
287269 viewModel.createPageFlowTriggered()
@@ -290,7 +272,6 @@ class ModalLayoutPickerViewModelTest {
290272 .contains(" about" )
291273 }
292274
293- @ExperimentalCoroutinesApi
294275 @Test
295276 fun `when the user taps on a selected category the category is deselected` () = mockFetchingSelectedSite {
296277 viewModel.createPageFlowTriggered()
@@ -300,7 +281,6 @@ class ModalLayoutPickerViewModelTest {
300281 .doesNotContain(" about" )
301282 }
302283
303- @ExperimentalCoroutinesApi
304284 @Test
305285 fun `when the modal layout picker is dismissed the category is deselected` () = mockFetchingSelectedSite {
306286 viewModel.createPageFlowTriggered()
@@ -309,15 +289,13 @@ class ModalLayoutPickerViewModelTest {
309289 assertThat(requireNotNull(viewModel.uiState.value as Content ).selectedCategoriesSlugs).isEmpty()
310290 }
311291
312- @ExperimentalCoroutinesApi
313292 @Test
314293 fun `when no layout is selected the create blank page button is visible` () = mockFetchingSelectedSite {
315294 viewModel.createPageFlowTriggered()
316295 assertThat(requireNotNull(viewModel.uiState.value as Content ).buttonsUiState.createBlankPageVisible)
317296 .isEqualTo(true )
318297 }
319298
320- @ExperimentalCoroutinesApi
321299 @Test
322300 fun `when a layout is selected the create blank page button is not visible` () = mockFetchingSelectedSite {
323301 viewModel.createPageFlowTriggered()
@@ -327,15 +305,13 @@ class ModalLayoutPickerViewModelTest {
327305 .isEqualTo(false )
328306 }
329307
330- @ExperimentalCoroutinesApi
331308 @Test
332309 fun `when no layout is selected the create page button is not visible` () = mockFetchingSelectedSite {
333310 viewModel.createPageFlowTriggered()
334311 assertThat(requireNotNull(viewModel.uiState.value as Content ).buttonsUiState.createPageVisible)
335312 .isEqualTo(false )
336313 }
337314
338- @ExperimentalCoroutinesApi
339315 @Test
340316 fun `when a layout is selected the create page button is visible` () = mockFetchingSelectedSite {
341317 viewModel.createPageFlowTriggered()
@@ -345,15 +321,13 @@ class ModalLayoutPickerViewModelTest {
345321 .isEqualTo(true )
346322 }
347323
348- @ExperimentalCoroutinesApi
349324 @Test
350325 fun `when no layout is selected the preview button is not visible` () = mockFetchingSelectedSite {
351326 viewModel.createPageFlowTriggered()
352327 assertThat(requireNotNull(viewModel.uiState.value as Content ).buttonsUiState.previewVisible)
353328 .isEqualTo(false )
354329 }
355330
356- @ExperimentalCoroutinesApi
357331 @Test
358332 fun `when a layout is selected the preview button is visible` () = mockFetchingSelectedSite {
359333 viewModel.createPageFlowTriggered()
0 commit comments