From a2f02866c6e3df5691e263fd41f942e999ccfd77 Mon Sep 17 00:00:00 2001 From: andresmr Date: Tue, 18 Jun 2024 13:28:46 +0200 Subject: [PATCH] Add Mock response on old event when filtering by overdue Signed-off-by: andresmr --- .../dhis2/common/mockwebserver/MockWebServerRobot.kt | 2 ++ .../org/dhis2/usescases/searchte/SearchTETest.kt | 12 ++++++++++++ .../mocks/teilist/old_events_empty_response.json | 9 +++++++++ 3 files changed, 23 insertions(+) create mode 100644 app/src/dhisUITesting/assets/mocks/teilist/old_events_empty_response.json diff --git a/app/src/androidTest/java/org/dhis2/common/mockwebserver/MockWebServerRobot.kt b/app/src/androidTest/java/org/dhis2/common/mockwebserver/MockWebServerRobot.kt index eb2c53c7af..cd07f23e3d 100644 --- a/app/src/androidTest/java/org/dhis2/common/mockwebserver/MockWebServerRobot.kt +++ b/app/src/androidTest/java/org/dhis2/common/mockwebserver/MockWebServerRobot.kt @@ -20,6 +20,8 @@ class MockWebServerRobot(private val dhis2MockServer: Dhis2MockServer) { const val API_OLD_TRACKED_ENTITY_PATH = "/api/trackedEntityInstances/query?.*" const val API_OLD_TRACKED_ENTITY_RESPONSE = "mocks/teilist/old_tracked_entity_empty_response.json" + const val API_OLD_EVENTS_PATH = "/api/events?.*" + const val API_OLD_EVENTS_RESPONSE = "mocks/teilist/old_events_empty_response.json" } } 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 a0c055353b..99aebeb245 100644 --- a/app/src/androidTest/java/org/dhis2/usescases/searchte/SearchTETest.kt +++ b/app/src/androidTest/java/org/dhis2/usescases/searchte/SearchTETest.kt @@ -15,6 +15,8 @@ import dispatch.android.espresso.IdlingDispatcherProviderRule import org.dhis2.R import org.dhis2.bindings.app import org.dhis2.common.idlingresources.MapIdlingResource +import org.dhis2.common.mockwebserver.MockWebServerRobot.Companion.API_OLD_EVENTS_PATH +import org.dhis2.common.mockwebserver.MockWebServerRobot.Companion.API_OLD_EVENTS_RESPONSE import org.dhis2.common.mockwebserver.MockWebServerRobot.Companion.API_OLD_TRACKED_ENTITY_PATH import org.dhis2.common.mockwebserver.MockWebServerRobot.Companion.API_OLD_TRACKED_ENTITY_RESPONSE import org.dhis2.commons.date.DateUtils.SIMPLE_DATE_FORMAT @@ -202,6 +204,16 @@ class SearchTETest : BaseTest() { @Test fun shouldSuccessfullyFilterByEventStatusOverdue() { + mockWebServerRobot.addResponse( + ResponseController.GET, + API_OLD_TRACKED_ENTITY_PATH, + API_OLD_TRACKED_ENTITY_RESPONSE, + ) + mockWebServerRobot.addResponse( + ResponseController.GET, + API_OLD_EVENTS_PATH, + API_OLD_EVENTS_RESPONSE, + ) enableComposeForms() val eventStatusFilter = context.getString(R.string.filters_title_event_status) val totalCount = "1" diff --git a/app/src/dhisUITesting/assets/mocks/teilist/old_events_empty_response.json b/app/src/dhisUITesting/assets/mocks/teilist/old_events_empty_response.json new file mode 100644 index 0000000000..c03b0880c9 --- /dev/null +++ b/app/src/dhisUITesting/assets/mocks/teilist/old_events_empty_response.json @@ -0,0 +1,9 @@ +{ + "pager": { + "page": 1, + "pageCount": 1, + "total": 2, + "pageSize": 50 + }, + "events": [] +} \ No newline at end of file