Skip to content

Commit

Permalink
Fix #511 : Past expanded answers do not collapse in the question play…
Browse files Browse the repository at this point in the history
…er (#1456)

* fix previous response collapse

* added correct import

* added test cases

* added test for question player

* fix ktlint

* update skill_id to test_skill_id

* added QuestionPlayerActivityLocalTest

* nit changes as suggested

* removed unused import

* failed test to check over CI

* revert failed test to check over CI

* updating dagger modules

* adding profile init in test

* fix merge issue

* added questionplayer test to CI

Co-authored-by: Ben Henning <[email protected]>
  • Loading branch information
anandwana001 and BenHenning authored Aug 24, 2020
1 parent d8f1de5 commit 4ccbf73
Show file tree
Hide file tree
Showing 8 changed files with 373 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
- name: Robolectric tests - FAQ, Help, Mydownloads, Parser, ProfileProgress, RecyclerView, Story, Utility tests
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: |
sudo ./gradlew :app:testDebugUnitTest --tests org.oppia.app.faq* --tests org.oppia.app.help* --tests org.oppia.app.mydownloads* --tests org.oppia.app.parser* --tests org.oppia.app.profileprogress* --tests org.oppia.app.recyclerview* --tests org.oppia.app.splash* --tests org.oppia.app.story* --tests org.oppia.app.utility*
sudo ./gradlew :app:testDebugUnitTest --tests org.oppia.app.faq* --tests org.oppia.app.help* --tests org.oppia.app.mydownloads* --tests org.oppia.app.parser* --tests org.oppia.app.profileprogress* --tests org.oppia.app.recyclerview* --tests org.oppia.app.splash* --tests org.oppia.app.story* --tests org.oppia.app.utility* --tests org.oppia.app.topic.questionplayer*
- name: Upload App Test Reports
uses: actions/upload-artifact@v2
if: ${{ always() }} # IMPORTANT: Upload reports regardless of status
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.oppia.app.topic.questionplayer

import androidx.databinding.ObservableArrayList
import androidx.databinding.ObservableBoolean
import androidx.databinding.ObservableField
import androidx.databinding.ObservableList
import org.oppia.app.model.UserAnswer
import org.oppia.app.player.state.answerhandling.AnswerErrorCategory
import org.oppia.app.player.state.answerhandling.InteractionAnswerHandler
import org.oppia.app.player.state.itemviewmodel.StateItemViewModel
import org.oppia.app.viewmodel.ObservableArrayList
import org.oppia.app.viewmodel.ObservableViewModel
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/previous_response_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/previous_response_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/previous_response_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/previous_responses_header_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/previous_response_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions.scrollToHolder
import androidx.test.espresso.contrib.RecyclerViewActions.scrollToPosition
import androidx.test.espresso.matcher.RootMatchers.isDialog
import androidx.test.espresso.matcher.ViewMatchers.hasChildCount
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isEnabled
import androidx.test.espresso.matcher.ViewMatchers.withId
Expand Down Expand Up @@ -48,6 +49,7 @@ import org.oppia.app.player.exploration.TAG_HINTS_AND_SOLUTION_DIALOG
import org.oppia.app.player.state.itemviewmodel.StateItemViewModel
import org.oppia.app.player.state.itemviewmodel.StateItemViewModel.ViewType.CONTINUE_NAVIGATION_BUTTON
import org.oppia.app.player.state.itemviewmodel.StateItemViewModel.ViewType.FRACTION_INPUT_INTERACTION
import org.oppia.app.player.state.itemviewmodel.StateItemViewModel.ViewType.PREVIOUS_RESPONSES_HEADER
import org.oppia.app.player.state.itemviewmodel.StateItemViewModel.ViewType.SELECTION_INTERACTION
import org.oppia.app.player.state.itemviewmodel.StateItemViewModel.ViewType.SUBMIT_ANSWER_BUTTON
import org.oppia.app.player.state.testing.StateFragmentTestActivity
Expand Down Expand Up @@ -101,9 +103,15 @@ class StateFragmentLocalTest {
createAudioUrl(explorationId = "MjZzEVOG47_1", audioFileName = "content-en-ouqm7j21vt8.mp3")
private val audioDataSource1 = DataSource.toDataSource(AUDIO_URL_1, /* headers= */ null)

@Inject lateinit var profileTestHelper: ProfileTestHelper
@Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers
@Inject @field:ApplicationContext lateinit var context: Context
@Inject
lateinit var profileTestHelper: ProfileTestHelper

@Inject
lateinit var testCoroutineDispatchers: TestCoroutineDispatchers

@Inject
@field:ApplicationContext
lateinit var context: Context

private val internalProfileId: Int = 1

Expand Down Expand Up @@ -228,6 +236,65 @@ class StateFragmentLocalTest {
}
}

@Test
fun testStateFragment_submitTwoWrongAnswers_checkPreviousHeaderVisible() {
launchForExploration(FRACTIONS_EXPLORATION_ID_1).use {
startPlayingExploration()
playThroughState1()

submitTwoWrongAnswers()
onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(PREVIOUS_RESPONSES_HEADER))
onView(withId(R.id.previous_response_header)).check(matches(isDisplayed()))
}
}

@Test
fun testStateFragment_submitTwoWrongAnswers_checkPreviousHeaderCollapsed() {
launchForExploration(FRACTIONS_EXPLORATION_ID_1).use {
startPlayingExploration()
playThroughState1()

submitTwoWrongAnswers()
onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(PREVIOUS_RESPONSES_HEADER))
onView(withId(R.id.previous_response_header)).check(matches(isDisplayed()))
onView(withId(R.id.state_recycler_view)).check(matches(hasChildCount(/* childCount= */ 5)))
}
}

@Test
fun testStateFragment_submitTwoWrongAnswers_expandResponse_checkPreviousHeaderExpanded() {
launchForExploration(FRACTIONS_EXPLORATION_ID_1).use {
startPlayingExploration()
playThroughState1()

submitTwoWrongAnswers()

onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(PREVIOUS_RESPONSES_HEADER))
onView(withId(R.id.previous_response_header)).perform(click())
onView(withId(R.id.state_recycler_view)).check(matches(hasChildCount(/* childCount= */ 6)))
}
}

@Test
fun testStateFragment_expandCollapseResponse_checkPreviousHeaderCollapsed() {
launchForExploration(FRACTIONS_EXPLORATION_ID_1).use {
startPlayingExploration()
playThroughState1()

submitTwoWrongAnswers()

onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(PREVIOUS_RESPONSES_HEADER))
onView(withId(R.id.previous_response_header)).check(matches(isDisplayed()))
onView(withId(R.id.state_recycler_view)).check(matches(hasChildCount(/* childCount= */ 5)))
onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(PREVIOUS_RESPONSES_HEADER))
onView(withSubstring("Previous Responses")).perform(click())
onView(withId(R.id.state_recycler_view)).check(matches(hasChildCount(/* childCount= */ 6)))
onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(PREVIOUS_RESPONSES_HEADER))
onView(withSubstring("Previous Responses")).perform(click())
onView(withId(R.id.state_recycler_view)).check(matches(hasChildCount(/* childCount= */ 5)))
}
}

@Test
fun testStateFragment_nextState_submitInitialWrongAnswer_noHintAvailable() {
launchForExploration(FRACTIONS_EXPLORATION_ID_1).use {
Expand Down
Loading

0 comments on commit 4ccbf73

Please sign in to comment.