Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2689: Corrected options in exploration with id text_exp_id_4 of Second Test Topic. #2690

Merged
merged 24 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0d0e0d6
implemented recommendation system
veena14cs Dec 11, 2020
94d179c
Merge remote-tracking branch 'upstream/develop' into recommended-story
veena14cs Dec 11, 2020
3b374c6
writing testcases
veena14cs Dec 11, 2020
9d2d9e4
Update TopicListControllerTest.kt
veena14cs Dec 12, 2020
5309299
reverted changes
veena14cs Dec 12, 2020
7282650
optimized list
veena14cs Dec 15, 2020
02bba56
fixed recommended list
veena14cs Dec 15, 2020
27112a3
fixed index error
veena14cs Dec 16, 2020
a0abcc3
Merge remote-tracking branch 'upstream/develop' into promoted-story
veena14cs Dec 16, 2020
1a9fdc4
added timestamp for recently played
veena14cs Dec 16, 2020
f2b6271
removed walkthrough field
veena14cs Dec 17, 2020
4e6926c
writting testcases
veena14cs Dec 17, 2020
872ccc3
fixing testcase
veena14cs Dec 17, 2020
1115eaf
Merge remote-tracking branch 'upstream/develop' into promoted-story
veena14cs Dec 17, 2020
d2bcbea
Merge remote-tracking branch 'upstream/develop' into develop
veena14cs Dec 17, 2020
a6a940f
Merge branch 'promoted-story' into develop
veena14cs Dec 17, 2020
32824aa
Merge remote-tracking branch 'upstream/develop' into develop
veena14cs Feb 11, 2021
29171ba
updated with develop
veena14cs Feb 11, 2021
c1fea02
Update TopicTestActivityForStory.kt
veena14cs Feb 11, 2021
4216726
Fixed exploration id 4 json and testcase
veena14cs Feb 11, 2021
0701033
Deleted unwanted file changes
veena14cs Feb 12, 2021
74c2755
fixed unrelated file changes
veena14cs Feb 12, 2021
f73cf09
Merge remote-tracking branch 'upstream/develop' into fix-second-test-…
veena14cs Feb 12, 2021
ee883b7
Merge remote-tracking branch 'upstream/develop' into fix-second-test-…
veena14cs Feb 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
writing testcases
  • Loading branch information
