Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ANDROAPP-5800] Search parameters #3497

Merged
merged 47 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e38a0c6
[ANDROAPP-5800] Replace xml view by ComposeView
andresmr Feb 1, 2024
e53dbfd
[ANDROAPP-5800] Set up SearchParameter structure
andresmr Feb 2, 2024
14447e6
[ANDROAPP-5800] Implement SearchParametersRepository
andresmr Feb 2, 2024
bb3acf8
[ANDROAPP-5800] update search query
andresmr Feb 2, 2024
2d3bb06
[ANDROAPP-500] Remove deprecated steps in walkthrough
andresmr Feb 5, 2024
cfcf67e
[ANDROAPP-500] Implement search and clear button
andresmr Feb 6, 2024
a412e2b
[ANDROAPP-500] Implement SnackBar for min attributes search
andresmr Feb 6, 2024
c600945
[ANDROAPP-500] Refactor search and clear button to SearchTEIViewModel
andresmr Feb 7, 2024
acd7e29
[ANDROAPP-500] rebase develop and update library
andresmr Feb 7, 2024
bb50331
[ANDROAPP-500] show min attributes message
andresmr Feb 7, 2024
a4883ac
[ANDROAPP-5800] handle focus
andresmr Feb 8, 2024
056d4c1
[ANDROAPP-5800] update design library
andresmr Feb 8, 2024
95fbc6a
[ANDROAPP-5800] clear search parameters
andresmr Feb 9, 2024
9f659f9
[ANDROAPP-5800] Use fieldUiModel for parameter provider
andresmr Feb 12, 2024
874be46
[ANDROAPP-5800] insert inputstyle as parameter
andresmr Feb 12, 2024
43ab28a
[ANDROAPP-5800] text range to textInput model
andresmr Feb 12, 2024
21ee9ed
[ANDROAPP-5800] update display name values
andresmr Feb 12, 2024
6c62fdc
[ANDROAPP-5800] show org unit selector
andresmr Feb 13, 2024
5b9e2ab
[ANDROAPP-5800] remove SearchRepository.kt
andresmr Feb 13, 2024
440e7d9
[ANDROAPP-5800] fix tests
andresmr Feb 13, 2024
464b2be
[ANDROAPP-5800] fix tests
andresmr Feb 13, 2024
7c23a5e
[ANDROAPP-5800] Add composeTestRule to functional tests
andresmr Feb 14, 2024
239753a
[ANDROAPP-5800] Update design library version
andresmr Feb 14, 2024
9d43c4e
[ANDROAPP-5800] Remove SearchParametersRepository.kt and use SearchR…
andresmr Feb 14, 2024
c019054
[ANDROAPP-5800] provide icons based on valueType
andresmr Feb 14, 2024
076efb7
[ANDROAPP-5800] Implement QR and Barcode scanning
andresmr Feb 14, 2024
cf6d001
[ANDROAPP-5800] fix code smells
andresmr Feb 14, 2024
599211a
[ANDROAPP-5800] clear focus on clear search
andresmr Feb 15, 2024
b02644a
[ANDROAPP-5800] close keyboard om search and clear
andresmr Feb 15, 2024
371fe00
[ANDROAPP-5800] close empty fields when clear search
andresmr Feb 15, 2024
f5eba04
[ANDROAPP-5800] request focus when item is opened
andresmr Feb 15, 2024
73379df
[ANDROAPP-5800] move focus to next item
andresmr Feb 15, 2024
3b2699d
[ANDROAPP-5800] enable disable search button on empty parameters
andresmr Feb 16, 2024
0ba6231
[ANDROAPP-5805] clear search button visibility
andresmr Feb 20, 2024
006d164
[ANDROAPP-5805] Adapt top bar when searching
andresmr Feb 20, 2024
e7f2a8e
[ANDROAPP-5805] Add replay to mutable search flow in order to emit th…
andresmr Feb 20, 2024
d88ef08
[ANDROAPP-5805] Remove connected rounded corners on landscape
andresmr Feb 20, 2024
7655b38
[ANDROAPP-5805] update ProgramEventTest to remove check on org unit w…
andresmr Feb 20, 2024
d880fa7
[ANDROAPP-5800] configure toolbar for landscape
andresmr Feb 21, 2024
661cdf0
[ANDROAPP-5800] remove unused program variable
andresmr Feb 21, 2024
04b1792
[ANDROAPP-5800] remove needs force update parameter from Form only us…
andresmr Feb 21, 2024
8ef5ffd
[ANDROAPP-5800] Remember ScanContract on SearchParametersScreen
andresmr Feb 21, 2024
9fe4601
[ANDROAPP-5800] Clear focus when closing search
andresmr Feb 22, 2024
ed4c6ac
[ANDROAPP-5800] Avoid double updating Age field
andresmr Feb 22, 2024
4152188
[ANDROAPP-5800] Not loop on next click when gets the last item
andresmr Feb 22, 2024
0f493d0
[ANDROAPP-5800] set rounded corners on show filters landscape
andresmr Feb 22, 2024
4c4730a
[ANDROAPP-5800] fix code smell
andresmr Feb 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.dhis2.usescases.flow.searchFlow

