Skip to content

Commit

Permalink
fix: [ANDROAPP-6131] fix android test
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo <[email protected]>
  • Loading branch information
Balcan committed Jun 14, 2024
1 parent d818054 commit 55a6d7c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ProgramEventTest : BaseTest() {
clickOnCompleteButton()
}
programEventsRobot(composeTestRule) {
checkEventWasCreatedAndClosed(eventOrgUnit)
checkEventWasCreatedAndClosed("1/1/2001")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@ package org.dhis2.usescases.programevent.robot

import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.hasAnyDescendant
import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.printToLog
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withTagValue
import androidx.test.espresso.matcher.ViewMatchers.withText
import org.dhis2.R
import org.dhis2.common.BaseRobot
import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.anyOf
import org.hamcrest.CoreMatchers.equalTo

fun programEventsRobot(
composeTestRule: ComposeContentTestRule,
Expand All @@ -45,21 +43,20 @@ class ProgramEventsRobot(val composeTestRule: ComposeContentTestRule) : BaseRobo
onView(withId(R.id.navigation_map_view)).perform(click())
}

fun checkEventWasCreatedAndClosed(eventName: String) {
waitForView(
allOf(
withId(R.id.recycler),
hasDescendant(withText(eventName)),
hasDescendant(
withTagValue(
anyOf(
equalTo(R.drawable.ic_event_status_complete),
equalTo(R.drawable.ic_event_status_complete_read)
)
fun checkEventWasCreatedAndClosed(eventDate: String) {
composeTestRule.onRoot().printToLog("TEST")
composeTestRule.onNode(
hasTestTag("EVENT_ITEM")
and
hasAnyDescendant(
hasText("Event completed")
)
)
)
).check(matches(isDisplayed()))
and
hasAnyDescendant(
hasText("View only")
),
useUnmergedTree = true
).assertIsDisplayed()
}

fun checkEventIsComplete(eventDate: String) {
Expand Down

0 comments on commit 55a6d7c

Please sign in to comment.