diff --git a/app/src/androidTest/java/org/dhis2/usescases/flow/teiFlow/TeiFlowRobot.kt b/app/src/androidTest/java/org/dhis2/usescases/flow/teiFlow/TeiFlowRobot.kt index 19e4def288..279b92be95 100644 --- a/app/src/androidTest/java/org/dhis2/usescases/flow/teiFlow/TeiFlowRobot.kt +++ b/app/src/androidTest/java/org/dhis2/usescases/flow/teiFlow/TeiFlowRobot.kt @@ -103,7 +103,7 @@ class TeiFlowRobot(val composeTestRule: ComposeTestRule) : BaseRobot() { eventRobot(composeTestRule) { clickOnEventDueDate() - selectSpecificDate(getPreviousDate().substring(0, 2)) + selectSpecificDate(getCurrentDatePickerDate(), getPreviousDate()) acceptUpdateEventDate() } } @@ -115,9 +115,15 @@ class TeiFlowRobot(val composeTestRule: ComposeTestRule) : BaseRobot() { } private fun getPreviousDate(): String { - val sdf = SimpleDateFormat("ddMMYYYY") + val sdf = SimpleDateFormat("MMddYYYY") val calendar = Calendar.getInstance() calendar.add(Calendar.DAY_OF_MONTH, -1) return sdf.format(calendar.time) } + + private fun getCurrentDatePickerDate(): String { + val sdf = SimpleDateFormat("MM/dd/YYYY") + val calendar = Calendar.getInstance() + return sdf.format(calendar.time) + } } diff --git a/app/src/androidTest/java/org/dhis2/usescases/teidashboard/robot/EventRobot.kt b/app/src/androidTest/java/org/dhis2/usescases/teidashboard/robot/EventRobot.kt index f10138eec9..9f3cdc87f7 100644 --- a/app/src/androidTest/java/org/dhis2/usescases/teidashboard/robot/EventRobot.kt +++ b/app/src/androidTest/java/org/dhis2/usescases/teidashboard/robot/EventRobot.kt @@ -5,6 +5,7 @@ import androidx.compose.ui.test.hasAnySibling import androidx.compose.ui.test.hasTestTag import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.ComposeTestRule +import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick @@ -110,9 +111,13 @@ class EventRobot(val composeTestRule: ComposeTestRule) : BaseRobot() { } - fun selectSpecificDate(date: String) { + fun selectSpecificDate(currentDate: String, date: String) { composeTestRule.onNodeWithTag("DATE_PICKER").assertIsDisplayed() - composeTestRule.onNode(hasText(date, true)).performClick() + composeTestRule.onNodeWithContentDescription( + "Switch to text input mode", + useUnmergedTree = true, + ).performClick() + composeTestRule.onNodeWithText(currentDate).performTextReplacement(date) } fun typeOnDateParameter(dateValue: String) {