Skip to content

Commit

Permalink
Update DataCollectionFragmentTest
Browse files Browse the repository at this point in the history
  • Loading branch information
shobhitagarwal1612 committed Dec 20, 2024
1 parent b898bcb commit 86213bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class DataCollectionFragmentTest : BaseHiltTest() {
runner()
.inputText(TASK_1_RESPONSE)
.clickNextButton()
.selectMultipleChoiceOption(TASK_2_OPTION_LABEL)
.validateMultipleChoiceOptionIsDisplayed(TASK_2_OPTION_LABEL)
.clickPreviousButton()

assertDraftSaved(listOf(TASK_1_VALUE_DELTA, TASK_2_VALUE_DELTA), currentTaskId = TASK_ID_1)
Expand Down Expand Up @@ -169,7 +169,7 @@ class DataCollectionFragmentTest : BaseHiltTest() {
runner()
.validateTextIsDisplayed(TASK_1_RESPONSE)
.clickNextButton()
.validateTextIsDisplayed(TASK_2_OPTION_LABEL)
.validateMultipleChoiceOptionIsDisplayed(TASK_2_OPTION_LABEL)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.typeText
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
Expand Down Expand Up @@ -77,7 +76,12 @@ class TaskFragmentRunner(
}

internal fun selectMultipleChoiceOption(optionText: String): TaskFragmentRunner {
onView(withText(optionText)).perform(click())
baseHiltTest.composeTestRule.onNodeWithText(optionText).performClick()
return this
}

internal fun validateMultipleChoiceOptionIsDisplayed(text: String): TaskFragmentRunner {
baseHiltTest.composeTestRule.onNodeWithText(text).performClick()
return this
}

Expand Down

0 comments on commit 86213bf

Please sign in to comment.