Skip to content

Commit

Permalink
fix ui test
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmateos committed Jul 5, 2024
1 parent 8edcbb3 commit 7d9943d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import org.dhis2.common.mockwebserver.MockWebServerRobot.Companion.API_OLD_TRACKED_ENTITY_PATH
import org.dhis2.common.mockwebserver.MockWebServerRobot.Companion.API_OLD_TRACKED_ENTITY_RESPONSE
import org.dhis2.commons.date.DateUtils
import org.dhis2.usescases.BaseTest
import org.dhis2.usescases.flow.teiFlow.entity.DateRegistrationUIModel
import org.dhis2.usescases.flow.teiFlow.entity.EnrollmentListUIModel
Expand All @@ -16,7 +17,6 @@ import org.hisp.dhis.android.core.mockwebserver.ResponseController
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import java.text.SimpleDateFormat
import java.util.Date


Expand Down Expand Up @@ -95,7 +95,7 @@ class TeiFlowTest : BaseTest() {
)

private fun getCurrentDate(): String {
val sdf = SimpleDateFormat(DATE_FORMAT)
val sdf = DateUtils.uiDateFormat()
val dateFormat = sdf.format(Date())
return dateFormat.removePrefix("0")
}
Expand All @@ -117,7 +117,5 @@ class TeiFlowTest : BaseTest() {
const val ORG_UNIT = "Ngelehun CHC"
const val NAME = "Marta"
const val LASTNAME = "Stuart"

const val DATE_FORMAT = "dd/M/yyyy"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ class ProgramEventTest : BaseTest() {
}
composeTestRule.waitForIdle()
programEventsRobot(composeTestRule) {
checkEventWasCreatedAndClosed("1/1/2001")
checkEventWasCreatedAndClosed()
}
}

@Test
fun shouldOpenExistingEvent() {
val eventDate = "15/3/2020"
val eventDate = "15/03/2020"
val eventOrgUnit = "Ngelehun CHC"

prepareProgramAndLaunchActivity(antenatalCare)
Expand All @@ -81,7 +81,7 @@ class ProgramEventTest : BaseTest() {
@Ignore("Flaky test, will be look om issue ANDROAPP-6030")
@Test
fun shouldCompleteAnEventAndReopenIt() {
val eventDate = "15/3/2020"
val eventDate = "15/03/2020"

prepareProgramAndLaunchActivity(antenatalCare)

Expand All @@ -107,7 +107,7 @@ class ProgramEventTest : BaseTest() {

@Test
fun shouldDeleteEvent() {
val eventDate = "15/3/2020"
val eventDate = "15/03/2020"

prepareProgramAndLaunchActivity(antenatalCare)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ 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
Expand Down Expand Up @@ -44,7 +42,7 @@ class ProgramEventsRobot(val composeTestRule: ComposeContentTestRule) : BaseRobo
}

@OptIn(ExperimentalTestApi::class)
fun checkEventWasCreatedAndClosed(eventDate: String) {
fun checkEventWasCreatedAndClosed() {
composeTestRule.waitUntilAtLeastOneExists(hasTestTag("EVENT_ITEM"))
composeTestRule.onNode(
hasTestTag("EVENT_ITEM")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ class SearchTETest : BaseTest() {
private fun createDisplayListFields() = DisplayListFieldsUIModel(
"Sarah",
"Thompson",
"2001-01-01",
"01/01/2001",
"[email protected]",
"Main street 1",
"56",
Expand Down

0 comments on commit 7d9943d

Please sign in to comment.