Skip to content

Commit e9ea108

Browse files
nbradburyclaude
andcommitted
Update UiModelMapperTest to match forced empty view behavior
Updated tests to expect UiModel.Empty since mapInsights currently returns the empty state for testing. Removed image assertion since the image parameter was removed from UiModel.Empty. Also fixed minor string typo. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent daefe67 commit e9ea108

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

WordPress/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@
14901490
<string name="stats_insights_linkedin">LinkedIn</string>
14911491
<string name="stats_insights_path">Path</string>
14921492
<string name="stats_most_popular_percent_views">%1$s of views</string>
1493-
<string name="stats_most_popular_percent_views_empty">Not enough activity. Check back when your site has had more visitors!</string>
1493+
<string name="stats_most_popular_percent_views_empty">Not enough activity. Check back when your site had more visitors!</string>
14941494
<string name="stats_insights_posting_activity">Posting Activity</string>
14951495
<string name="stats_insights_management_title">Manage your insights to see only the most relevant stats</string>
14961496

WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/UiModelMapperTest.kt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import org.wordpress.android.BaseUnitTest
99
import org.wordpress.android.R
1010
import org.wordpress.android.fluxc.store.StatsStore.InsightType.TOTAL_FOLLOWERS
1111
import org.wordpress.android.fluxc.store.StatsStore.ManagementType
12-
import org.wordpress.android.ui.stats.refresh.lists.StatsBlock.Success
1312
import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.UiModel
1413
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.UseCaseModel
1514
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.UseCaseModel.UseCaseState.SUCCESS
@@ -26,8 +25,9 @@ class UiModelMapperTest : BaseUnitTest() {
2625
mapper = UiModelMapper(networkUtilsWrapper)
2726
}
2827

28+
// TODO restore this test when removing the forced empty view in UiModelMapper.mapInsights
2929
@Test
30-
fun `mapInsights returns success ui model when all the inputs are successful`() {
30+
fun `mapInsights returns empty ui model`() {
3131
var error: Int? = null
3232
val uiModel = mapper.mapInsights(
3333
listOf(
@@ -38,14 +38,10 @@ class UiModelMapperTest : BaseUnitTest() {
3838
error = it
3939
}
4040

41-
val model = uiModel as UiModel.Success
42-
assertThat(model.data).hasSize(2)
43-
assertThat((model.data[0] as Success).statsType).isEqualTo(TOTAL_FOLLOWERS)
44-
assertThat(model.data[0].type).isEqualTo(StatsBlock.Type.SUCCESS)
45-
assertThat(model.data[0].data).isEmpty()
46-
assertThat((model.data[1] as Success).statsType).isEqualTo(ManagementType.CONTROL)
47-
assertThat(model.data[1].type).isEqualTo(StatsBlock.Type.SUCCESS)
48-
assertThat(model.data[1].data).isEmpty()
41+
val model = uiModel as UiModel.Empty
42+
assertThat(model.title).isEqualTo(R.string.stats_empty_insights_title)
43+
assertThat(model.subtitle).isEqualTo(R.string.stats_insights_management_title)
44+
assertThat(model.showButton).isTrue()
4945
assertThat(error).isNull()
5046
}
5147

@@ -64,7 +60,6 @@ class UiModelMapperTest : BaseUnitTest() {
6460
val model = uiModel as UiModel.Empty
6561
assertThat(model.title).isEqualTo(R.string.stats_empty_insights_title)
6662
assertThat(model.subtitle).isEqualTo(R.string.stats_insights_management_title)
67-
assertThat(model.image).isEqualTo(R.drawable.img_illustration_insights_94dp)
6863
assertThat(model.showButton).isTrue()
6964
assertThat(error).isNull()
7065
}

0 commit comments

Comments
 (0)