From 4d5b9b68818955b355cb2db924b8308790fddc56 Mon Sep 17 00:00:00 2001 From: Xavier Molloy Date: Wed, 10 Jul 2024 10:10:54 +0200 Subject: [PATCH] fix: [ANDROAPP-6315] fix tests --- .../programevent/robot/ProgramEventsRobot.kt | 4 ++-- .../dhis2/usescases/searchte/SearchTETest.kt | 8 +++---- .../searchte/robot/SearchTeiRobot.kt | 21 +++++++++---------- .../teidashboard/robot/EventRobot.kt | 3 +++ .../eventCapture/EventCapturePresenterImpl.kt | 2 +- .../searchTrackEntity/SearchTEIViewModel.kt | 1 + 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/app/src/androidTest/java/org/dhis2/usescases/programevent/robot/ProgramEventsRobot.kt b/app/src/androidTest/java/org/dhis2/usescases/programevent/robot/ProgramEventsRobot.kt index 9be1dff635..d987222258 100644 --- a/app/src/androidTest/java/org/dhis2/usescases/programevent/robot/ProgramEventsRobot.kt +++ b/app/src/androidTest/java/org/dhis2/usescases/programevent/robot/ProgramEventsRobot.kt @@ -48,11 +48,11 @@ class ProgramEventsRobot(val composeTestRule: ComposeContentTestRule) : BaseRobo hasTestTag("EVENT_ITEM") and hasAnyDescendant( - hasText("Event completed") + hasText("Event completed", true) ) and hasAnyDescendant( - hasText("View only") + hasText("View only", true) ), useUnmergedTree = true ).assertIsDisplayed() diff --git a/app/src/androidTest/java/org/dhis2/usescases/searchte/SearchTETest.kt b/app/src/androidTest/java/org/dhis2/usescases/searchte/SearchTETest.kt index df1d7a387e..ef993e0432 100644 --- a/app/src/androidTest/java/org/dhis2/usescases/searchte/SearchTETest.kt +++ b/app/src/androidTest/java/org/dhis2/usescases/searchte/SearchTETest.kt @@ -84,7 +84,7 @@ class SearchTETest : BaseTest() { clickOnSearch() checkListOfSearchTEI( title = "First name: $firstName", - attributes = mapOf("Last name:" to lastName), + attributes = mapOf("Last name" to lastName), ) } } @@ -133,7 +133,7 @@ class SearchTETest : BaseTest() { checkListOfSearchTEI( title = "First name: $firstName", - attributes = mapOf("Last name:" to lastName), + attributes = mapOf("Last name" to lastName), ) } } @@ -231,7 +231,7 @@ class SearchTETest : BaseTest() { changeDueDate(scheduledEventTitle) pressBack() } - + composeTestRule.waitForIdle() filterRobot { clickOnFilter() clickOnFilterBy(eventStatusFilter) @@ -402,7 +402,7 @@ class SearchTETest : BaseTest() { searchTeiRobot(composeTestRule) { checkListOfSearchTEI( title = "First name: $name", - attributes = mapOf("Last name:" to lastName) + attributes = mapOf("Last name" to lastName) ) } } diff --git a/app/src/androidTest/java/org/dhis2/usescases/searchte/robot/SearchTeiRobot.kt b/app/src/androidTest/java/org/dhis2/usescases/searchte/robot/SearchTeiRobot.kt index 6cd3a9f8bf..bd6ec51eab 100644 --- a/app/src/androidTest/java/org/dhis2/usescases/searchte/robot/SearchTeiRobot.kt +++ b/app/src/androidTest/java/org/dhis2/usescases/searchte/robot/SearchTeiRobot.kt @@ -132,10 +132,10 @@ class SearchTeiRobot(val composeTestRule: ComposeTestRule) : BaseRobot() { composeTestRule.waitForIdle() composeTestRule.onNodeWithText(title).assertIsDisplayed() attributes.forEach { item -> - item.key?.let { composeTestRule.onNodeWithText(it).assertIsDisplayed() } + item.key?.let { composeTestRule.onNodeWithText("$it:",true).assertIsDisplayed() } composeTestRule.onNode( hasParent(hasTestTag("LIST_CARD_ADDITIONAL_INFO_COLUMN")) - and hasText(item.value), useUnmergedTree = true + and hasText(item.value,true), useUnmergedTree = true ).assertIsDisplayed() } } @@ -174,17 +174,16 @@ class SearchTeiRobot(val composeTestRule: ComposeTestRule) : BaseRobot() { //Given the title is the first attribute val title = "First name: ${displayListFieldsUIModel.name}" val displayedAttributes = createAttributesList(displayListFieldsUIModel) - //When we expand all attribute list composeTestRule.onNodeWithText("Show more").performClick() - + composeTestRule.waitForIdle() //Then The title and all attributes are displayed composeTestRule.onNodeWithText(title).assertIsDisplayed() displayedAttributes.forEach { item -> - item.key?.let { composeTestRule.onNodeWithText(it).assertIsDisplayed() } + item.key?.let { composeTestRule.onNodeWithText("$it:", true).assertIsDisplayed() } composeTestRule.onNode( hasParent(hasTestTag("LIST_CARD_ADDITIONAL_INFO_COLUMN")) - and hasText(item.value), useUnmergedTree = true + and hasText(item.value,true), useUnmergedTree = true ).assertIsDisplayed() } } @@ -210,26 +209,26 @@ class SearchTeiRobot(val composeTestRule: ComposeTestRule) : BaseRobot() { composeTestRule.onNodeWithText(title).assertIsDisplayed() composeTestRule.onNode( hasParent(hasTestTag("LIST_CARD_ADDITIONAL_INFO_COLUMN")) - and hasText(additionalText), + and hasText(additionalText, true), useUnmergedTree = true, ).assertIsDisplayed() } private fun createAttributesList(displayListFieldsUIModel: DisplayListFieldsUIModel) = listOf( AdditionalInfoItem( - key = "Last name:", + key = "Last name", value = displayListFieldsUIModel.lastName, ), AdditionalInfoItem( - key = "Email:", + key = "Email", value = displayListFieldsUIModel.email, ), AdditionalInfoItem( - key = "Date of birth:", + key = "Date of birth", value = displayListFieldsUIModel.birthday, ), AdditionalInfoItem( - key = "Address:", + key = "Address", value = displayListFieldsUIModel.address, ), ) 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 2875d162b2..03f7f02a67 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 @@ -1,5 +1,6 @@ package org.dhis2.usescases.teidashboard.robot +import androidx.compose.ui.test.ExperimentalTestApi import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.hasAnyAncestor import androidx.compose.ui.test.hasAnySibling @@ -125,7 +126,9 @@ class EventRobot(val composeTestRule: ComposeTestRule) : BaseRobot() { ).performTextReplacement(date) } + @OptIn(ExperimentalTestApi::class) fun typeOnDateParameter(dateValue: String) { + composeTestRule.waitUntilAtLeastOneExists(hasTestTag("INPUT_DATE_TIME_TEXT_FIELD"),2000) composeTestRule.apply { onNodeWithTag("INPUT_DATE_TIME_TEXT_FIELD").performClick() onNodeWithTag("INPUT_DATE_TIME_TEXT_FIELD").performTextReplacement(dateValue) diff --git a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventCapture/EventCapturePresenterImpl.kt b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventCapture/EventCapturePresenterImpl.kt index fe94d41867..5ce1b1f769 100644 --- a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventCapture/EventCapturePresenterImpl.kt +++ b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventCapture/EventCapturePresenterImpl.kt @@ -194,13 +194,13 @@ class EventCapturePresenterImpl( .defaultSubscribe( schedulerProvider, onNext = { - EventIdlingResourceSingleton.decrement() if (addNew) { view.restartDataEntry() } else { preferences.setValue(Preference.PREF_COMPLETED_EVENT, eventUid) view.finishDataEntry() } + EventIdlingResourceSingleton.decrement() }, onError = { EventIdlingResourceSingleton.decrement() diff --git a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt index 2f580bc979..cea7197126 100644 --- a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt +++ b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt @@ -451,6 +451,7 @@ class SearchTEIViewModel( fetchListResults { flow -> flow?.let { _refreshData.postValue(Unit) + SearchIdlingResourceSingleton.decrement() } } }