Napraw synchronizację kursu w aplikacji kierowcy
This commit is contained in:
@@ -205,8 +205,9 @@ class DriverUiRulesTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun allowsRetryActionOnlyForRetryableFailedUploads() {
|
||||
fun allowsRetryForRetryableAndLegacyCancelledUploads() {
|
||||
assertTrue(canRetryPhotoUpload("FAILED_RETRYABLE"))
|
||||
assertTrue(canRetryPhotoUpload("FAILED_PERMANENT", "Typ: błąd aplikacji\nKomunikat: Job was cancelled"))
|
||||
assertFalse(canRetryPhotoUpload("PENDING"))
|
||||
assertFalse(canRetryPhotoUpload("UPLOADING"))
|
||||
assertFalse(canRetryPhotoUpload("VERIFYING"))
|
||||
@@ -215,6 +216,37 @@ class DriverUiRulesTest {
|
||||
assertFalse(canRetryPhotoUpload("CANCELLED"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun permanentUploadDoesNotSatisfyRouteStageAndCanBeDiscarded() {
|
||||
val failed = upload(status = "FAILED_PERMANENT")
|
||||
val pending = upload(status = "PENDING").copy(clientRequestId = "pending-upload")
|
||||
|
||||
assertEquals(listOf("pending-upload"), routeStageUsableUploads(listOf(failed, pending)).map { it.clientRequestId })
|
||||
assertFalse(photoUploadCanSatisfyStage("FAILED_PERMANENT"))
|
||||
assertTrue(canDiscardLocalPhotoUpload("FAILED_PERMANENT", null))
|
||||
assertFalse(canDiscardLocalPhotoUpload("CONFIRMED", "42"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun serverRefreshLeavesObsoleteRouteStageScreen() {
|
||||
assertEquals(
|
||||
DriverScreen.Detail,
|
||||
routeScreenAfterServerRefresh(DriverScreen.StartRoute, route(status = "W TRAKCIE")),
|
||||
)
|
||||
assertEquals(
|
||||
DriverScreen.Detail,
|
||||
routeScreenAfterServerRefresh(DriverScreen.LoadingWeight, route(status = "ZAKOŃCZONA")),
|
||||
)
|
||||
assertEquals(
|
||||
DriverScreen.Detail,
|
||||
routeScreenAfterServerRefresh(DriverScreen.FinishRoute, route(status = "ZAKOŃCZONA")),
|
||||
)
|
||||
assertEquals(
|
||||
DriverScreen.StartRoute,
|
||||
routeScreenAfterServerRefresh(DriverScreen.StartRoute, route(status = "ZAPLANOWANA")),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun showsFailureDetailsOnlyForFailedUploadsWithErrorMessage() {
|
||||
assertTrue(canShowPhotoUploadFailureDetails("FAILED_RETRYABLE", "Typ: błąd serwera"))
|
||||
@@ -365,18 +397,62 @@ class DriverUiRulesTest {
|
||||
assertEquals(RouteLifecycleAction.Start, action?.action)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun driverFlowIgnoresOperationalStatusFromGeofence() {
|
||||
val route = route(
|
||||
status = "ZAKOŃCZONA",
|
||||
driverStatus = "ZAPLANOWANA",
|
||||
operationalStatus = "ZAKOŃCZONA",
|
||||
)
|
||||
|
||||
val steps = routeFlowSteps(route, emptyList())
|
||||
|
||||
assertTrue(canStartRouteFromDriverApp(route, "2026-06-30", today))
|
||||
assertEquals(RouteFlowStepState.Todo, steps[0].state)
|
||||
assertEquals(RouteFlowStepState.Todo, steps[1].state)
|
||||
assertEquals(RouteFlowStepState.Todo, steps[2].state)
|
||||
assertEquals(DriverScreen.StartRoute, routeScreenAfterServerRefresh(DriverScreen.StartRoute, route))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun plannedRouteWithLoadingPhotoShowsOnlyPhotoStepComplete() {
|
||||
val route = route(status = "ZAPLANOWANA", photos = listOf(photo("loading-1", stage = "loading")))
|
||||
|
||||
val steps = routeFlowSteps(route, emptyList())
|
||||
|
||||
assertEquals(RouteFlowStepState.LocalComplete, steps[0].state)
|
||||
assertEquals(RouteFlowStepState.ServerSaved, steps[0].state)
|
||||
assertEquals("zapisane na serwerze", steps[0].stateLabel)
|
||||
assertEquals(RouteFlowStepState.Todo, steps[1].state)
|
||||
assertEquals(RouteFlowStepState.Todo, steps[2].state)
|
||||
assertEquals(RouteFlowStepState.Todo, steps[3].state)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun freshInstallLabelsBackendLoadingDocumentationAsServerData() {
|
||||
val route = route(
|
||||
status = "ZAPLANOWANA",
|
||||
loadingWeight = 23.76,
|
||||
photos = listOf(photo("loading-1", stage = "loading")),
|
||||
)
|
||||
|
||||
val steps = routeFlowSteps(route, emptyList())
|
||||
|
||||
assertEquals(RouteFlowStepState.ServerSaved, steps[0].state)
|
||||
assertEquals("zapisane na serwerze", steps[0].stateLabel)
|
||||
assertEquals(RouteFlowStepState.ServerSaved, steps[1].state)
|
||||
assertEquals("zapisane na serwerze", steps[1].stateLabel)
|
||||
assertEquals(RouteFlowStepState.Todo, steps[2].state)
|
||||
assertEquals(RouteFlowStepState.Todo, steps[3].state)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun serverWeightDoesNotMarkMissingLoadingPhotoAsComplete() {
|
||||
val steps = routeFlowSteps(route(status = "ZAPLANOWANA", loadingWeight = 23.76), emptyList())
|
||||
|
||||
assertEquals(RouteFlowStepState.Todo, steps[0].state)
|
||||
assertEquals(RouteFlowStepState.ServerSaved, steps[1].state)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun activeRouteShowsTransitStateAndFinishAction() {
|
||||
val route = route(status = "W TRAKCIE", loadingWeight = 12.5)
|
||||
@@ -386,7 +462,8 @@ class DriverUiRulesTest {
|
||||
|
||||
assertEquals(RouteFlowStepState.Confirmed, steps[0].state)
|
||||
assertEquals(RouteFlowStepState.Confirmed, steps[1].state)
|
||||
assertEquals(RouteFlowStepState.LocalComplete, steps[2].state)
|
||||
assertEquals(RouteFlowStepState.InProgress, steps[2].state)
|
||||
assertEquals("w trakcie", steps[2].stateLabel)
|
||||
assertEquals(RouteFlowStepState.Todo, steps[3].state)
|
||||
assertEquals("Rozładuj", action?.label)
|
||||
assertEquals(RouteLifecycleAction.Finish, action?.action)
|
||||
@@ -527,6 +604,8 @@ class DriverUiRulesTest {
|
||||
|
||||
private fun route(
|
||||
status: String = "ZAPLANOWANA",
|
||||
driverStatus: String? = null,
|
||||
operationalStatus: String? = null,
|
||||
loadingWeight: Double? = null,
|
||||
unloadingWeight: Double? = null,
|
||||
photos: List<RoutePhotoDto> = emptyList(),
|
||||
@@ -545,6 +624,8 @@ class DriverUiRulesTest {
|
||||
contractCode = "TPP-1",
|
||||
relationLabel = "Baza -> Instalacja",
|
||||
status = status,
|
||||
driverStatus = driverStatus,
|
||||
operationalStatus = operationalStatus,
|
||||
loadingWeight = loadingWeight,
|
||||
unloadingWeight = unloadingWeight,
|
||||
distanceKm = 1.0,
|
||||
|
||||
Reference in New Issue
Block a user