Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -203,7 +203,7 @@ internal class ObserveSyncInfoUseCase @Inject constructor(
)
)
val isSyncButtonEnabled =
(eventSyncVisibleState == OnStandby) &&
(eventSyncVisibleState == OnStandby || eventSyncVisibleState == Error) &&
((!isPreLogoutUpSync && isDownSyncPossible) || isEventUpSyncPossible)

val projectId = authStore.signedInProjectId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,20 @@ class ObserveSyncInfoUseCaseTest {
assertThat(result.syncInfoSectionRecords.isSyncButtonEnabled).isFalse()
}

@Test
fun `sync button should be enabled when sync has failed for non-CommCare and non-network reasons`() = runTest {
val mockCommCarePermissionErrorEventSyncState = mockk<EventSyncState>(relaxed = true) {
every { isSyncFailed() } returns true
every { isSyncFailedBecauseCommCarePermissionIsMissing() } returns false
}
every { eventSyncManager.getLastSyncState(any()) } returns MutableLiveData(mockCommCarePermissionErrorEventSyncState)

createUseCase()
val result = useCase().first()

assertThat(result.syncInfoSectionRecords.isSyncButtonEnabled).isTrue()
}

@Test
fun `should calculate correct record last sync time when sync time available`() = runTest {
val timestamp = Timestamp(0L)
Expand Down