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

Resolve Sync progress going above 100% #3684

Merged
merged 13 commits into from
Jan 30, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onAllNodesWithTag
import androidx.compose.ui.test.onChildAt
Expand Down Expand Up @@ -681,4 +682,66 @@ class RegisterScreenTest {
.assertExists()
.assertIsDisplayed()
}

@Test
fun testSyncStatusPercentageProgressLimitIs100() {
val configurationRegistry: ConfigurationRegistry = Faker.buildTestConfigurationRegistry()
val registerUiState =
RegisterUiState(
screenTitle = "Register101",
isFirstTimeSync = true,
registerConfiguration =
configurationRegistry.retrieveConfiguration(ConfigType.Register, "householdRegister"),
registerId = "register101",
progressPercentage = flowOf(101),
isSyncUpload = flowOf(false),
currentSyncJobStatus =
flowOf(
CurrentSyncJobStatus.Running(
SyncJobStatus.InProgress(
syncOperation = SyncOperation.DOWNLOAD,
),
),
),
params = emptyList(),
)
val searchText = mutableStateOf(SearchQuery.emptyText)
val currentPage = mutableStateOf(0)

composeTestRule.setContent {
val data = listOf(ResourceData("1", ResourceType.Patient, emptyMap()))
val pagingItems = flowOf(PagingData.from(data)).collectAsLazyPagingItems()
RegisterScreen(
modifier = Modifier,
openDrawer = {},
onEvent = {},
registerUiState = registerUiState,
registerUiCountState =
RegisterUiCountState(
totalRecordsCount = 1,
filteredRecordsCount = 0,
pagesCount = 0,
),
appDrawerUIState =
AppDrawerUIState(
currentSyncJobStatus =
CurrentSyncJobStatus.Running(
SyncJobStatus.InProgress(
syncOperation = SyncOperation.UPLOAD,
),
),
),
onAppMainEvent = {},
searchQuery = searchText,
currentPage = currentPage,
pagingItems = pagingItems,
navController = rememberNavController(),
decodeImage = null,
)
}

composeTestRule
.onNodeWithTag(SYNC_PROGRESS_INDICATOR_TEST_TAG, useUnmergedTree = true)
.assertIsNotDisplayed()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@
contentAlignment = Alignment.Center,
) {
val context = LocalContext.current
when (currentSyncJobStatus) {
is CurrentSyncJobStatus.Running -> {
when {

Check warning on line 173 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/shared/components/SyncStatusView.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/shared/components/SyncStatusView.kt#L173

Added line #L173 was not covered by tests
currentSyncJobStatus is CurrentSyncJobStatus.Running &&
appDrawerUIState.percentageProgress!! <= 100 -> {
Lentumunai-Mark marked this conversation as resolved.
Show resolved Hide resolved
SyncStatusView(
isSyncUpload = appDrawerUIState.isSyncUpload,
currentSyncJobStatus = currentSyncJobStatus,
Expand All @@ -181,7 +182,7 @@
)
SideEffect { hideSyncCompleteStatus.value = false }
}
is CurrentSyncJobStatus.Failed -> {
currentSyncJobStatus is CurrentSyncJobStatus.Failed -> {
SyncStatusView(
isSyncUpload = appDrawerUIState.isSyncUpload,
currentSyncJobStatus = currentSyncJobStatus,
Expand All @@ -192,7 +193,7 @@
},
)
}
is CurrentSyncJobStatus.Succeeded -> {
currentSyncJobStatus is CurrentSyncJobStatus.Succeeded -> {
if (!hideSyncCompleteStatus.value) {
SyncStatusView(
isSyncUpload = appDrawerUIState.isSyncUpload,
Expand Down
Loading