Skip to content

Commit

Permalink
remove all old form components
Browse files Browse the repository at this point in the history
  • Loading branch information
andresmr committed Mar 25, 2024
1 parent 41f5907 commit a215f5e
Show file tree
Hide file tree
Showing 82 changed files with 62 additions and 7,052 deletions.
12 changes: 0 additions & 12 deletions app/src/androidTest/java/org/dhis2/usescases/BaseTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import org.dhis2.common.keystore.KeyStoreRobot.Companion.USERNAME
import org.dhis2.common.mockwebserver.MockWebServerRobot
import org.dhis2.common.preferences.PreferencesRobot
import org.dhis2.common.rules.DisableAnimations
import org.dhis2.commons.featureconfig.model.Feature
import org.dhis2.commons.idlingresource.CountingIdlingResourceSingleton
import org.dhis2.commons.idlingresource.SearchIdlingResourceSingleton
import org.dhis2.commons.prefs.Preference
Expand Down Expand Up @@ -75,7 +74,6 @@ open class BaseTest {
keyStoreRobot = providesKeyStoreRobot(context)
preferencesRobot = providesPreferencesRobot(context)
mockWebServerRobot = providesMockWebserverRobot(context)
disableComposeForms()
}
}

Expand Down Expand Up @@ -168,16 +166,6 @@ open class BaseTest {
(context.applicationContext as AppTest).deleteDatabase(DB_TO_IMPORT)
}

private fun disableComposeForms() {
preferencesRobot.saveValue(Feature.COMPOSE_FORMS.name, false)
}


fun enableComposeForms() {
preferencesRobot.saveValue("SET_FROM_DEVELOPMENT", true)
preferencesRobot.saveValue(Feature.COMPOSE_FORMS.name, true)
}

