Skip to content

Commit

Permalink
Added new tests and updated ActivityRouter to fix failing CI
Browse files Browse the repository at this point in the history
  • Loading branch information
vrajdesai78 committed Oct 5, 2022
1 parent 9c06752 commit 6c8221c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ class ActivityRouter @Inject constructor(
/** Opens the activity corresponding to the specified [destinationScreen]. */
fun routeToScreen(destinationScreen: DestinationScreen) {
destinationRoutes[destinationScreen.destinationScreenCase]?.let { route ->
when (destinationScreen.destinationScreenCase) {
DestinationScreenCase.RECENTLY_PLAYED_ACTIVITY_PARAMS -> {
activity.startActivity(
route.createIntent(
activity,
destinationScreen
)
if (destinationScreen.destinationScreenCase ==
DestinationScreenCase.RECENTLY_PLAYED_ACTIVITY_PARAMS
) {
activity.startActivity(
route.createIntent(
activity,
destinationScreen
)
}
DestinationScreenCase.DESTINATIONSCREEN_NOT_SET, null -> {
consoleLogger.w("ActivityRouter", "Destination screen case is not identified.")
}
)
}
}
if (destinationScreen.destinationScreenCase ==
DestinationScreenCase.DESTINATIONSCREEN_NOT_SET
) {
consoleLogger.w("ActivityRouter", "Destination screen case is not identified.")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ class ProfileProgressFragmentTest {
}

@Test
fun testProfileProgressFragment_clickViewAll_opensRecentlyPlayedActivity() {
fun testClickViewAll_withLessThanTwoStories_opensRecentlyPlayedActivityWithStoriesForYouTitle() {
storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0(
profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(),
timestampOlderThanOneWeek = false
Expand All @@ -685,6 +685,42 @@ class ProfileProgressFragmentTest {
}
}

@Test
fun testClickViewAll_opensRecentlyPlayedActivityWithRecentlyPlayedActivityTitle() {
storyProgressTestHelper.markCompletedFractionsStory0(
profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(),
timestampOlderThanOneWeek = false
)
storyProgressTestHelper.markCompletedRatiosStory0(
profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(),
timestampOlderThanOneWeek = false
)
storyProgressTestHelper.markInProgressNotSavedTestTopic0Story0(
profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(),
timestampOlderThanOneWeek = false
)
launch<ProfileProgressActivity>(createProfileProgressActivityIntent(internalProfileId)).use {
testCoroutineDispatchers.runCurrent()
verifyItemDisplayedOnProfileProgressListItem(
itemPosition = 0,
targetViewId = R.id.view_all_text_view,
stringToMatch = "View All"
)
val recentlyPlayedActivityParams = RecentlyPlayedActivityParams
.newBuilder()
.setProfileId(ProfileId.newBuilder().setInternalId(internalProfileId).build())
.setActivityTitle(RecentlyPlayedActivityTitle.RECENTLY_PLAYED_STORIES)
.build()
clickProfileProgressItem(itemPosition = 0, targetViewId = R.id.view_all_text_view)
intended(
allOf(
hasProtoExtra(RECENTLY_PLAYED_ACTIVITY_INTENT_EXTRAS_KEY, recentlyPlayedActivityParams),
hasComponent(RecentlyPlayedActivity::class.java.name)
)
)
}
}

@Test
fun testProfileProgressFragment_noProgress_topicCountIsNotClickable() {
launch<ProfileProgressActivity>(createProfileProgressActivityIntent(internalProfileId)).use {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ class ActivityRouterModuleTest {

@Test
fun testInjectDestinationRoutes_hasRouteForRecentlyPlayedActivity() {
assertThat(
destinationRoutes.containsKey(DestinationScreenCase.RECENTLY_PLAYED_ACTIVITY_PARAMS)
).isTrue()
assertThat(destinationRoutes).containsKey(DestinationScreenCase.RECENTLY_PLAYED_ACTIVITY_PARAMS)
val route = destinationRoutes[DestinationScreenCase.RECENTLY_PLAYED_ACTIVITY_PARAMS]
val intent = route?.createIntent(context, DestinationScreen.getDefaultInstance())
assertThat(intent).hasComponentClass(RecentlyPlayedActivity::class.java)
Expand Down

0 comments on commit 6c8221c

Please sign in to comment.