import org.dhis2.common.BaseRobot
import org.dhis2.usescases.searchte.robot.filterRobot
import org.dhis2.usescases.searchte.robot.searchTeiRobot

fun searchFlowRobot(searchFlowRobot: SearchFlowRobot.() -> Unit) {
SearchFlowRobot().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.dhis2.usescases.flow.searchFlow
import android.content.Intent
import androidx.compose.ui.text.capitalize
import androidx.compose.ui.text.intl.Locale
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import org.dhis2.R
Expand All @@ -21,6 +22,9 @@ class SearchFlowTest : BaseTest() {
@get:Rule
val rule = ActivityTestRule(SearchTEActivity::class.java, false, false)

@get:Rule
val composeTestRule = createComposeRule()

private val dateRegistration = createFirstSpecificDate()
private val dateEnrollment = createEnrollmentDate()

Expand All @@ -35,7 +39,7 @@ class SearchFlowTest : BaseTest() {
prepareWomanProgrammeIntentAndLaunchActivity(rule)

teiFlowRobot {
registerTEI(registerTEIDetails)
registerTEI(registerTEIDetails, composeTestRule)
pressBack()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ class SyncFlowTest : BaseTest() {

prepareTBProgrammeIntentAndLaunchActivity(ruleSearch)

searchTeiRobot {
searchTeiRobot(composeTestRule) {
clickOnOpenSearch()
typeAttributeAtPosition(teiName, 0)
typeAttributeAtPosition(teiLastName, 1)
openNextSearchParameter("First name")
typeOnNextSearchTextParameter(teiName)
openNextSearchParameter("Last name")
typeOnNextSearchTextParameter(teiLastName)
clickOnSearch()
clickOnTEI(teiName, teiLastName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ fun teiFlowRobot(teiFlowRobot: TeiFlowRobot.() -> Unit) {

class TeiFlowRobot : BaseRobot() {

fun registerTEI(registrationModel: RegisterTEIUIModel) {
fun registerTEI(
registrationModel: RegisterTEIUIModel,
composeTestRule: ComposeContentTestRule
) {
val registrationDate = registrationModel.firstSpecificDate
val enrollmentDate = registrationModel.enrollmentDate

searchTeiRobot {
typeAttributeAtPosition(registrationModel.name, 0)
typeAttributeAtPosition(registrationModel.lastName, 1)
clickOnDateField()
selectSpecificDate(registrationDate.year, registrationDate.month, registrationDate.day)
acceptDate()
searchTeiRobot(composeTestRule) {
openNextSearchParameter("First name")
typeOnNextSearchTextParameter(registrationModel.name)
openNextSearchParameter("Last name")
typeOnNextSearchTextParameter(registrationModel.lastName)
openNextSearchParameter("Date of birth")
typeOnDateParameter("${registrationDate.day}0${registrationDate.month}${registrationDate.year}")
clickOnSearch()
clickOnEnroll()
selectSpecificDate(enrollmentDate.year, enrollmentDate.month, enrollmentDate.day)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TeiFlowTest: BaseTest() {
prepareWomanProgrammeIntentAndLaunchActivity(ruleSearch)

teiFlowRobot {
registerTEI(registerTeiDetails)
registerTEI(registerTeiDetails, composeTestRule)
closeEnrollmentAndCheckEvents(composeTestRule,totalEventsPerEnrollment)
enrollToProgram(composeTestRule, ADULT_WOMAN_PROGRAM)
checkActiveAndPastEnrollmentDetails(enrollmentListDetails)
Expand Down
8 changes: 4 additions & 4 deletions app/src/androidTest/java/org/dhis2/usescases/form/FormTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import org.dhis2.usescases.searchte.robot.searchTeiRobot
import org.dhis2.usescases.teiDashboard.TeiDashboardMobileActivity
import org.dhis2.usescases.teidashboard.robot.enrollmentRobot
import org.dhis2.usescases.teidashboard.robot.eventRobot
import org.dhis2.usescases.teidashboard.robot.teiDashboardRobot
import org.junit.After
import org.junit.Ignore
import org.junit.Rule
Expand Down Expand Up @@ -241,7 +240,7 @@ class FormTest : BaseTest() {
val firstSectionPosition = 1
startSearchActivity(ruleSearch)

searchTeiRobot {
searchTeiRobot(composeTestRule) {
clickOnOpenSearch()
typeAttributeAtPosition("optionGroup", 1)
clickOnSearch()
Expand Down Expand Up @@ -285,9 +284,10 @@ class FormTest : BaseTest() {

startSearchActivity(ruleSearch)

searchTeiRobot {
searchTeiRobot(composeTestRule) {
clickOnOpenSearch()
typeAttributeAtPosition("abc", 1)
openNextSearchParameter("First name")
typeOnNextSearchTextParameter("abc")
clickOnSearch()
clickOnEnroll()
orgUnitSelectorRobot(composeTestRule) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ProgramEventTest : BaseTest() {
prepareProgramAndLaunchActivity(atenatalCare)

programEventsRobot {
clickOnEvent(eventDate, eventOrgUnit)
clickOnEvent(eventDate)
}

eventRobot {
Expand All @@ -84,7 +84,7 @@ class ProgramEventTest : BaseTest() {
disableRecyclerViewAnimations()

programEventsRobot {
clickOnEvent(eventDate, eventOrgUnit)
clickOnEvent(eventDate)
}

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

programEventsRobot {
checkEventIsComplete(eventDate, eventOrgUnit)
clickOnEvent(eventDate, eventOrgUnit)
clickOnEvent(eventDate)
}

eventRobot {
Expand All @@ -118,7 +118,7 @@ class ProgramEventTest : BaseTest() {
prepareProgramAndLaunchActivity(atenatalCare)

programEventsRobot {
clickOnEvent(eventDate, eventOrgUnit)
clickOnEvent(eventDate)
}
eventRobot {
clickOnDetails()
Expand All @@ -135,7 +135,7 @@ class ProgramEventTest : BaseTest() {
disableRecyclerViewAnimations()

programEventsRobot {
clickOnEvent(eventDate, eventOrgUnit)
clickOnEvent(eventDate)
}
eventRobot {
openMenuMoreOptions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItem
import androidx.test.espresso.matcher.ViewMatchers.*
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.dhis2.common.matchers.RecyclerviewMatchers.Companion.hasItem
Expand All @@ -23,19 +27,14 @@ fun programEventsRobot(programEventsRobot: ProgramEventsRobot.() -> Unit) {

class ProgramEventsRobot : BaseRobot() {

fun clickOnEvent(eventDate: String, eventOrgUnit: String) {
fun clickOnEvent(eventDate: String) {
onView(withId(R.id.recycler)).perform(
RecyclerViewActions.scrollTo<EventViewHolder>(
allOf(
hasDescendant(withText(eventDate)),
hasDescendant(withText(eventOrgUnit))
)
hasDescendant(withText(eventDate)),
),
actionOnItem<EventViewHolder>(
allOf(
hasDescendant(withText(eventDate)),
hasDescendant(withText(eventOrgUnit))
), click()
hasDescendant(withText(eventDate)),
click(),
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ class SearchTETest : BaseTest() {
@Test
fun shouldSuccessfullySearchByName() {
val firstName = "Tim"
val firstNamePosition = 0
val orgUnit = "Ngelehun CHC"

prepareChildProgrammeIntentAndLaunchActivity(rule)

searchTeiRobot {
searchTeiRobot(composeTestRule) {
clickOnOpenSearch()
typeAttributeAtPosition(firstName, firstNamePosition)
openNextSearchParameter("First name")
typeOnNextSearchTextParameter(firstName)
clickOnSearch()
checkListOfSearchTEI(firstName, orgUnit)
}
Expand All @@ -76,13 +76,13 @@ class SearchTETest : BaseTest() {
@Test
fun shouldShowErrorWhenCanNotFindSearchResult() {
val firstName = "asdssds"
val firstNamePosition = 1

prepareTestProgramRulesProgrammeIntentAndLaunchActivity(rule)

searchTeiRobot {
searchTeiRobot(composeTestRule) {
clickOnOpenSearch()
typeAttributeAtPosition(firstName, firstNamePosition)
openNextSearchParameter("First name")
typeOnNextSearchTextParameter(firstName)
clickOnSearch()
checkNoSearchResult()
}
Expand All @@ -91,16 +91,16 @@ class SearchTETest : BaseTest() {
@Test
fun shouldSuccessfullySearchUsingMoreThanOneField() {
val firstName = "Anna"
val firstNamePosition = 0
val lastName = "Jones"
val lastNamePosition = 1

prepareChildProgrammeIntentAndLaunchActivity(rule)

searchTeiRobot {
searchTeiRobot(composeTestRule) {
clickOnOpenSearch()
typeAttributeAtPosition(firstName, firstNamePosition)
typeAttributeAtPosition(lastName, lastNamePosition)
openNextSearchParameter("First name")
typeOnNextSearchTextParameter(firstName)
openNextSearchParameter("Last name")
typeOnNextSearchTextParameter(lastName)
clickOnSearch()
checkListOfSearchTEI(firstName, lastName)
}
Expand All @@ -113,7 +113,7 @@ class SearchTETest : BaseTest() {

prepareChildProgrammeIntentAndLaunchActivity(rule)

searchTeiRobot {
searchTeiRobot(composeTestRule) {
clickOnProgramSpinner()
selectAProgram(tbProgram)
checkProgramHasChanged(tbProgram)
Expand All @@ -122,23 +122,20 @@ class SearchTETest : BaseTest() {

@Test
fun shouldCheckDisplayInList() {
val birthdaySearch = createDateOfBirthSearch()
val displayInListData = createDisplayListFields()
val namePosition = 0
val lastNamePosition = 1

setDatePicker()
prepareTestAdultWomanProgrammeIntentAndLaunchActivity(rule)

searchTeiRobot {
typeAttributeAtPosition(displayInListData.name, namePosition)
typeAttributeAtPosition(displayInListData.lastName, lastNamePosition)
clickOnDateField()
selectSpecificDate(birthdaySearch.year, birthdaySearch.month, birthdaySearch.day)
acceptDate()
searchTeiRobot(composeTestRule) {
openNextSearchParameter("First name")
typeOnNextSearchTextParameter(displayInListData.name)
openNextSearchParameter("Last name")
typeOnNextSearchTextParameter(displayInListData.lastName)
openNextSearchParameter("Date of birth")
typeOnDateParameter("01012001")
clickOnSearch()
checkFieldsFromDisplayList(
composeTestRule,
displayInListData,
)
}
Expand Down Expand Up @@ -179,7 +176,7 @@ class SearchTETest : BaseTest() {
prepareTestAdultWomanProgrammeIntentAndLaunchActivity(rule)

teiFlowRobot {
registerTEI(registerTeiDetails)
registerTEI(registerTeiDetails, composeTestRule)
changeDueDate(overdueDate, programStage, orgUnit, composeTestRule)
pressBack()
composeTestRule.onNodeWithTag(SECONDARY_BUTTON_TAG).performClick()
Expand Down Expand Up @@ -276,16 +273,16 @@ class SearchTETest : BaseTest() {
fun shouldSuccessfullyFilterBySync() {
val teiName = "Frank"
val teiLastName = "Fjordsen"
val firstNamePosition = 0
val lastNamePosition = 1
val syncFilter = context.getString(R.string.action_sync)
val totalCount = "1"
prepareChildProgrammeIntentAndLaunchActivity(rule)

searchTeiRobot {
searchTeiRobot(composeTestRule) {
clickOnOpenSearch()
typeAttributeAtPosition(teiName, firstNamePosition)
typeAttributeAtPosition(teiLastName, lastNamePosition)
openNextSearchParameter("First name")
typeOnNextSearchTextParameter(teiName)
openNextSearchParameter("Last name")
typeOnNextSearchTextParameter(teiLastName)
clickOnSearch()
clickOnTEI(teiName, teiLastName)
}
Expand All @@ -311,17 +308,17 @@ class SearchTETest : BaseTest() {
fun shouldSuccessfullySearchAndFilter() {
val name = "Anna"
val lastName = "Jones"
val namePosition = 0
val enrollmentStatus = context.getString(R.string.filters_title_enrollment_status)
.format(context.resources.getQuantityString(R.plurals.enrollment, 1).capitalize(Locale.current))
val totalCount = "2"
val totalFilterCount = "1"

prepareChildProgrammeIntentAndLaunchActivity(rule)

searchTeiRobot {
searchTeiRobot(composeTestRule) {
clickOnOpenSearch()
typeAttributeAtPosition(name, namePosition)
openNextSearchParameter("First name")
typeOnNextSearchTextParameter(name)
clickOnSearch()
}

Expand All @@ -336,7 +333,7 @@ class SearchTETest : BaseTest() {
checkTEIsAreOpen()
}

searchTeiRobot {
searchTeiRobot(composeTestRule) {
checkListOfSearchTEI(name, lastName)
}
}
Expand All @@ -347,7 +344,7 @@ class SearchTETest : BaseTest() {

prepareChildProgrammeIntentAndLaunchActivity(rule)

searchTeiRobot {
searchTeiRobot(composeTestRule) {
clickOnShowMap()
try {
val device = UiDevice.getInstance(getInstrumentation())
Expand Down
Loading
Loading