veena14cs committed Dec 11, 2020
commit 3b374c6f9cda9d40ce1f3e818efad5e03c680617
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,12 @@ class TopicListAdapter(
}
when (promotedStoryList[0].promotedStoriesType) {
PromotedStoriesType.PromotedStoriesTypeCase.RECENTLY_PLAYED -> {
binding.recentlyPlayedStoriesTextView.visibility = View.VISIBLE
binding.recentlyPlayedStoriesTextView.setText(activity.getString(R.string.recently_played_stories))
binding.viewAllTextView.visibility = View.VISIBLE
}
PromotedStoriesType.PromotedStoriesTypeCase.RECOMMENDED -> {
binding.recentlyPlayedStoriesTextView.visibility = View.VISIBLE
binding.recentlyPlayedStoriesTextView.setText(activity.getString(R.string.recommended_stories))
binding.viewAllTextView.visibility = View.INVISIBLE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ class StateFragmentPresenter @Inject constructor(
}

private fun markExplorationAsRecentlyPlayed() {
Log.d("topicplay=", "==" +topicId+" "+ storyId+" "+explorationId)
storyProgressController.recordRecentlyPlayedChapter(
profileId,
topicId,
Expand All @@ -552,6 +553,8 @@ class StateFragmentPresenter @Inject constructor(
}

private fun markExplorationCompleted() {

Log.d("topicplaycom=", "==" +topicId+" "+ storyId+" "+explorationId)
storyProgressController.recordCompletedChapter(
profileId,
topicId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class TopicListController @Inject constructor(
topicProgress.storyProgressMap.values.forEach { storyProgress ->
val storyId = storyProgress.storyId
var story = topicController.retrieveStory(topic.topicId, storyId)
Log.d("topic progress =", "" + topicProgress.topicId)
Log.d("topic progress =", "" + topicProgress.topicId + storyId)

val completedChapterProgressList =
storyProgress.chapterProgressMap.values
Expand Down Expand Up @@ -281,7 +281,7 @@ class TopicListController @Inject constructor(
.getJSONArray("topic_id_list")
for (j in 0 until topicIdJsonArray.length()) {
val found = topicProgressList.any { it.topicId == topicIdJsonArray[j] }
if (!found) {
if (!found && ongoingStoryListBuilder.recommendedStoryList.size<3) {
Log.d("topic =", " not" + " " + topicIdJsonArray[j])
ongoingStoryListBuilder.addRecommendedStory(
createRecommendedStoryFromAssets(
Expand Down Expand Up @@ -401,7 +401,7 @@ class TopicListController @Inject constructor(
.loadJsonFromAsset("topics.json")!!
.getJSONArray("topic_id_list")
for (i in 0 until topicIdJsonArray.length()) {
if (topicProgress.topicId != topicIdJsonArray[i]) {
if (topicProgress.topicId != topicIdJsonArray[i] && recommendedStories.size<3) {
recommendedStories.add(createRecommendedStoryFromAssets(topicIdJsonArray[i].toString()))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class TopicListControllerTest {

@Test
@Ignore("Failing on Circle CI.")
fun testRetrieveOngoingStoryList_markRecentlyPlayedFracStory0Exp0_ongoingStoryListIsCorrect() {
fun testRetrieveRecentStoryList_markRecentlyPlayedFracStory0Exp0_recentStoryListIsCorrect() {
storyProgressController.recordRecentlyPlayedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
Expand All @@ -262,7 +262,164 @@ class TopicListControllerTest {
}

@Test
fun testRetrieveOngoingStoryList_markChapterCompletedFracStory0Exp0_ongoingStoryListIsCorrect() {
fun testRetrieveRecommendedStoryList_markChapterCompletedFracStory0Exp0_fromWalkthrough_recommendedStoryListIsCorrect() {
storyProgressController.recordCompletedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0,
FRACTIONS_EXPLORATION_ID_0,
getCurrentTimestamp(),
true
)
testCoroutineDispatchers.runCurrent()

topicListController.getOngoingStoryList(profileId0).toLiveData()
.observeForever(mockOngoingStoryListObserver)
testCoroutineDispatchers.runCurrent()

verifyGetOngoingStoryListSucceeded()

val ongoingTopicList = ongoingStoryListResultCaptor.value.getOrThrow()
assertThat(ongoingTopicList.recommendedStoryCount).isEqualTo(3)
verifyOngoingStoryAsFractionStory0Exploration1(ongoingTopicList.recommendedStoryList[0])
}

@Test
@Ignore("Failing on Circle CI.")
fun testRetrieveRecommendedStoryList_markRecentlyPlayedFracStory0Exp0_isFromWalkthrough_recommendedStoryListIsCorrect() {
storyProgressController.recordRecentlyPlayedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0,
FRACTIONS_EXPLORATION_ID_0,
getCurrentTimestamp(),
isFromWalkthrough = true
)
testCoroutineDispatchers.runCurrent()

topicListController.getOngoingStoryList(profileId0).toLiveData()
.observeForever(mockOngoingStoryListObserver)
testCoroutineDispatchers.runCurrent()

verifyGetOngoingStoryListSucceeded()

val ongoingTopicList = ongoingStoryListResultCaptor.value.getOrThrow()
assertThat(ongoingTopicList.recommendedStoryCount).isEqualTo(3)
verifyOngoingStoryAsFractionStory0Exploration0(ongoingTopicList.recommendedStoryList[0])
}

@Test
fun testRetrieveRecommendedStoryList_markChapDoneFracStory0Exp0_playedFracStory0Exp1_fromWalkthrough_recommendedListCorrect() {
storyProgressController.recordCompletedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0,
FRACTIONS_EXPLORATION_ID_0,
getCurrentTimestamp(),
true
)
testCoroutineDispatchers.runCurrent()

storyProgressController.recordRecentlyPlayedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0,
FRACTIONS_EXPLORATION_ID_1,
getCurrentTimestamp(),
isFromWalkthrough = true
)
testCoroutineDispatchers.runCurrent()

topicListController.getOngoingStoryList(profileId0).toLiveData()
.observeForever(mockOngoingStoryListObserver)
testCoroutineDispatchers.runCurrent()

verifyGetOngoingStoryListSucceeded()

val ongoingTopicList = ongoingStoryListResultCaptor.value.getOrThrow()
assertThat(ongoingTopicList.recommendedStoryCount).isEqualTo(3)
verifyOngoingStoryAsFractionStory0Exploration1(ongoingTopicList.recommendedStoryList[0])
}

@Test
fun testRetrieveRecommendedStoryList_markAllChaptersCompletedInFractions_recommendedListIsCorrect() {
storyProgressController.recordCompletedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0,
FRACTIONS_EXPLORATION_ID_0,
getCurrentTimestamp(),
true
)
testCoroutineDispatchers.runCurrent()

storyProgressController.recordCompletedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0,
FRACTIONS_EXPLORATION_ID_1,
getCurrentTimestamp(),
true
)
testCoroutineDispatchers.runCurrent()

topicListController.getOngoingStoryList(profileId0).toLiveData()
.observeForever(mockOngoingStoryListObserver)
testCoroutineDispatchers.runCurrent()

verifyGetOngoingStoryListSucceeded()

val ongoingTopicList = ongoingStoryListResultCaptor.value.getOrThrow()
assertThat(ongoingTopicList.recommendedStoryCount).isEqualTo(3)
verifyDefaultRecommendedStoryListSucceeded()
}

@Test
fun testRetrieveRecentStoryList_markAllChaptersCompletedInFractions_fromRecommendedList_playedFirstTopicStory0Exploration0_recentStoryListIsCorrect() {
storyProgressController.recordCompletedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0,
FRACTIONS_EXPLORATION_ID_0,
getCurrentTimestamp(),
true
)
testCoroutineDispatchers.runCurrent()

storyProgressController.recordCompletedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0,
FRACTIONS_EXPLORATION_ID_1,
getCurrentTimestamp(),
true
)
testCoroutineDispatchers.runCurrent()

storyProgressController.recordRecentlyPlayedChapter(
profileId0,
TEST_TOPIC_ID_0,
TEST_STORY_ID_0,
TEST_EXPLORATION_ID_2,
getCurrentTimestamp(),
isFromWalkthrough = false
)
testCoroutineDispatchers.runCurrent()

topicListController.getOngoingStoryList(profileId0).toLiveData()
.observeForever(mockOngoingStoryListObserver)
testCoroutineDispatchers.runCurrent()

verifyGetOngoingStoryListSucceeded()

val ongoingTopicList = ongoingStoryListResultCaptor.value.getOrThrow()
assertThat(ongoingTopicList.recentStoryCount).isEqualTo(1)

verifyOngoingStoryAsFirstTopicStory0Exploration0(ongoingTopicList.recentStoryList[0])
}

@Test
fun testRetrieveRecentList_markChapterCompletedFracStory0Exp0_recentStoryListIsCorrect() {
storyProgressController.recordCompletedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
Expand All @@ -285,7 +442,7 @@ class TopicListControllerTest {
}

@Test
fun testRetrieveStoryList_markChapDoneFracStory0Exp0_playedFracStory0Exp1_ongoingListCorrect() {
fun testRetrieveRecentStoryList_markChapDoneFracStory0Exp0_playedFracStory0Exp1_RecentStoryListCorrect() {
storyProgressController.recordCompletedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
Expand Down Expand Up @@ -464,6 +621,122 @@ class TopicListControllerTest {
verifyOngoingStoryAsRatioStory1Exploration3(ongoingTopicList.recentStoryList[2])
}

@Test
fun testRetrieveRecommendedStoryList_markFirstStoryOfFractDone_noMoreOngoingList_recommendedListIsCorrect() {
storyProgressController.recordCompletedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0,
FRACTIONS_EXPLORATION_ID_0,
getCurrentTimestamp(),
false
)
testCoroutineDispatchers.runCurrent()

storyProgressController.recordCompletedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0,
FRACTIONS_EXPLORATION_ID_1,
getCurrentTimestamp(),
false
)
testCoroutineDispatchers.runCurrent()

topicListController.getOngoingStoryList(profileId0).toLiveData()
.observeForever(mockOngoingStoryListObserver)
testCoroutineDispatchers.runCurrent()

verifyGetOngoingStoryListSucceeded()

val ongoingTopicList = ongoingStoryListResultCaptor.value.getOrThrow()
assertThat(ongoingTopicList.recentStoryCount).isEqualTo(0)
assertThat(ongoingTopicList.recommendedStoryCount).isEqualTo(3)
}

@Test
fun testRetrieveComingSoonTopicList_markFirstExpOfEveryStoryDoneWithinLastSevenDays_comingSoonListIsCorrect() {
storyProgressController.recordCompletedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0,
FRACTIONS_EXPLORATION_ID_0,
getCurrentTimestamp(),
false
)
testCoroutineDispatchers.runCurrent()

storyProgressController.recordCompletedChapter(
profileId0,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0,
FRACTIONS_EXPLORATION_ID_1,
getCurrentTimestamp(),
false
)
testCoroutineDispatchers.runCurrent()

storyProgressController.recordCompletedChapter(
profileId0,
TEST_TOPIC_ID_0,
TEST_STORY_ID_0,
TEST_EXPLORATION_ID_2,
getCurrentTimestamp(),
false
)
testCoroutineDispatchers.runCurrent()
storyProgressController.recordCompletedChapter(
profileId0,
TEST_TOPIC_ID_0,
TEST_STORY_ID_0,
TEST_EXPLORATION_ID_5,
getCurrentTimestamp(),
false
)
testCoroutineDispatchers.runCurrent()

storyProgressController.recordCompletedChapter(
profileId0,
TEST_TOPIC_ID_1,
TEST_STORY_ID_2,
TEST_EXPLORATION_ID_4,
getCurrentTimestamp(),
false
)
testCoroutineDispatchers.runCurrent()


// storyProgressController.recordCompletedChapter(
// profileId0,
// RATIOS_TOPIC_ID,
// RATIOS_STORY_ID_1,
// RATIOS_EXPLORATION_ID_2,
// getCurrentTimestamp(),
// false
// )
// testCoroutineDispatchers.runCurrent()
//
// storyProgressController.recordCompletedChapter(
// profileId0,
// RATIOS_TOPIC_ID,
// RATIOS_STORY_ID_1,
// RATIOS_EXPLORATION_ID_3,
// getCurrentTimestamp(),
// false
// )
// testCoroutineDispatchers.runCurrent()

topicListController.getOngoingStoryList(profileId0).toLiveData()
.observeForever(mockOngoingStoryListObserver)
testCoroutineDispatchers.runCurrent()

verifyGetOngoingStoryListSucceeded()

val ongoingTopicList = ongoingStoryListResultCaptor.value.getOrThrow()
assertThat(ongoingTopicList.recentStoryCount).isEqualTo(0)
// assertThat(ongoingTopicList.recommendedStoryCount).isEqualTo(3)
}

@Test
fun testRetrieveStoryList_markFirstExpOfEveryStoryDoneWithinLastMonth_ongoingListIsCorrect() {
storyProgressController.recordCompletedChapter(
Expand Down Expand Up @@ -527,6 +800,14 @@ class TopicListControllerTest {
verifyOngoingStoryAsRatioStory0Exploration0(ongoingTopicList.recentStoryList[3])
}

private fun verifyDefaultRecommendedStoryListSucceeded() {
val ongoingTopicList = ongoingStoryListResultCaptor.value.getOrThrow()
assertThat(ongoingTopicList.recommendedStoryCount).isEqualTo(3)
verifyOngoingStoryAsFirstTopicStory0Exploration0(ongoingTopicList.recommendedStoryList[0])
verifyOngoingStoryAsSecondTopicStory0Exploration0(ongoingTopicList.recommendedStoryList[1])
verifyOngoingStoryAsRatioStory0Exploration0(ongoingTopicList.recommendedStoryList[2])
}

private fun verifyOngoingStoryAsFirstTopicStory0Exploration0(promotedStory: PromotedStory) {
assertThat(promotedStory.explorationId).isEqualTo(TEST_EXPLORATION_ID_2)
assertThat(promotedStory.storyId).isEqualTo(TEST_STORY_ID_0)
Expand Down