fix: stop orphaned GPS synchronization
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package pl.firmatpp.kierowca.data.upload
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class RoutePointWorkerRulesTest {
|
||||
@Test
|
||||
fun inactiveRouteConflictDiscardsObsoleteGpsPoints() {
|
||||
assertTrue(isInactiveRoutePointError("ROUTE_POINTS_INVALID_STATUS"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun temporaryServerFailureDoesNotDiscardGpsPoints() {
|
||||
assertFalse(isInactiveRoutePointError("SERVER_UNAVAILABLE"))
|
||||
assertFalse(isInactiveRoutePointError(null))
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package pl.firmatpp.kierowca.ui
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.io.IOException
|
||||
@@ -130,6 +131,44 @@ class DriverUiStateTest {
|
||||
assertEquals(listOf("above-first", "above-second", "span"), state.displayRoutes.map { it.id })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun freshGpsPointsDoNotShowSynchronizationBannerWhenOnlineIsHealthy() {
|
||||
val state = DriverUiState(
|
||||
isOnline = true,
|
||||
serverConnectionState = ServerConnectionState.Reachable,
|
||||
pendingGpsPoints = 48,
|
||||
oldestPendingGpsAtEpochMillis = System.currentTimeMillis() - 30_000L,
|
||||
)
|
||||
|
||||
assertEquals(0, state.pendingOperationalItems)
|
||||
assertFalse(state.operationalQueueNeedsAttention)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun staleGpsBacklogRequiresAttentionWhenOnline() {
|
||||
val state = DriverUiState(
|
||||
isOnline = true,
|
||||
serverConnectionState = ServerConnectionState.Reachable,
|
||||
pendingGpsPoints = 48,
|
||||
oldestPendingGpsAtEpochMillis = System.currentTimeMillis() - 3 * 60_000L,
|
||||
)
|
||||
|
||||
assertEquals(48, state.pendingOperationalItems)
|
||||
assertTrue(state.operationalQueueNeedsAttention)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun offlineGpsPointsAreShownAsSavedLocallyNotAsFailure() {
|
||||
val state = DriverUiState(
|
||||
isOnline = false,
|
||||
pendingGpsPoints = 48,
|
||||
oldestPendingGpsAtEpochMillis = System.currentTimeMillis() - 3 * 60_000L,
|
||||
)
|
||||
|
||||
assertEquals(48, state.pendingOperationalItems)
|
||||
assertFalse(state.operationalQueueNeedsAttention)
|
||||
}
|
||||
|
||||
private fun leaveRequest(id: String, status: String, version: Long = 1): DriverLeaveRequestDto =
|
||||
DriverLeaveRequestDto(
|
||||
id = id,
|
||||
|
||||
Reference in New Issue
Block a user