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 part of #2132: Chapter List Page Issues #2232

Merged
merged 18 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ import org.oppia.android.domain.topic.FRACTIONS_STORY_ID_0
import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.domain.topic.StoryProgressTestHelper
import org.oppia.android.domain.topic.TEST_STORY_ID_1
import org.oppia.android.domain.topic.TEST_TOPIC_ID_1
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestCoroutineDispatchers
import org.oppia.android.testing.TestDispatcherModule
Expand Down Expand Up @@ -126,15 +128,6 @@ class StoryFragmentTest {
Intents.release()
}

private fun createStoryActivityIntent(): Intent {
return StoryActivity.createStoryActivityIntent(
ApplicationProvider.getApplicationContext(),
internalProfileId,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0
)
}

@Test
fun testStoryFragment_clickOnToolbarNavigationButton_closeActivity() {
activityTestRule.launchActivity(createStoryActivityIntent())
Expand All @@ -154,11 +147,8 @@ class StoryFragmentTest {

@Test
fun testStoryFragment_correctStoryCountLoadedInHeader() {
setStoryPartialProgressForFractions()
launch<StoryActivity>(createStoryActivityIntent()).use {
storyProgressTestHelper.markPartialStoryProgressForFractions(
profileId,
timestampOlderThanAWeek = false
)
testCoroutineDispatchers.runCurrent()
val headerString: String =
getResources().getQuantityString(R.plurals.story_total_chapters, 2, 1, 2)
Expand Down Expand Up @@ -199,7 +189,13 @@ class StoryFragmentTest {
1
)
)
onView(atPositionOnView(R.id.story_chapter_list, 1, R.id.chapter_title)).check(
onView(
atPositionOnView(
R.id.story_chapter_list,
1,
R.id.chapter_title
)
).check(
matches(
withText("Chapter 1: What is a Fraction?")
)
Expand All @@ -216,7 +212,13 @@ class StoryFragmentTest {
1
)
)
onView(atPositionOnView(R.id.story_chapter_list, 1, R.id.chapter_summary)).check(
onView(
atPositionOnView(
R.id.story_chapter_list,
1,
R.id.chapter_summary
)
).check(
matches(
withText("This is outline/summary for What is a Fraction?")
)
Expand All @@ -234,7 +236,13 @@ class StoryFragmentTest {
1
)
)
onView(atPositionOnView(R.id.story_chapter_list, 1, R.id.chapter_summary)).check(
onView(
atPositionOnView(
R.id.story_chapter_list,
1,
R.id.chapter_summary
)
).check(
matches(
withText("This is outline/summary for What is a Fraction?")
)
Expand All @@ -243,16 +251,76 @@ class StoryFragmentTest {
}

@Test
fun testStoryFragment_changeConfiguration_chapterMissingPrerequisiteIsShownCorrectly() {
launch<StoryActivity>(createStoryActivityIntent()).use {
fun testStoryFragment_chapterLongSummaryIsShownCorrectly() {
launch<StoryActivity>(createTestStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(allOf(withId(R.id.story_chapter_list))).perform(
scrollToPosition<RecyclerView.ViewHolder>(
1
)
)
onView(
atPositionOnView(
R.id.story_chapter_list,
1,
R.id.chapter_summary
)
).check(
matches(
withText(
"This is outline/summary for Second Exploration. It is very long but " +
"it has to be fully visible. You wil be learning about oppia app in Second Story. " +
"Learn about oppia app via testing in second exploration."
)
)
)
}
}

@Test
fun testStoryFragment_changeConfiguration_chapterLongSummaryIsShownCorrectly() {
launch<StoryActivity>(createTestStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(isRoot()).perform(orientationLandscape())
onView(allOf(withId(R.id.story_chapter_list))).perform(
scrollToPosition<RecyclerView.ViewHolder>(
1
)
)
onView(
atPositionOnView(
R.id.story_chapter_list,
1,
R.id.chapter_summary
)
).check(
matches(
withText(
"This is outline/summary for Second Exploration. It is very long but " +
"it has to be fully visible. You wil be learning about oppia app in Second Story. " +
"Learn about oppia app via testing in second exploration."
)
)
)
}
}

@Test
fun testStoryFragment_chapterMissingPrerequisiteIsShownCorrectly() {
launch<StoryActivity>(createStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(allOf(withId(R.id.story_chapter_list))).perform(
scrollToPosition<RecyclerView.ViewHolder>(
2
)
)
onView(atPositionOnView(R.id.story_chapter_list, 2, R.id.chapter_summary)).check(
onView(
atPositionOnView(
R.id.story_chapter_list,
2,
R.id.chapter_summary
)
).check(
matches(
withText("Complete Chapter 1: What is a Fraction? to unlock this chapter.")
)
Expand All @@ -261,15 +329,22 @@ class StoryFragmentTest {
}

@Test
fun testStoryFragment_chapterMissingPrerequisiteIsShownCorrectly() {
fun testStoryFragment_changeConfiguration_chapterMissingPrerequisiteIsShownCorrectly() {
anandwana001 marked this conversation as resolved.
Show resolved Hide resolved
launch<StoryActivity>(createStoryActivityIntent()).use {
testCoroutineDispatchers.runCurrent()
onView(isRoot()).perform(orientationLandscape())
onView(allOf(withId(R.id.story_chapter_list))).perform(
scrollToPosition<RecyclerView.ViewHolder>(
2
)
)
onView(atPositionOnView(R.id.story_chapter_list, 2, R.id.chapter_summary)).check(
onView(
atPositionOnView(
R.id.story_chapter_list,
2,
R.id.chapter_summary
)
).check(
matches(
withText("Complete Chapter 1: What is a Fraction? to unlock this chapter.")
)
Expand Down Expand Up @@ -297,11 +372,8 @@ class StoryFragmentTest {

@Test
fun testStoryFragment_changeConfiguration_correctStoryCountInHeader() {
setStoryPartialProgressForFractions()
launch<StoryActivity>(createStoryActivityIntent()).use {
storyProgressTestHelper.markPartialStoryProgressForFractions(
profileId,
timestampOlderThanAWeek = false
)
testCoroutineDispatchers.runCurrent()
onView(isRoot()).perform(orientationLandscape())
val headerString: String =
Expand Down Expand Up @@ -330,6 +402,31 @@ class StoryFragmentTest {
}
}

private fun createStoryActivityIntent(): Intent {
anandwana001 marked this conversation as resolved.
Show resolved Hide resolved
return StoryActivity.createStoryActivityIntent(
ApplicationProvider.getApplicationContext(),
internalProfileId,
FRACTIONS_TOPIC_ID,
FRACTIONS_STORY_ID_0
)
}

private fun createTestStoryActivityIntent(): Intent {
return StoryActivity.createStoryActivityIntent(
ApplicationProvider.getApplicationContext(),
internalProfileId,
TEST_TOPIC_ID_1,
TEST_STORY_ID_1
)
}

private fun setStoryPartialProgressForFractions() {
storyProgressTestHelper.markPartialStoryProgressForFractions(
profileId,
timestampOlderThanAWeek = false
)
}

private fun setUpTestApplicationComponent() {
ApplicationProvider.getApplicationContext<TestApplication>().inject(this)
}
Expand Down
2 changes: 1 addition & 1 deletion domain/src/main/assets/test_story_id_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"objective": "Learn about oppia app via testing in second exploration.",
"id": "test_exp_id_1"
},
"outline": "",
"outline": "This is outline/summary for Second Exploration. It is very long but it has to be fully visible. You wil be learning about oppia app in Second Story. Learn about oppia app via testing in second exploration.",
"title": "Second Exploration",
"acquired_skill_ids": []
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class TopicController @Inject constructor(
val chapterBuilder = chapterSummary.toBuilder()
if (index != 0) {
chapterBuilder.chapterPlayState = ChapterPlayState.NOT_PLAYABLE_MISSING_PREREQUISITES
chapterBuilder.missingPrerequisiteChapter = storySummary.chapterList.get(index - 1)
chapterBuilder.missingPrerequisiteChapter = storySummary.chapterList[index - 1]
} else {
chapterBuilder.chapterPlayState = ChapterPlayState.NOT_STARTED
}
Expand Down