companion object {
@ClassRule
@JvmField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@ import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.PickerActions
import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import org.dhis2.R
import org.dhis2.common.BaseRobot
import org.dhis2.common.viewactions.clickChildViewWithId
import org.dhis2.usescases.teiDashboard.dashboardfragments.teidata.DashboardProgramViewHolder
import org.dhis2.usescases.teidashboard.robot.EnrollmentRobot
import org.hamcrest.CoreMatchers.containsString
import org.hamcrest.CoreMatchers.equalTo


Expand All @@ -27,13 +21,13 @@ fun enrollmentFormRobot(enrollmentFormRobot: EnrollmentFormRobot.() -> Unit) {
class EnrollmentFormRobot : BaseRobot() {

fun clickOnDateOfBirth() {
onView(withId(R.id.recyclerView))
/*onView(withId(R.id.recyclerView))
.perform(
RecyclerViewActions.actionOnItem<DashboardProgramViewHolder>(
ViewMatchers.hasDescendant(withText(containsString(EnrollmentRobot.DATE_OF_BIRTH))),
clickChildViewWithId(R.id.inputEditText)
)
)
)*/
}

fun changePickerDate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ class EventTest : BaseTest() {
val completion = 92
val email = "[email protected]"

enableComposeForms()

prepareEventDetailsIntentAndLaunchActivity(rule)

eventRegistrationRobot {
Expand Down
36 changes: 15 additions & 21 deletions app/src/androidTest/java/org/dhis2/usescases/form/FormRobot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition
import androidx.test.espresso.matcher.RootMatchers.isPlatformPopup
import androidx.test.espresso.matcher.RootMatchers.withDecorView
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
Expand All @@ -19,11 +18,6 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import org.dhis2.R
import org.dhis2.common.BaseRobot
import org.dhis2.common.matchers.RecyclerviewMatchers.Companion.atPosition
import org.dhis2.common.matchers.RecyclerviewMatchers.Companion.hasItem
import org.dhis2.common.viewactions.clickChildViewWithId
import org.dhis2.common.viewactions.scrollToBottomRecyclerView
import org.dhis2.form.ui.FormViewHolder
import org.dhis2.usescases.form.FormTest.Companion.NO_ACTION_POSITION
import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.anything
Expand All @@ -45,12 +39,12 @@ class FormRobot : BaseRobot() {
}

private fun clickOnSpinner(position: Int) {
onView(withId(R.id.recyclerView))
/*onView(withId(R.id.recyclerView))
.perform(
actionOnItemAtPosition<FormViewHolder>(
position, clickChildViewWithId(R.id.inputEditText)
)
)
)*/
}

private fun selectAction(position: Int) {
Expand All @@ -66,17 +60,17 @@ class FormRobot : BaseRobot() {
}

fun checkHiddenField(label: String) {
onView(withId(R.id.recyclerView))
.check(matches(not(hasItem(withText(label)))))
/*onView(withId(R.id.recyclerView))
.check(matches(not(hasItem(withText(label)))))*/
}

fun checkHiddenSection(label: String) {
onView(withId(R.id.recyclerView))
.check(matches(not(hasItem(withText(label)))))
/*onView(withId(R.id.recyclerView))
.check(matches(not(hasItem(withText(label)))))*/
}

fun checkValueWasAssigned(value: String) {
onView(withId(R.id.recyclerView))
/*onView(withId(R.id.recyclerView))
.check(
matches(
hasItem(
Expand All @@ -86,17 +80,17 @@ class FormRobot : BaseRobot() {
)
)
)
)
)*/
}

fun checkWarningIsShown() {
onView(withId(R.id.recyclerView))
.check(matches(hasItem(hasDescendant(withText("Warning with Current Event ")))))
/*onView(withId(R.id.recyclerView))
.check(matches(hasItem(hasDescendant(withText("Warning with Current Event ")))))*/
}

fun checkErrorIsShown() {
onView(withId(R.id.recyclerView))
.check(matches(hasItem(hasDescendant(withText("Error with current event ")))))
/*onView(withId(R.id.recyclerView))
.check(matches(hasItem(hasDescendant(withText("Error with current event ")))))*/
}

fun checkPopUpWithMessageOnCompleteIsShown(message: String, composeTestRule: ComposeTestRule) {
Expand All @@ -111,8 +105,8 @@ class FormRobot : BaseRobot() {
}

fun checkLabel(label: String, position: Int) {
onView(withId(R.id.recyclerView))
.check(matches(atPosition(position, hasDescendant(withText(label)))))
/*onView(withId(R.id.recyclerView))
.check(matches(atPosition(position, hasDescendant(withText(label)))))*/
}

fun clickOnSaveForm() {
Expand Down Expand Up @@ -140,7 +134,7 @@ class FormRobot : BaseRobot() {
}

fun scrollToBottomForm() {
onView(withId(R.id.recyclerView)).perform(scrollToBottomRecyclerView())
// onView(withId(R.id.recyclerView)).perform(scrollToBottomRecyclerView())
}

fun goToAnalytics() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import org.dhis2.usescases.orgunitselector.orgUnitSelectorRobot
import org.dhis2.usescases.programEventDetail.ProgramEventDetailActivity
import org.dhis2.usescases.programevent.robot.programEventsRobot
import org.dhis2.usescases.teidashboard.robot.eventRobot
import org.junit.Before
import org.junit.Rule
import org.junit.Test

Expand All @@ -30,12 +29,6 @@ class ProgramEventTest : BaseTest() {
return arrayOf(Manifest.permission.ACCESS_FINE_LOCATION)
}

@Before
override fun setUp() {
super.setUp()
enableComposeForms()
}

@Test
fun shouldCreateNewEventAndCompleteIt() {
val eventOrgUnit = "Ngelehun CHC"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItem
import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition
import androidx.test.espresso.contrib.RecyclerViewActions.scrollTo
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
import androidx.test.espresso.matcher.ViewMatchers.withId
Expand All @@ -26,7 +25,6 @@ import org.dhis2.common.matchers.RecyclerviewMatchers
import org.dhis2.common.matchers.RecyclerviewMatchers.Companion.hasItem
import org.dhis2.common.matchers.RecyclerviewMatchers.Companion.hasNoMoreResultsInProgram
import org.dhis2.common.viewactions.openSpinnerPopup
import org.dhis2.common.viewactions.typeChildViewWithId
import org.dhis2.usescases.searchTrackEntity.adapters.SearchTEViewHolder
import org.dhis2.usescases.searchTrackEntity.listView.SearchResult
import org.dhis2.usescases.searchte.entity.DisplayListFieldsUIModel
Expand Down Expand Up @@ -103,7 +101,7 @@ class SearchTeiRobot(val composeTestRule: ComposeTestRule) : BaseRobot() {
}

fun typeAttributeAtPosition(searchWord: String, position: Int) {
onView(withId(R.id.recyclerView))
/*onView(withId(R.id.recyclerView))
.perform(
actionOnItemAtPosition<SearchTEViewHolder>(
position,
Expand All @@ -118,7 +116,7 @@ class SearchTeiRobot(val composeTestRule: ComposeTestRule) : BaseRobot() {
typeChildViewWithId(searchWord, R.id.input_editText)
)
)
closeKeyboard()
closeKeyboard()*/
}

fun clickOnSearch() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,17 @@ import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.PickerActions
import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItem
import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import org.dhis2.R
import org.dhis2.common.BaseRobot
import org.dhis2.common.matchers.RecyclerviewMatchers.Companion.atPosition
import org.dhis2.common.viewactions.clickChildViewWithId
import org.dhis2.common.viewactions.scrollToBottomRecyclerView
import org.dhis2.form.ui.FormViewHolder
import org.dhis2.usescases.flow.teiFlow.entity.EnrollmentListUIModel
import org.dhis2.usescases.teiDashboard.dashboardfragments.teidata.DashboardProgramViewHolder
import org.dhis2.usescases.teiDashboard.teiProgramList.ui.PROGRAM_TO_ENROLL
import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.containsString

fun enrollmentRobot(enrollmentRobot: EnrollmentRobot.() -> Unit) {
EnrollmentRobot().apply {
Expand All @@ -46,27 +41,27 @@ class EnrollmentRobot : BaseRobot() {
}

fun clickOnPersonAttributes(attribute: String) {
onView(withId(R.id.recyclerView))
/*onView(withId(R.id.recyclerView))
.perform(
actionOnItem<FormViewHolder>(
hasDescendant(withText(containsString(attribute))),
clickChildViewWithId(R.id.section_details)
)
)
)*/
}

fun scrollToBottomProgramForm() {
onView(withId(R.id.recyclerView)).perform(scrollToBottomRecyclerView())
// onView(withId(R.id.recyclerView)).perform(scrollToBottomRecyclerView())
}

fun clickOnCalendarItem() {
onView(withId(R.id.recyclerView))
/*onView(withId(R.id.recyclerView))
.perform(
actionOnItem<DashboardProgramViewHolder>(
hasDescendant(withText(containsString(DATE_OF_BIRTH))),
clickChildViewWithId(R.id.inputEditText)
)
)
)*/
}

fun checkActiveAndPastEnrollmentDetails(enrollmentListUIModel: EnrollmentListUIModel) {
Expand Down Expand Up @@ -124,12 +119,12 @@ class EnrollmentRobot : BaseRobot() {
}

fun clickOnInputDate(label: String) {
onView(withId(R.id.recyclerView))
/*onView(withId(R.id.recyclerView))
.perform(
actionOnItem<FormViewHolder>(
hasDescendant(withText(label)), clickChildViewWithId(R.id.inputEditText)
)
)
)*/
}

fun selectSpecificDate(year: Int, monthOfYear: Int, dayOfMonth: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,13 @@ import androidx.compose.ui.test.performTextInput
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import org.dhis2.R
import org.dhis2.common.BaseRobot
import org.dhis2.common.matchers.hasCompletedPercentage
import org.dhis2.common.viewactions.clickChildViewWithId
import org.dhis2.common.viewactions.scrollToBottomRecyclerView
import org.dhis2.common.viewactions.typeChildViewWithId
import org.dhis2.form.ui.FormViewHolder
import org.dhis2.ui.dialogs.bottomsheet.MAIN_BUTTON_TAG
import org.dhis2.ui.dialogs.bottomsheet.SECONDARY_BUTTON_TAG
import org.dhis2.usescases.teiDashboard.dashboardfragments.teidata.DashboardProgramViewHolder

fun eventRobot(
composeTestRule: ComposeTestRule,
Expand All @@ -38,7 +32,7 @@ fun eventRobot(
class EventRobot(val composeTestRule: ComposeTestRule) : BaseRobot() {

fun scrollToBottomForm() {
onView(withId(R.id.recyclerView)).perform(scrollToBottomRecyclerView())
// onView(withId(R.id.recyclerView)).perform(scrollToBottomRecyclerView())
}

fun clickOnFormFabButton() {
Expand All @@ -65,13 +59,13 @@ class EventRobot(val composeTestRule: ComposeTestRule) : BaseRobot() {
var formLength = 0

while (formLength < numberFields) {
onView(withId(R.id.recyclerView))
/*onView(withId(R.id.recyclerView))
.perform(
actionOnItemAtPosition<DashboardProgramViewHolder>(
formLength,
clickChildViewWithId(R.id.yes)
)
)
)*/
formLength++
}
}
Expand All @@ -81,12 +75,12 @@ class EventRobot(val composeTestRule: ComposeTestRule) : BaseRobot() {
}

fun typeOnRequiredEventForm(text: String, position: Int) {
onView(withId(R.id.recyclerView))
/*onView(withId(R.id.recyclerView))
.perform(
actionOnItemAtPosition<FormViewHolder>( //EditTextCustomHolder
position, typeChildViewWithId(text, R.id.input_editText)
)
)
)*/
}

fun openMenuMoreOptions() {
Expand Down
Loading

0 comments on commit a215f5e

Please sign in to comment.