Skip to content

Commit

Permalink
fix: [ANDROAPP-6315] fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xavimolloy committed Jul 10, 2024
1 parent a7e869e commit 4d5b9b6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
}
}
Expand Down Expand Up @@ -133,7 +133,7 @@ class SearchTETest : BaseTest() {

checkListOfSearchTEI(
title = "First name: $firstName",
attributes = mapOf("Last name:" to lastName),
attributes = mapOf("Last name" to lastName),
)
}
}
Expand Down Expand Up @@ -231,7 +231,7 @@ class SearchTETest : BaseTest() {
changeDueDate(scheduledEventTitle)
pressBack()
}

composeTestRule.waitForIdle()
filterRobot {
clickOnFilter()
clickOnFilterBy(eventStatusFilter)
Expand Down Expand Up @@ -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)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down Expand Up @@ -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()
}
}
Expand All @@ -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,
),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ class SearchTEIViewModel(
fetchListResults { flow ->
flow?.let {
_refreshData.postValue(Unit)
SearchIdlingResourceSingleton.decrement()
}
}
}
Expand Down

0 comments on commit 4d5b9b6

Please sign in to comment.