|
|
@ -16,7 +16,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
package com.google.samples.apps.nowinandroid.feature.foryou
|
|
|
|
package com.google.samples.apps.nowinandroid.feature.foryou
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.lifecycle.SavedStateHandle
|
|
|
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.domain.GetFollowableTopicsStreamUseCase
|
|
|
|
import com.google.samples.apps.nowinandroid.core.domain.GetFollowableTopicsStreamUseCase
|
|
|
|
import com.google.samples.apps.nowinandroid.core.domain.GetSaveableNewsResourcesStreamUseCase
|
|
|
|
import com.google.samples.apps.nowinandroid.core.domain.GetSaveableNewsResourcesStreamUseCase
|
|
|
|
import com.google.samples.apps.nowinandroid.core.domain.GetSortedFollowableAuthorsStreamUseCase
|
|
|
|
import com.google.samples.apps.nowinandroid.core.domain.GetSortedFollowableAuthorsStreamUseCase
|
|
|
@ -65,7 +64,8 @@ class ForYouViewModelTest {
|
|
|
|
userDataRepository = userDataRepository
|
|
|
|
userDataRepository = userDataRepository
|
|
|
|
)
|
|
|
|
)
|
|
|
|
private val getSortedFollowableAuthorsStream = GetSortedFollowableAuthorsStreamUseCase(
|
|
|
|
private val getSortedFollowableAuthorsStream = GetSortedFollowableAuthorsStreamUseCase(
|
|
|
|
authorsRepository = authorsRepository
|
|
|
|
authorsRepository = authorsRepository,
|
|
|
|
|
|
|
|
userDataRepository = userDataRepository
|
|
|
|
)
|
|
|
|
)
|
|
|
|
private val getFollowableTopicsStreamUseCase = GetFollowableTopicsStreamUseCase(
|
|
|
|
private val getFollowableTopicsStreamUseCase = GetFollowableTopicsStreamUseCase(
|
|
|
|
topicsRepository = topicsRepository,
|
|
|
|
topicsRepository = topicsRepository,
|
|
|
@ -80,16 +80,15 @@ class ForYouViewModelTest {
|
|
|
|
userDataRepository = userDataRepository,
|
|
|
|
userDataRepository = userDataRepository,
|
|
|
|
getSaveableNewsResourcesStream = getSaveableNewsResourcesStreamUseCase,
|
|
|
|
getSaveableNewsResourcesStream = getSaveableNewsResourcesStreamUseCase,
|
|
|
|
getSortedFollowableAuthorsStream = getSortedFollowableAuthorsStream,
|
|
|
|
getSortedFollowableAuthorsStream = getSortedFollowableAuthorsStream,
|
|
|
|
getFollowableTopicsStream = getFollowableTopicsStreamUseCase,
|
|
|
|
getFollowableTopicsStream = getFollowableTopicsStreamUseCase
|
|
|
|
savedStateHandle = SavedStateHandle()
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun stateIsInitiallyLoading() = runTest {
|
|
|
|
fun stateIsInitiallyLoading() = runTest {
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.Loading,
|
|
|
|
OnboardingUiState.Loading,
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(NewsFeedUiState.Loading, viewModel.feedState.value)
|
|
|
|
assertEquals(NewsFeedUiState.Loading, viewModel.feedState.value)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -97,14 +96,14 @@ class ForYouViewModelTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun stateIsLoadingWhenFollowedTopicsAreLoading() = runTest {
|
|
|
|
fun stateIsLoadingWhenFollowedTopicsAreLoading() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
val collectJob1 =
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.Loading,
|
|
|
|
OnboardingUiState.Loading,
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(NewsFeedUiState.Loading, viewModel.feedState.value)
|
|
|
|
assertEquals(NewsFeedUiState.Loading, viewModel.feedState.value)
|
|
|
|
|
|
|
|
|
|
|
@ -130,14 +129,14 @@ class ForYouViewModelTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun stateIsLoadingWhenFollowedAuthorsAreLoading() = runTest {
|
|
|
|
fun stateIsLoadingWhenFollowedAuthorsAreLoading() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
val collectJob1 =
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
authorsRepository.sendAuthors(sampleAuthors)
|
|
|
|
authorsRepository.sendAuthors(sampleAuthors)
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.Loading,
|
|
|
|
OnboardingUiState.Loading,
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(NewsFeedUiState.Loading, viewModel.feedState.value)
|
|
|
|
assertEquals(NewsFeedUiState.Loading, viewModel.feedState.value)
|
|
|
|
|
|
|
|
|
|
|
@ -146,16 +145,16 @@ class ForYouViewModelTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun stateIsLoadingWhenTopicsAreLoading() = runTest {
|
|
|
|
fun onboardingStateIsLoadingWhenTopicsAreLoading() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
val collectJob1 =
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.Loading,
|
|
|
|
OnboardingUiState.Loading,
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(NewsFeedUiState.Success(emptyList()), viewModel.feedState.value)
|
|
|
|
assertEquals(NewsFeedUiState.Success(emptyList()), viewModel.feedState.value)
|
|
|
|
|
|
|
|
|
|
|
@ -164,16 +163,16 @@ class ForYouViewModelTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun stateIsLoadingWhenAuthorsAreLoading() = runTest {
|
|
|
|
fun onboardingStateIsLoadingWhenAuthorsAreLoading() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
val collectJob1 =
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
userDataRepository.setFollowedAuthorIds(emptySet())
|
|
|
|
userDataRepository.setFollowedAuthorIds(emptySet())
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.Loading,
|
|
|
|
OnboardingUiState.Loading,
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(NewsFeedUiState.Success(emptyList()), viewModel.feedState.value)
|
|
|
|
assertEquals(NewsFeedUiState.Success(emptyList()), viewModel.feedState.value)
|
|
|
|
|
|
|
|
|
|
|
@ -182,9 +181,9 @@ class ForYouViewModelTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun stateIsInterestsSelectionWhenNewsResourcesAreLoading() = runTest {
|
|
|
|
fun onboardingIsShownWhenNewsResourcesAreLoading() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
val collectJob1 =
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
@ -193,7 +192,7 @@ class ForYouViewModelTest {
|
|
|
|
userDataRepository.setFollowedAuthorIds(emptySet())
|
|
|
|
userDataRepository.setFollowedAuthorIds(emptySet())
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.WithInterestsSelection(
|
|
|
|
OnboardingUiState.Shown(
|
|
|
|
topics = listOf(
|
|
|
|
topics = listOf(
|
|
|
|
FollowableTopic(
|
|
|
|
FollowableTopic(
|
|
|
|
topic = Topic(
|
|
|
|
topic = Topic(
|
|
|
@ -265,7 +264,7 @@ class ForYouViewModelTest {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
@ -279,9 +278,9 @@ class ForYouViewModelTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun stateIsInterestsSelectionAfterLoadingEmptyFollowedTopicsAndAuthors() = runTest {
|
|
|
|
fun onboardingIsShownAfterLoadingEmptyFollowedTopicsAndAuthors() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
val collectJob1 =
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
@ -291,7 +290,7 @@ class ForYouViewModelTest {
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.WithInterestsSelection(
|
|
|
|
OnboardingUiState.Shown(
|
|
|
|
topics = listOf(
|
|
|
|
topics = listOf(
|
|
|
|
FollowableTopic(
|
|
|
|
FollowableTopic(
|
|
|
|
topic = Topic(
|
|
|
|
topic = Topic(
|
|
|
@ -363,7 +362,7 @@ class ForYouViewModelTest {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
@ -378,27 +377,28 @@ class ForYouViewModelTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun stateIsWithoutInterestsSelectionAfterLoadingFollowedTopics() = runTest {
|
|
|
|
fun onboardingIsNotShownAfterUserDismissesOnboarding() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
val collectJob1 =
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
authorsRepository.sendAuthors(sampleAuthors)
|
|
|
|
authorsRepository.sendAuthors(sampleAuthors)
|
|
|
|
userDataRepository.setFollowedAuthorIds(emptySet())
|
|
|
|
userDataRepository.setFollowedAuthorIds(emptySet())
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
userDataRepository.setFollowedTopicIds(setOf("0", "1"))
|
|
|
|
userDataRepository.setFollowedTopicIds(setOf("0", "1"))
|
|
|
|
|
|
|
|
viewModel.dismissOnboarding()
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.NoInterestsSelection,
|
|
|
|
OnboardingUiState.NotShown,
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(NewsFeedUiState.Loading, viewModel.feedState.value)
|
|
|
|
assertEquals(NewsFeedUiState.Loading, viewModel.feedState.value)
|
|
|
|
|
|
|
|
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.NoInterestsSelection,
|
|
|
|
OnboardingUiState.NotShown,
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
@ -417,52 +417,10 @@ class ForYouViewModelTest {
|
|
|
|
collectJob2.cancel()
|
|
|
|
collectJob2.cancel()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun stateIsWithoutInterestsSelectionAfterLoadingFollowedAuthors() = runTest {
|
|
|
|
|
|
|
|
val collectJob1 =
|
|
|
|
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
authorsRepository.sendAuthors(sampleAuthors)
|
|
|
|
|
|
|
|
userDataRepository.setFollowedAuthorIds(setOf("0", "1"))
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
ForYouInterestsSelectionUiState.NoInterestsSelection,
|
|
|
|
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
NewsFeedUiState.Loading,
|
|
|
|
|
|
|
|
viewModel.feedState.value
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
ForYouInterestsSelectionUiState.NoInterestsSelection,
|
|
|
|
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
|
|
|
|
feed = sampleNewsResources.map {
|
|
|
|
|
|
|
|
SaveableNewsResource(
|
|
|
|
|
|
|
|
newsResource = it,
|
|
|
|
|
|
|
|
isSaved = false
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
viewModel.feedState.value
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
collectJob1.cancel()
|
|
|
|
|
|
|
|
collectJob2.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun topicSelectionUpdatesAfterSelectingTopic() = runTest {
|
|
|
|
fun topicSelectionUpdatesAfterSelectingTopic() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
val collectJob1 =
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
@ -472,7 +430,7 @@ class ForYouViewModelTest {
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.WithInterestsSelection(
|
|
|
|
OnboardingUiState.Shown(
|
|
|
|
topics = listOf(
|
|
|
|
topics = listOf(
|
|
|
|
FollowableTopic(
|
|
|
|
FollowableTopic(
|
|
|
|
topic = Topic(
|
|
|
|
topic = Topic(
|
|
|
@ -544,7 +502,7 @@ class ForYouViewModelTest {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
@ -556,7 +514,7 @@ class ForYouViewModelTest {
|
|
|
|
viewModel.updateTopicSelection("1", isChecked = true)
|
|
|
|
viewModel.updateTopicSelection("1", isChecked = true)
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.WithInterestsSelection(
|
|
|
|
OnboardingUiState.Shown(
|
|
|
|
topics = listOf(
|
|
|
|
topics = listOf(
|
|
|
|
FollowableTopic(
|
|
|
|
FollowableTopic(
|
|
|
|
topic = Topic(
|
|
|
|
topic = Topic(
|
|
|
@ -628,7 +586,7 @@ class ForYouViewModelTest {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
@ -651,9 +609,9 @@ class ForYouViewModelTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun topicSelectionUpdatesAfterSelectingAuthor() = runTest {
|
|
|
|
fun authorSelectionUpdatesAfterSelectingAuthor() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
val collectJob1 =
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
@ -663,7 +621,7 @@ class ForYouViewModelTest {
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.WithInterestsSelection(
|
|
|
|
OnboardingUiState.Shown(
|
|
|
|
topics = listOf(
|
|
|
|
topics = listOf(
|
|
|
|
FollowableTopic(
|
|
|
|
FollowableTopic(
|
|
|
|
topic = Topic(
|
|
|
|
topic = Topic(
|
|
|
@ -735,7 +693,7 @@ class ForYouViewModelTest {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
@ -747,7 +705,7 @@ class ForYouViewModelTest {
|
|
|
|
viewModel.updateAuthorSelection("1", isChecked = true)
|
|
|
|
viewModel.updateAuthorSelection("1", isChecked = true)
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.WithInterestsSelection(
|
|
|
|
OnboardingUiState.Shown(
|
|
|
|
topics = listOf(
|
|
|
|
topics = listOf(
|
|
|
|
FollowableTopic(
|
|
|
|
FollowableTopic(
|
|
|
|
topic = Topic(
|
|
|
|
topic = Topic(
|
|
|
@ -819,7 +777,7 @@ class ForYouViewModelTest {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
@ -844,7 +802,7 @@ class ForYouViewModelTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun topicSelectionUpdatesAfterUnselectingTopic() = runTest {
|
|
|
|
fun topicSelectionUpdatesAfterUnselectingTopic() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
val collectJob1 =
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
@ -857,7 +815,7 @@ class ForYouViewModelTest {
|
|
|
|
|
|
|
|
|
|
|
|
advanceUntilIdle()
|
|
|
|
advanceUntilIdle()
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.WithInterestsSelection(
|
|
|
|
OnboardingUiState.Shown(
|
|
|
|
topics = listOf(
|
|
|
|
topics = listOf(
|
|
|
|
FollowableTopic(
|
|
|
|
FollowableTopic(
|
|
|
|
topic = Topic(
|
|
|
|
topic = Topic(
|
|
|
@ -929,7 +887,7 @@ class ForYouViewModelTest {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
@ -943,9 +901,9 @@ class ForYouViewModelTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun topicSelectionUpdatesAfterUnselectingAuthor() = runTest {
|
|
|
|
fun authorSelectionUpdatesAfterUnselectingAuthor() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
val collectJob1 =
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
@ -958,7 +916,7 @@ class ForYouViewModelTest {
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
|
|
|
|
ForYouInterestsSelectionUiState.WithInterestsSelection(
|
|
|
|
OnboardingUiState.Shown(
|
|
|
|
topics = listOf(
|
|
|
|
topics = listOf(
|
|
|
|
FollowableTopic(
|
|
|
|
FollowableTopic(
|
|
|
|
topic = Topic(
|
|
|
|
topic = Topic(
|
|
|
@ -1030,331 +988,7 @@ class ForYouViewModelTest {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
|
|
|
|
feed = emptyList()
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
viewModel.feedState.value
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
collectJob1.cancel()
|
|
|
|
|
|
|
|
collectJob2.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun topicSelectionUpdatesAfterSavingTopicsOnly() = runTest {
|
|
|
|
|
|
|
|
val collectJob1 =
|
|
|
|
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
|
|
|
|
authorsRepository.sendAuthors(sampleAuthors)
|
|
|
|
|
|
|
|
userDataRepository.setFollowedAuthorIds(emptySet())
|
|
|
|
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
|
|
|
|
viewModel.updateTopicSelection("1", isChecked = true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
viewModel.saveFollowedInterests()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
ForYouInterestsSelectionUiState.NoInterestsSelection,
|
|
|
|
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
|
|
|
|
feed = listOf(
|
|
|
|
|
|
|
|
SaveableNewsResource(
|
|
|
|
|
|
|
|
newsResource = sampleNewsResources[1],
|
|
|
|
|
|
|
|
isSaved = false,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
SaveableNewsResource(
|
|
|
|
|
|
|
|
newsResource = sampleNewsResources[2],
|
|
|
|
|
|
|
|
isSaved = false,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
viewModel.feedState.value
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(setOf("1"), userDataRepository.getCurrentFollowedTopics())
|
|
|
|
|
|
|
|
assertEquals(emptySet<Int>(), userDataRepository.getCurrentFollowedAuthors())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
collectJob1.cancel()
|
|
|
|
|
|
|
|
collectJob2.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun topicSelectionUpdatesAfterSavingAuthorsOnly() = runTest {
|
|
|
|
|
|
|
|
val collectJob1 =
|
|
|
|
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
|
|
|
|
authorsRepository.sendAuthors(sampleAuthors)
|
|
|
|
|
|
|
|
userDataRepository.setFollowedAuthorIds(emptySet())
|
|
|
|
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
|
|
|
|
viewModel.updateAuthorSelection("0", isChecked = true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
viewModel.saveFollowedInterests()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
ForYouInterestsSelectionUiState.NoInterestsSelection,
|
|
|
|
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
|
|
|
|
feed = listOf(
|
|
|
|
|
|
|
|
SaveableNewsResource(
|
|
|
|
|
|
|
|
newsResource = sampleNewsResources[0],
|
|
|
|
|
|
|
|
isSaved = false
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
viewModel.feedState.value
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(emptySet<Int>(), userDataRepository.getCurrentFollowedTopics())
|
|
|
|
|
|
|
|
assertEquals(setOf("0"), userDataRepository.getCurrentFollowedAuthors())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
collectJob1.cancel()
|
|
|
|
|
|
|
|
collectJob2.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun topicSelectionUpdatesAfterSavingAuthorsAndTopics() = runTest {
|
|
|
|
|
|
|
|
val collectJob1 =
|
|
|
|
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
|
|
|
|
authorsRepository.sendAuthors(sampleAuthors)
|
|
|
|
|
|
|
|
userDataRepository.setFollowedAuthorIds(emptySet())
|
|
|
|
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
|
|
|
|
viewModel.updateAuthorSelection("1", isChecked = true)
|
|
|
|
|
|
|
|
viewModel.updateTopicSelection("1", isChecked = true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
viewModel.saveFollowedInterests()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
ForYouInterestsSelectionUiState.NoInterestsSelection,
|
|
|
|
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
|
|
|
|
feed = listOf(
|
|
|
|
|
|
|
|
SaveableNewsResource(
|
|
|
|
|
|
|
|
newsResource = sampleNewsResources[1],
|
|
|
|
|
|
|
|
isSaved = false
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
SaveableNewsResource(
|
|
|
|
|
|
|
|
newsResource = sampleNewsResources[2],
|
|
|
|
|
|
|
|
isSaved = false
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
viewModel.feedState.value
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(setOf("1"), userDataRepository.getCurrentFollowedTopics())
|
|
|
|
|
|
|
|
assertEquals(setOf("1"), userDataRepository.getCurrentFollowedAuthors())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
collectJob1.cancel()
|
|
|
|
|
|
|
|
collectJob2.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun topicSelectionIsResetAfterSavingTopicsAndRemovingThem() = runTest {
|
|
|
|
|
|
|
|
val collectJob1 =
|
|
|
|
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
|
|
|
|
authorsRepository.sendAuthors(sampleAuthors)
|
|
|
|
|
|
|
|
userDataRepository.setFollowedAuthorIds(emptySet())
|
|
|
|
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
|
|
|
|
viewModel.updateTopicSelection("1", isChecked = true)
|
|
|
|
|
|
|
|
viewModel.saveFollowedInterests()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
ForYouInterestsSelectionUiState.WithInterestsSelection(
|
|
|
|
|
|
|
|
topics = listOf(
|
|
|
|
|
|
|
|
FollowableTopic(
|
|
|
|
|
|
|
|
topic = Topic(
|
|
|
|
|
|
|
|
id = "0",
|
|
|
|
|
|
|
|
name = "Headlines",
|
|
|
|
|
|
|
|
shortDescription = "",
|
|
|
|
|
|
|
|
longDescription = "long description",
|
|
|
|
|
|
|
|
url = "URL",
|
|
|
|
|
|
|
|
imageUrl = "image URL",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
isFollowed = false
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
FollowableTopic(
|
|
|
|
|
|
|
|
topic = Topic(
|
|
|
|
|
|
|
|
id = "1",
|
|
|
|
|
|
|
|
name = "UI",
|
|
|
|
|
|
|
|
shortDescription = "",
|
|
|
|
|
|
|
|
longDescription = "long description",
|
|
|
|
|
|
|
|
url = "URL",
|
|
|
|
|
|
|
|
imageUrl = "image URL",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
isFollowed = false
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
FollowableTopic(
|
|
|
|
|
|
|
|
topic = Topic(
|
|
|
|
|
|
|
|
id = "2",
|
|
|
|
|
|
|
|
name = "Tools",
|
|
|
|
|
|
|
|
shortDescription = "",
|
|
|
|
|
|
|
|
longDescription = "long description",
|
|
|
|
|
|
|
|
url = "URL",
|
|
|
|
|
|
|
|
imageUrl = "image URL",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
isFollowed = false
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
authors = listOf(
|
|
|
|
|
|
|
|
FollowableAuthor(
|
|
|
|
|
|
|
|
author = Author(
|
|
|
|
|
|
|
|
id = "0",
|
|
|
|
|
|
|
|
name = "Android Dev",
|
|
|
|
|
|
|
|
imageUrl = "",
|
|
|
|
|
|
|
|
twitter = "",
|
|
|
|
|
|
|
|
mediumPage = "",
|
|
|
|
|
|
|
|
bio = "",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
isFollowed = false
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
FollowableAuthor(
|
|
|
|
|
|
|
|
author = Author(
|
|
|
|
|
|
|
|
id = "1",
|
|
|
|
|
|
|
|
name = "Android Dev 2",
|
|
|
|
|
|
|
|
imageUrl = "",
|
|
|
|
|
|
|
|
twitter = "",
|
|
|
|
|
|
|
|
mediumPage = "",
|
|
|
|
|
|
|
|
bio = "",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
isFollowed = false
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
FollowableAuthor(
|
|
|
|
|
|
|
|
author = Author(
|
|
|
|
|
|
|
|
id = "2",
|
|
|
|
|
|
|
|
name = "Android Dev 3",
|
|
|
|
|
|
|
|
imageUrl = "",
|
|
|
|
|
|
|
|
twitter = "",
|
|
|
|
|
|
|
|
mediumPage = "",
|
|
|
|
|
|
|
|
bio = "",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
isFollowed = false
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
|
|
|
|
feed = emptyList()
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
viewModel.feedState.value
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
collectJob1.cancel()
|
|
|
|
|
|
|
|
collectJob2.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun authorSelectionIsResetAfterSavingAuthorsAndRemovingThem() = runTest {
|
|
|
|
|
|
|
|
val collectJob1 =
|
|
|
|
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
|
|
|
|
authorsRepository.sendAuthors(sampleAuthors)
|
|
|
|
|
|
|
|
userDataRepository.setFollowedAuthorIds(emptySet())
|
|
|
|
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
|
|
|
|
viewModel.updateAuthorSelection("1", isChecked = true)
|
|
|
|
|
|
|
|
viewModel.saveFollowedInterests()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
userDataRepository.setFollowedAuthorIds(emptySet())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
ForYouInterestsSelectionUiState.WithInterestsSelection(
|
|
|
|
|
|
|
|
topics = listOf(
|
|
|
|
|
|
|
|
FollowableTopic(
|
|
|
|
|
|
|
|
topic = Topic(
|
|
|
|
|
|
|
|
id = "0",
|
|
|
|
|
|
|
|
name = "Headlines",
|
|
|
|
|
|
|
|
shortDescription = "",
|
|
|
|
|
|
|
|
longDescription = "long description",
|
|
|
|
|
|
|
|
url = "URL",
|
|
|
|
|
|
|
|
imageUrl = "image URL",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
isFollowed = false
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
FollowableTopic(
|
|
|
|
|
|
|
|
topic = Topic(
|
|
|
|
|
|
|
|
id = "1",
|
|
|
|
|
|
|
|
name = "UI",
|
|
|
|
|
|
|
|
shortDescription = "",
|
|
|
|
|
|
|
|
longDescription = "long description",
|
|
|
|
|
|
|
|
url = "URL",
|
|
|
|
|
|
|
|
imageUrl = "image URL",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
isFollowed = false
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
FollowableTopic(
|
|
|
|
|
|
|
|
topic = Topic(
|
|
|
|
|
|
|
|
id = "2",
|
|
|
|
|
|
|
|
name = "Tools",
|
|
|
|
|
|
|
|
shortDescription = "",
|
|
|
|
|
|
|
|
longDescription = "long description",
|
|
|
|
|
|
|
|
url = "URL",
|
|
|
|
|
|
|
|
imageUrl = "image URL",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
isFollowed = false
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
authors = listOf(
|
|
|
|
|
|
|
|
FollowableAuthor(
|
|
|
|
|
|
|
|
author = Author(
|
|
|
|
|
|
|
|
id = "0",
|
|
|
|
|
|
|
|
name = "Android Dev",
|
|
|
|
|
|
|
|
imageUrl = "",
|
|
|
|
|
|
|
|
twitter = "",
|
|
|
|
|
|
|
|
mediumPage = "",
|
|
|
|
|
|
|
|
bio = "",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
isFollowed = false
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
FollowableAuthor(
|
|
|
|
|
|
|
|
author = Author(
|
|
|
|
|
|
|
|
id = "1",
|
|
|
|
|
|
|
|
name = "Android Dev 2",
|
|
|
|
|
|
|
|
imageUrl = "",
|
|
|
|
|
|
|
|
twitter = "",
|
|
|
|
|
|
|
|
mediumPage = "",
|
|
|
|
|
|
|
|
bio = "",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
isFollowed = false
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
FollowableAuthor(
|
|
|
|
|
|
|
|
author = Author(
|
|
|
|
|
|
|
|
id = "2",
|
|
|
|
|
|
|
|
name = "Android Dev 3",
|
|
|
|
|
|
|
|
imageUrl = "",
|
|
|
|
|
|
|
|
twitter = "",
|
|
|
|
|
|
|
|
mediumPage = "",
|
|
|
|
|
|
|
|
bio = "",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
isFollowed = false
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
@ -1370,19 +1004,20 @@ class ForYouViewModelTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun newsResourceSelectionUpdatesAfterLoadingFollowedTopics() = runTest {
|
|
|
|
fun newsResourceSelectionUpdatesAfterLoadingFollowedTopics() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
val collectJob1 =
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.interestsSelectionUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
userDataRepository.setFollowedTopicIds(setOf("1"))
|
|
|
|
userDataRepository.setFollowedTopicIds(setOf("1"))
|
|
|
|
authorsRepository.sendAuthors(sampleAuthors)
|
|
|
|
authorsRepository.sendAuthors(sampleAuthors)
|
|
|
|
userDataRepository.setFollowedAuthorIds(setOf("1"))
|
|
|
|
userDataRepository.setFollowedAuthorIds(setOf("1"))
|
|
|
|
|
|
|
|
userDataRepository.setShouldHideOnboarding(true)
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
viewModel.updateNewsResourceSaved("2", true)
|
|
|
|
viewModel.updateNewsResourceSaved("2", true)
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
ForYouInterestsSelectionUiState.NoInterestsSelection,
|
|
|
|
OnboardingUiState.NotShown,
|
|
|
|
viewModel.interestsSelectionUiState.value
|
|
|
|
viewModel.onboardingUiState.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|
NewsFeedUiState.Success(
|
|
|
|