Skip to content

Commit

Permalink
Map search bug fixes (#3516)
Browse files Browse the repository at this point in the history
* - Updating the infinite scroll paging
- Updating the behaviour after clearing search bar on the maps

* - spotless apply

* - Fix breaking tests on geo widget module

* - Fix tests

* - Run spotless

* - Import `LazyPagingItems`

* - Adding tests

* - Update the APK naming

* Ignore test to be refactored later

Signed-off-by: Elly Kitoto <[email protected]>

* - Run spotless

* Update kujaku version.

Signed-off-by: Lentumunai-Mark <[email protected]>

---------

Signed-off-by: Elly Kitoto <[email protected]>
Signed-off-by: Lentumunai-Mark <[email protected]>
Co-authored-by: Lentumunai Mark <[email protected]>
Co-authored-by: Elly Kitoto <[email protected]>
Co-authored-by: Lentumunai-Mark <[email protected]>
  • Loading branch information
4 people authored Oct 14, 2024
1 parent 6014982 commit 156451c
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1070,14 +1070,20 @@ constructor(
if (currentPage != null && pageSize != null) {
val fromIndex = currentPage * pageSize
val toIndex = (currentPage + 1) * pageSize
with(searchResults.subList(fromIndex, min(toIndex, searchResults.size))) {
mapResourceToRepositoryResourceData(
relatedResourcesConfig = relatedResourcesConfig,
configComputedRuleValues = configComputedRuleValues,
secondaryResourceConfigs = secondaryResourceConfigs,
filterActiveResources = filterActiveResources,
baseResourceConfig = baseResourceConfig,
)
val maxSublistIndex = min(toIndex, searchResults.size)

if (fromIndex < maxSublistIndex) {
with(searchResults.subList(fromIndex, maxSublistIndex)) {
mapResourceToRepositoryResourceData(
relatedResourcesConfig = relatedResourcesConfig,
configComputedRuleValues = configComputedRuleValues,
secondaryResourceConfigs = secondaryResourceConfigs,
filterActiveResources = filterActiveResources,
baseResourceConfig = baseResourceConfig,
)
}
} else {
emptyList()
}
} else {
searchResults.mapResourceToRepositoryResourceData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,50 @@ class RegisterRepositoryTest : RobolectricTest() {
}
}

@Ignore("Refactor this test")
@Test
fun countRegisterDataWithParamsAndRelatedEntityLocationFilter() {
runTest {
val paramsList =
arrayListOf(
ActionParameter(
key = "paramsName",
paramType = ActionParameterType.PARAMDATA,
value = "testing1",
dataType = DataType.STRING,
linkId = null,
),
ActionParameter(
key = "paramName2",
paramType = ActionParameterType.PARAMDATA,
value = "testing2",
dataType = DataType.STRING,
linkId = null,
),
)
paramsList
.asSequence()
.filter { it.paramType == ActionParameterType.PARAMDATA && it.value.isNotEmpty() }
.associate { it.key to it.value }
val paramsMap = emptyMap<String, String>()
val searchSlot = slot<Search>()
every {
registerRepository.retrieveRegisterConfiguration(PATIENT_REGISTER, emptyMap())
} returns
RegisterConfiguration(
appId = "app",
id = PATIENT_REGISTER,
fhirResource = fhirResourceConfig(),
filterDataByRelatedEntityLocation = true,
)
coEvery { fhirEngine.count(capture(searchSlot)) } returns 20
val recordsCount =
registerRepository.countRegisterData(registerId = PATIENT_REGISTER, paramsMap = paramsMap)
Assert.assertEquals(ResourceType.Group, searchSlot.captured.type)
Assert.assertEquals(20, recordsCount)
}
}

@Test
fun testLoadRegisterDataWithForwardAndReverseIncludedResources() =
runTest(timeout = 90.seconds) {
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ kotlinx-coroutines = "1.9.0"
kotlinx-serialization-json = "1.6.0"
kt3k-coveralls-ver="2.12.0"
ktlint = "0.50.0"
kujaku-library = "0.10.6-2-SNAPSHOT"
kujaku-library = "0.10.7-SNAPSHOT"
kujaku-mapbox-sdk-turf = "7.2.0"
leakcanary-android = "2.10"
lifecycle= "2.8.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,7 @@ fun TopScreenSection(
when {
!searchQuery.isBlank() -> {
IconButton(
onClick = {
onSearchTextChanged(SearchQuery.emptyText, performSearchOnValueChanged)
},
onClick = { onSearchTextChanged(SearchQuery.emptyText, true) },
modifier = modifier.testTag(TRAILING_ICON_BUTTON_TEST_TAG),
) {
Icon(
Expand Down

0 comments on commit 156451c

Please sign in to comment.