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 4826 display message when event has no sections or data elements config issue #3481

Closed
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
2284b8f
add: [ANDROAPP-4826] string added
DavidAparicioAlbaAsenjo Jan 29, 2024
8baf232
add: [ANDROAPP-4826] no section infobar added
DavidAparicioAlbaAsenjo Jan 29, 2024
28a23fc
delete: [ANDROAPP-4826] dummy section removed
DavidAparicioAlbaAsenjo Jan 29, 2024
0a75c67
update: [ANDROAPP-4826] code formated, infobar added
DavidAparicioAlbaAsenjo Jan 30, 2024
aabb3f9
Merge branch 'develop' into ANDROAPP-4826-Display-message-when-event-…
DavidAparicioAlbaAsenjo Jan 30, 2024
11ccb77
[ANDROAPP-5760] DashboardRepositoryImpl refactor to kotlin, new test …
xavimolloy Dec 14, 2023
93a372f
Move shouldSuccessfullyCreateANewEvent to unit test
Balcan Jan 29, 2024
2c94bda
Move shouldNotBeAbleToCreateNewEventsWhenFull to unit tests
Balcan Jan 29, 2024
95e3f34
Move shouldSuccessfullySyncAChangedTEI to unit tests
Balcan Jan 31, 2024
6dcf25d
update: [ANDROAPP-4826] focus next restored
DavidAparicioAlbaAsenjo Jan 31, 2024
eac7a07
fix test
Balcan Feb 1, 2024
32503c7
fix test
Balcan Feb 2, 2024
c852df0
Merge pull request #3482 from dhis2/ANDROAPP-5760
andresmr Feb 2, 2024
4ac8abd
Remove deep links
andresmr Feb 5, 2024
5feab0b
update version code
andresmr Feb 5, 2024
d90d828
Merge pull request #3488 from dhis2/remove_deep_links
andresmr Feb 5, 2024
e028271
[ANDROAPP-5645] Close enrollment data section if already completed (#…
Balcan Feb 5, 2024
69520d9
feat: [ANDROAPP-5683] legend description (#3486)
mmmateos Feb 5, 2024
1f50e29
fix: [ANDROAPP-5900] adapt Input providers to new TextFieldValue usage
xavimolloy Feb 2, 2024
be69d70
fix: [ANDROAPP-5900] update mobile ui 0.2-20240206.071329-16
xavimolloy Feb 6, 2024
90bdca6
Merge branch 'main' into develop-2.9.1
xavimolloy Feb 6, 2024
84aab55
fix: [ANDROAPP-5900] set initial selection to value length
xavimolloy Feb 6, 2024
4ce45c2
Merge pull request #3485 from dhis2/ANDROAPP-5900-Some-values-are-und…
andresmr Feb 6, 2024
4fcb25e
updates paging on search to paging3
ferdyrod Jan 19, 2024
a022c25
update search tests
ferdyrod Jan 22, 2024
eafa25d
fix code smells
ferdyrod Jan 23, 2024
1765614
updates sdk and prevents scroll to top when paginating
ferdyrod Jan 26, 2024
1f5d2c7
Updates sdk
ferdyrod Feb 6, 2024
7b8f83c
Merge branch 'develop' into develop-2.9.1
xavimolloy Feb 6, 2024
271fff1
Merge pull request #3491 from dhis2/develop-2.9.1
andresmr Feb 7, 2024
daa4428
Merge branch 'develop' into ANDROAPP-5536
ferdyrod Feb 7, 2024
74be855
Merge pull request #3469 from dhis2/ANDROAPP-5536
andresmr Feb 8, 2024
b7722f9
update and adapt design library version
andresmr Feb 8, 2024
c6ab8bc
fix tests
andresmr Feb 8, 2024
44bbb1f
Merge pull request #3492 from dhis2/update_design_library
andresmr Feb 8, 2024
23d412c
adds helpertext to table's input field (#3487)
ferdyrod Feb 12, 2024
e46ba93
add: [ANDROAPP-4826] string added
DavidAparicioAlbaAsenjo Jan 29, 2024
09cbd09
add: [ANDROAPP-4826] no section infobar added
DavidAparicioAlbaAsenjo Jan 29, 2024
9ec039b
delete: [ANDROAPP-4826] dummy section removed
DavidAparicioAlbaAsenjo Jan 29, 2024
bd9a5e6
update: [ANDROAPP-4826] code formated, infobar added
DavidAparicioAlbaAsenjo Jan 30, 2024
dbc2f78
update: [ANDROAPP-4826] focus next restored
DavidAparicioAlbaAsenjo Jan 31, 2024
f1efe26
add: [ANDROAPP-4826] no section infobar added
DavidAparicioAlbaAsenjo Jan 29, 2024
ca6a6a0
delete: [ANDROAPP-4826] dummy section removed
DavidAparicioAlbaAsenjo Jan 29, 2024
3b95666
update: [ANDROAPP-4826] code formated, infobar added
DavidAparicioAlbaAsenjo Jan 30, 2024
e8f0244
Merge branch 'ANDROAPP-4826-Display-message-when-event-has-no-section…
DavidAparicioAlbaAsenjo Feb 13, 2024
031e2ca
update: [ANDROAPP-4826] design system version updated, custom message…
DavidAparicioAlbaAsenjo Feb 13, 2024
c1bd858
update: [ANDROAPP-4826] code formatted
DavidAparicioAlbaAsenjo Feb 13, 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 @@ -51,42 +51,6 @@ class SyncFlowTest : BaseTest() {
ApplicationProvider.getApplicationContext<AppTest>().mutableWorkInfoStatuses
}

@Test
fun shouldSuccessfullySyncAChangedTEI() {
val teiName = "Scott"
val teiLastName = "Kelley"

prepareTBProgrammeIntentAndLaunchActivity(ruleSearch)
searchTeiRobot {
clickOnOpenSearch()
typeAttributeAtPosition(teiName, 0)
typeAttributeAtPosition(teiLastName, 1)
clickOnSearch()
clickOnTEI(teiName, teiLastName)
}

teiDashboardRobot {
clickOnGroupEventByName(TB_VISIT)
clickOnEventWith(TB_VISIT_EVENT_DATE, ORG_UNIT)
}

eventRobot {
clickOnUpdate()
}

teiDashboardRobot {
composeTestRule.onNodeWithText("Sync").performClick()
}
syncFlowRobot {
waitToDebounce(500)
clickOnSyncButton(composeTestRule)
workInfoStatusLiveData.postValue(arrayListOf(mockedGranularWorkInfo(WorkInfo.State.RUNNING)))
workInfoStatusLiveData.postValue(arrayListOf(mockedGranularWorkInfo(WorkInfo.State.SUCCEEDED)))
checkSyncWasSuccessfully(composeTestRule)
}
cleanLocalDatabase()
}

@Test
fun shouldShowErrorWhenTEISyncFails() {
val teiName = "Lars"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.not
import org.hisp.dhis.mobile.ui.designsystem.component.AdditionalInfoItem
import org.hisp.dhis.mobile.ui.designsystem.component.ListCard
import org.hisp.dhis.mobile.ui.designsystem.component.ListCardTitleModel


fun searchTeiRobot(searchTeiRobot: SearchTeiRobot.() -> Unit) {
Expand Down Expand Up @@ -186,7 +187,7 @@ class SearchTeiRobot : BaseRobot() {

composeTestRule.setContent {
ListCard(
title = title,
title = ListCardTitleModel(text = title),
additionalInfoList = displayedAttributes,
onCardClick = { }
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
package org.dhis2.usescases.teidashboard

import android.view.View
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.rules.activityScenarioRule
import dhis2.org.analytics.charts.Charts
import io.reactivex.Observable
import org.dhis2.R
import org.dhis2.android.rtsm.utils.NetworkUtils
import org.dhis2.commons.date.DateUtils
import org.dhis2.commons.filters.FilterManager
import org.dhis2.commons.resources.ResourceManager
import org.dhis2.ui.ThemeManager
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.EventInitialTest
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.data.EventDetailsRepository
import org.dhis2.usescases.main.program.ProgramPresenter
import org.dhis2.usescases.teiDashboard.DashboardRepositoryImpl
import org.dhis2.usescases.teiDashboard.DashboardViewModel
import org.dhis2.usescases.teiDashboard.TeiAttributesProvider
import org.dhis2.usescases.teiDashboard.TeiDashboardContracts
import org.dhis2.usescases.teiDashboard.TeiDashboardMobileActivity
import org.dhis2.utils.analytics.AnalyticsHelper
import org.hisp.dhis.android.core.D2
import org.hisp.dhis.android.core.event.EventEditableStatus
import org.hisp.dhis.android.core.trackedentity.TrackedEntityInstance
import org.hisp.dhis.android.core.trackedentity.TrackedEntityType
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.mockito.ArgumentMatchers
import org.mockito.Mockito
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.doReturnConsecutively
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever
import java.util.Calendar

class TeiDashboardMobileActivityTest {

@get:Rule
val activityScenarioRule = activityScenarioRule<TeiDashboardMobileActivity>()

@get:Rule
val composeRule = createAndroidComposeRule<TeiDashboardMobileActivity>()


private lateinit var viewModel: DashboardViewModel

private val d2: D2 = Mockito.mock(D2::class.java, Mockito.RETURNS_DEEP_STUBS)
private val resources: ResourceManager = mock()
private val charts: Charts = mock()
private val teiAttributesProvider: TeiAttributesProvider = mock()


private var repository: DashboardRepositoryImpl = mock {

}
var tei = Observable.just(TrackedEntityInstance.builder()
.uid(TEI_Uid)
.created(Calendar.getInstance().time)
.lastUpdated(Calendar.getInstance().time)
.organisationUnit(ORG_UNIT_UID)
.trackedEntityType(TETYPE_NAME)
.build())

private val teType: TrackedEntityType = mock()

private val analyticsHelper = mock<AnalyticsHelper> {
}

private val themeManager: ThemeManager = mock()
private val presenter: TeiDashboardContracts.Presenter = mock()
private val filterManager: FilterManager = mock()
private val networkUtils: NetworkUtils = mock()

companion object {
const val ENROLLMENT_UID = "enrollmentUid"
const val TEI_Uid = "TEIUid"
const val PROGRAM_UID = "programUid"
const val TETYPE_NAME = "TETypeName"
const val INITIAL_ORG_UNIT_UID = "initialOrgUnitUid"
const val PROGRAM_STAGE_NAME = "Marvellous Program Stage"
const val EXECUTION_DATE = "Date of Marvellous Program Stage"
const val ORG_UNIT_UID = "orgUnitUid"
const val ENROLLMENT_VALUE_WITH_NOTE = "EnrollmentValueWithNote"
const val TEI_UID_VALUE_WITH_NOTE = "TeiUidValueWithNote"
const val CHILD_PROGRAM_UID_VALUE = "childProgramUid"
}

private fun initViewModel() {
viewModel = DashboardViewModel(
repository ,
analyticsHelper
)

}

private fun setUp() {
initRepository()
initViewModel()
}

private fun initRepository() {
repository = DashboardRepositoryImpl(
d2,
charts,
TEI_Uid,
PROGRAM_UID,
ENROLLMENT_UID,
resources,
teiAttributesProvider,
)


}


@Test
fun shouldSuccessfullyInitializeTeiDashBoardMobileActivity() {
setUp()
whenever (repository.getTETypeName()) doReturn TETYPE_NAME
whenever ( repository.getTrackedEntityInstance("") ) doReturn mock()
whenever {repository.getTrackedEntityInstance("").flatMap { tei: TrackedEntityInstance ->
d2.trackedEntityModule().trackedEntityTypes()
.uid(tei.trackedEntityType())
.get()
.toObservable()
} } doReturn mock()
whenever {repository.getTrackedEntityInstance("").flatMap { tei: TrackedEntityInstance ->
d2.trackedEntityModule().trackedEntityTypes()
.uid(tei.trackedEntityType())
.get()
.toObservable()
}.blockingFirst() } doReturn { teType }
whenever(
presenter.teType
) doReturn TETYPE_NAME

whenever(
repository.getTETypeName()
) doReturn TETYPE_NAME
whenever(
d2.trackedEntityModule() ) doReturn mock()
whenever(
d2.trackedEntityModule().trackedEntityInstances() ) doReturn mock()
whenever(
d2.trackedEntityModule().trackedEntityInstances().byUid() ) doReturn mock()
whenever(
d2.trackedEntityModule().trackedEntityInstances().byUid().eq("") ) doReturn mock()
whenever(
d2.trackedEntityModule().trackedEntityInstances().byUid().eq("").one() ) doReturn mock()
whenever(
d2.trackedEntityModule().trackedEntityInstances().byUid().eq("").one()
.blockingGet() ) doReturn mock()

whenever(
d2.trackedEntityModule().trackedEntityTypes() ) doReturn mock()
whenever(
d2.trackedEntityModule().trackedEntityTypes().uid("") ) doReturn mock()
whenever(
d2.trackedEntityModule().trackedEntityTypes().uid("").get() ) doReturn mock()
whenever(
d2.trackedEntityModule().trackedEntityTypes().uid("").get().toObservable() ) doReturn mock()
whenever(
d2.trackedEntityModule().trackedEntityTypes().uid("").get().toObservable() ) doReturn mock()




ActivityScenario.launch(TeiDashboardMobileActivity::class.java).onActivity { activity ->

val showMoreOptions = activity.findViewById<View>(R.id.moreOptions)
showMoreOptions.performClick()
}


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,6 @@ class TeiDashboardTest : BaseTest() {
}
}

@Test
fun shouldNotBeAbleToCreateNewEventsWhenFull() {
prepareTeiOpenedWithFullEventsAndLaunchActivity(rule)

teiDashboardRobot {
clickOnMenuMoreOptions()
clickOnTimelineEvents()
checkCanNotAddEvent()
}
}

@Test
fun shouldOpenEventAndSaveSuccessfully() {
setupCredentials()
Expand Down Expand Up @@ -235,32 +224,6 @@ class TeiDashboardTest : BaseTest() {
}
}

@Test
fun shouldSuccessfullyCreateANewEvent() {
prepareTeiToCreateANewEventAndLaunchActivity(rule)

teiDashboardRobot {
clickOnMenuMoreOptions()
clickOnTimelineEvents()
clickOnFab()
clickOnCreateNewEvent()
clickOnFirstReferralEvent()
waitToDebounce(2000)
clickOnReferralNextButton()
waitToDebounce(600)
}

eventRobot {
fillRadioButtonForm(4)
clickOnFormFabButton()
clickOnNotNow(composeTestRule)
}

teiDashboardRobot {
checkEventWasCreatedAndOpen(LAB_MONITORING, 0)
}
}

@Test
fun shouldOpenEventEditAndSaveSuccessfully() {
prepareTeiOpenedToEditAndLaunchActivity(rule)
Expand Down
11 changes: 0 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,6 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:autoVerify="true">
<category android:name="android.intent.category.DEFAULT" />

<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="play.dhis2.org"
android:scheme="https" />
</intent-filter>
</activity>
<activity
android:name=".usescases.login.LoginActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class DataValuePresenter(
id = cell.id ?: "",
mainLabel = dataElement?.displayFormName() ?: "-",
secondaryLabels = repository.getCatOptComboOptions(ids[1]),
helperText = dataElement?.description(),
currentValue = cell.value,
keyboardInputType = inputType,
error = errors[cell.id],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.dhis2.databinding.ItemDatasetBinding
import org.dhis2.usescases.datasets.datasetDetail.DataSetDetailModel
import org.dhis2.usescases.datasets.datasetDetail.datasetList.mapper.DatasetCardMapper
import org.hisp.dhis.mobile.ui.designsystem.component.ListCard
import org.hisp.dhis.mobile.ui.designsystem.component.ListCardTitleModel

class DataSetListAdapter(
val viewModel: DataSetListViewModel,
Expand Down Expand Up @@ -49,7 +50,7 @@ class DataSetListAdapter(
)
ListCard(
listAvatar = card.avatar,
title = card.title,
title = ListCardTitleModel(text = card.title),
lastUpdated = card.lastUpdated,
additionalInfoList = card.additionalInfo,
actionButton = card.actionButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.dhis2.data.forms.dataentry.ValueStore
import org.dhis2.data.forms.dataentry.ValueStoreImpl
import org.dhis2.form.data.EnrollmentRepository
import org.dhis2.form.data.RulesRepository
import org.dhis2.form.data.metadata.EnrollmentConfiguration
import org.dhis2.form.data.metadata.FileResourceConfiguration
import org.dhis2.form.data.metadata.OptionSetConfiguration
import org.dhis2.form.data.metadata.OrgUnitConfiguration
Expand Down Expand Up @@ -90,8 +91,7 @@ class EnrollmentModule(
): EnrollmentRepository {
return EnrollmentRepository(
fieldFactory = modelFactory,
enrollmentUid = enrollmentUid,
d2 = d2,
conf = EnrollmentConfiguration(d2, enrollmentUid),
enrollmentMode = EnrollmentMode.valueOf(enrollmentMode.name),
enrollmentFormLabelsProvider = enrollmentFormLabelsProvider,
)
Expand Down
Loading
Loading