Skip to content

Commit

Permalink
Fix oppia#3413: Fix espresso test failing in topic practice fragment …
Browse files Browse the repository at this point in the history
…test (oppia#3743)

* Fixed test not passing in this testTopicPracticeFragment_loadFragment_selectSubtopics_clickStartButton_skillListTransferSuccessfully by unregistering the idling resouce in it

* removed a unused import as ktlint was failing

* Added .use after launcing the activity and added all code inside it

* formatted the file

* removed unused import

* Fixed Idling resources issue
  • Loading branch information
yash10019coder committed Sep 8, 2021
1 parent 0c98a6c commit 3dc0a61
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Application
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import androidx.test.core.app.ActivityScenario
import androidx.test.core.app.ActivityScenario.launch
import androidx.test.core.app.ApplicationProvider
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
Expand All @@ -26,7 +27,6 @@ import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.not
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -244,15 +244,16 @@ class TopicPracticeFragmentTest {
}

@Test
@Ignore("Flaky test") // TODO(#3413): Test is failing unexpectedly.
fun testTopicPracticeFragment_loadFragment_selectSubtopics_clickStartButton_skillListTransferSuccessfully() { // ktlint-disable max-line-length
launchTopicActivityIntent(internalProfileId, FRACTIONS_TOPIC_ID)
clickPracticeTab()
clickPracticeItem(position = 1, targetViewId = R.id.subtopic_check_box)
scrollToPosition(position = 5)
clickPracticeItem(position = 5, targetViewId = R.id.topic_practice_start_button)
intended(hasComponent(QuestionPlayerActivity::class.java.name))
intended(hasExtra(QuestionPlayerActivity.getIntentKey(), skillIdList))
testCoroutineDispatchers.unregisterIdlingResource()
launchTopicActivityIntent(internalProfileId, FRACTIONS_TOPIC_ID).use {
clickPracticeTab()
clickPracticeItem(position = 1, targetViewId = R.id.subtopic_check_box)
scrollToPosition(position = 5)
clickPracticeItem(position = 5, targetViewId = R.id.topic_practice_start_button)
intended(hasComponent(QuestionPlayerActivity::class.java.name))
intended(hasExtra(QuestionPlayerActivity.getIntentKey(), skillIdList))
}
}

@Test
Expand Down

0 comments on commit 3dc0a61

Please sign in to comment.