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 #1273 : Introduce UI tests for hints & solutions #5683

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to remove TODO(#1273) on line 174.

Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,55 @@ class QuestionPlayerActivityTest {
}
}

@Test
fun testQuestionPlayer_forHintsAndSolution_incorrectInput_hintBulbContainerIsNotVisible() {
launchForSkillList(SKILL_ID_LIST).use {
// Submit one incorrect answer.
selectMultipleChoiceOption(optionPosition = 3)

// Verify that the hint bulb container is not visible.
onView(withId(R.id.hints_and_solution_fragment_container)).check(matches(not(isDisplayed())))
}
}

@Test
fun testQuestionPlayer_forHintsAndSolution_incorrectInputTwice_hintBulbContainerIsVisible() {
launchForSkillList(SKILL_ID_LIST).use {
// Submit two incorrect answers.
selectMultipleChoiceOption(optionPosition = 3)
selectMultipleChoiceOption(optionPosition = 3)

// Verify that the hint bulb container is visible.
onView(withId(R.id.hints_and_solution_fragment_container)).check(matches(isDisplayed()))
}
}

@Test
fun testQuestionPlayer_showHintsAndSolutionBulb_dotHasCorrectContentDescription() {
launchForSkillList(SKILL_ID_LIST).use {
// Simulate two incorrect answers to make the hint bulb visible
selectMultipleChoiceOption(optionPosition = 3)
selectMultipleChoiceOption(optionPosition = 3)

// Verify the dot's content description
onView(withId(R.id.dot_hint))
.check(matches(withContentDescription("New hint available")))
}
}

@Test
fun testQuestionPlayer_showHintsAndSolutionBulb_bulbHasCorrectContentDescription() {
launchForSkillList(SKILL_ID_LIST).use {
// Simulate two incorrect answers to make the hint bulb visible
selectMultipleChoiceOption(optionPosition = 3) // Select first incorrect answer
selectMultipleChoiceOption(optionPosition = 3) // Select second incorrect answer

// Verify the hint bulb has the correct content description
onView(withId(R.id.hint_bulb))
.check(matches(withContentDescription("Show hints and solution")))
}
}

@Test
@RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso.
fun testQuestionPlayer_showHint_hasCorrectContentDescription() {
Expand Down
Loading