Skip to content

Commit

Permalink
ci: [ANDROAPP-6713] adapt test for screen resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
andresmr committed Jan 27, 2025
1 parent 8900977 commit ad3f50f
Showing 1 changed file with 52 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.dhis2.usescases.searchte.robot

import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.onAllNodesWithText
Expand Down Expand Up @@ -44,8 +43,9 @@ class FilterRobot(val composeTestRule: ComposeTestRule) : BaseRobot() {

fun clickOnFilterBy(filter: String) {
onView(withId(R.id.filterRecyclerLayout))
.perform(actionOnItem<FilterHolder>(hasDescendant(withText(filter)), click())
)
.perform(
actionOnItem<FilterHolder>(hasDescendant(withText(filter)), click())
)
}

fun clickOnFilterActiveOption() {
Expand All @@ -64,12 +64,22 @@ class FilterRobot(val composeTestRule: ComposeTestRule) : BaseRobot() {

fun closeFilterRowAtField(filter: String) {
onView(withId(R.id.filterRecyclerLayout))
.perform(actionOnItem<FilterHolder>(hasDescendant(withText(filter)), clickChildViewWithId(R.id.filterArrow)))
.perform(
actionOnItem<FilterHolder>(
hasDescendant(withText(filter)),
clickChildViewWithId(R.id.filterArrow)
)
)
}

fun clickOnSortByField(fieldFilter: String) {
onView(withId(R.id.filterRecyclerLayout))
.perform(actionOnItem<FilterHolder>(hasDescendant(withText(fieldFilter)), clickChildViewWithId(R.id.sortingIcon)))
.perform(
actionOnItem<FilterHolder>(
hasDescendant(withText(fieldFilter)),
clickChildViewWithId(R.id.sortingIcon)
)
)
}

fun typeOrgUnitField(orgUnit: String) {
Expand All @@ -88,13 +98,26 @@ class FilterRobot(val composeTestRule: ComposeTestRule) : BaseRobot() {
}

fun chooseDate(year: Int, monthOfYear: Int, dayOfMonth: Int) {
onView(withId(R.id.datePicker)).perform(PickerActions.setDate(year, monthOfYear, dayOfMonth))
onView(withId(R.id.datePicker)).perform(
PickerActions.setDate(
year,
monthOfYear,
dayOfMonth
)
)
onView(withId(R.id.acceptBtn)).perform(click())
}

fun checkTEIWithOrgUnit(orgUnit: String) {
onView(withId(R.id.scrollView))
.check(matches(allElementsWithHolderTypeHave(SearchTEViewHolder::class.java,hasDescendant(withText(orgUnit)))))
.check(
matches(
allElementsWithHolderTypeHave(
SearchTEViewHolder::class.java,
hasDescendant(withText(orgUnit))
)
)
)
}

fun checkTEINotSync() {
Expand All @@ -103,16 +126,34 @@ class FilterRobot(val composeTestRule: ComposeTestRule) : BaseRobot() {

fun checkFilterCounter(filterCount: String) {
waitForView(withId(R.id.filterCounter))
onView(allOf(withId(R.id.filterCounter), isDisplayed(), withParent(withId(R.id.mainToolbar))))
onView(
allOf(
withId(R.id.filterCounter),
isDisplayed(),
withParent(withId(R.id.mainToolbar))
)
)
.check(matches(withChild(withText(filterCount))))
}

fun checkCountAtFilter(filter: String, count: String) {
onView(withId(R.id.filterRecyclerLayout))
.check(matches(hasItem(allOf(hasDescendant(withText(filter)), hasDescendant(withText(count))))))
.check(
matches(
hasItem(
allOf(
hasDescendant(withText(filter)),
hasDescendant(withText(count))
)
)
)
)
}

fun checkTeiAreCompleted() {
composeTestRule.onAllNodesWithText("Enrollment completed", true).assertCountEquals(4)
val nodes = composeTestRule.onAllNodesWithText("Enrollment completed", true)
assert(nodes.fetchSemanticsNodes().size >= 3) {
"Expected at least 3 nodes, but found ${nodes.fetchSemanticsNodes().size}"
}
}
}
}

0 comments on commit ad3f50f

Please sign in to comment.