Skip to content

Commit

Permalink
Fix org unit selector robot test
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth Agarwal committed Jun 10, 2024
1 parent 129cbd0 commit 6f7b93d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
package org.dhis2.common.filters

import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollTo
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.TypeTextAction
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.PickerActions
import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withId
import org.dhis2.R
import org.dhis2.common.BaseRobot
import org.dhis2.common.matchers.DatePickerMatchers.Companion.matchesDate
import org.dhis2.commons.filters.FilterHolder
import org.dhis2.ui.dialogs.orgunit.DONE_TEST_TAG
import org.dhis2.ui.dialogs.orgunit.ITEM_CHECK_TEST_TAG
import org.dhis2.ui.dialogs.orgunit.ITEM_TEST_TAG

fun filterRobotCommon(robotBody: FiltersRobot.() -> Unit) {
FiltersRobot().apply {
Expand Down Expand Up @@ -56,7 +48,7 @@ class FiltersRobot : BaseRobot() {
}

fun selectNotSyncedState() {
onView( withId(R.id.stateNotSynced)).perform(click())
onView(withId(R.id.stateNotSynced)).perform(click())
}

fun acceptDateSelected() {
Expand All @@ -66,6 +58,4 @@ class FiltersRobot : BaseRobot() {
fun checkDate(year: Int, monthOfYear: Int, dayOfMonth: Int) {
onView(withId(R.id.datePicker)).check(matches(matchesDate(year, monthOfYear, dayOfMonth)))
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package org.dhis2.usescases.orgunitselector

import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollTo
import org.dhis2.common.BaseRobot
import org.dhis2.ui.dialogs.orgunit.DONE_TEST_TAG
import org.dhis2.ui.dialogs.orgunit.ITEM_CHECK_TEST_TAG

fun orgUnitSelectorRobot(
composeTestRule: ComposeTestRule,
Expand All @@ -19,9 +18,9 @@ fun orgUnitSelectorRobot(

class OrgUnitSelectorRobot(private val composeTestRule: ComposeTestRule) : BaseRobot() {
fun selectTreeOrgUnit(orgUnitName: String) {
composeTestRule.onNodeWithTag("$ITEM_CHECK_TEST_TAG$orgUnitName")
composeTestRule.onNodeWithTag("ORG_TREE_ITEM_$orgUnitName")
.performScrollTo()
.performClick()
composeTestRule.onNodeWithTag(DONE_TEST_TAG).performClick()
composeTestRule.onNodeWithText("Done").performClick()
}
}

0 comments on commit 6f7b93d

Please sign in to comment.