feat: add dispatch sheet reminder to driver app
This commit is contained in:
+65
@@ -0,0 +1,65 @@
|
||||
package pl.firmatpp.kierowca.data.upload
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import pl.firmatpp.kierowca.data.model.DispatchSheetUploadReceiptDto
|
||||
|
||||
class DispatchSheetUploadReceiptVerifierTest {
|
||||
private val upload = DispatchSheetUploadEntity(
|
||||
clientRequestId = "6f7a7d10-b7f7-41ab-8f5e-f1afc3e93736",
|
||||
workDate = "2026-07-03",
|
||||
replacePhotoId = "12",
|
||||
localPath = "/tmp/dispatch-sheet.jpg",
|
||||
source = "camera",
|
||||
takenAt = null,
|
||||
latitude = null,
|
||||
longitude = null,
|
||||
locationAccuracyMeters = null,
|
||||
mimeType = "image/jpeg",
|
||||
size = 1200,
|
||||
contentSha256 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
)
|
||||
|
||||
@Test
|
||||
fun confirmsOnlyMatchingReceipt() {
|
||||
assertTrue(
|
||||
DispatchSheetUploadReceiptVerifier.matches(
|
||||
upload,
|
||||
DispatchSheetUploadReceiptDto(
|
||||
clientRequestId = upload.clientRequestId,
|
||||
serverPhotoId = "55",
|
||||
contentSha256 = upload.contentSha256.uppercase(),
|
||||
storedAt = "2026-07-03T17:02:00+02:00",
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rejectsDifferentRequestOrHash() {
|
||||
assertFalse(
|
||||
DispatchSheetUploadReceiptVerifier.matches(
|
||||
upload,
|
||||
DispatchSheetUploadReceiptDto(
|
||||
clientRequestId = "other",
|
||||
serverPhotoId = "55",
|
||||
contentSha256 = upload.contentSha256,
|
||||
storedAt = null,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
assertFalse(
|
||||
DispatchSheetUploadReceiptVerifier.matches(
|
||||
upload,
|
||||
DispatchSheetUploadReceiptDto(
|
||||
clientRequestId = upload.clientRequestId,
|
||||
serverPhotoId = "55",
|
||||
contentSha256 = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
storedAt = null,
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import pl.firmatpp.kierowca.data.model.DriverRouteDto
|
||||
import pl.firmatpp.kierowca.data.model.DispatchSheetReminderDto
|
||||
import pl.firmatpp.kierowca.data.upload.PhotoUploadEntity
|
||||
|
||||
class DriverUiRulesTest {
|
||||
@@ -190,6 +191,21 @@ class DriverUiRulesTest {
|
||||
assertFalse(canLaunchCameraWithLocationPolicy(requirePreciseLocation = true, hasFineLocation = false))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun showsDispatchSheetCardOnlyWhenReminderIsDueToday() {
|
||||
assertTrue(shouldShowDispatchSheetReminderCard(dispatchReminder(status = "missing", dueToday = true)))
|
||||
assertTrue(shouldShowDispatchSheetReminderCard(dispatchReminder(status = "uploaded", dueToday = true)))
|
||||
assertFalse(shouldShowDispatchSheetReminderCard(dispatchReminder(status = "not_required", dueToday = false)))
|
||||
assertFalse(shouldShowDispatchSheetReminderCard(null))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun labelsDispatchSheetActionByStatusAndLocalUploadQueue() {
|
||||
assertEquals("Zrób zdjęcie", dispatchSheetPrimaryActionLabel(dispatchReminder(status = "missing"), hasQueuedUpload = false))
|
||||
assertEquals("Wysyłam zdjęcie...", dispatchSheetPrimaryActionLabel(dispatchReminder(status = "missing"), hasQueuedUpload = true))
|
||||
assertEquals("Popraw", dispatchSheetPrimaryActionLabel(dispatchReminder(status = "uploaded"), hasQueuedUpload = false))
|
||||
}
|
||||
|
||||
private fun route(status: String): DriverRouteDto =
|
||||
DriverRouteDto(
|
||||
id = "1",
|
||||
@@ -222,4 +238,16 @@ class DriverUiRulesTest {
|
||||
status = status,
|
||||
serverPhotoId = serverPhotoId,
|
||||
)
|
||||
|
||||
private fun dispatchReminder(status: String, dueToday: Boolean = true): DispatchSheetReminderDto =
|
||||
DispatchSheetReminderDto(
|
||||
enabled = dueToday,
|
||||
dueToday = dueToday,
|
||||
workDate = "2026-06-30",
|
||||
reason = if (dueToday) "friday" else null,
|
||||
availableUntil = "2026-06-30T23:59:59+02:00",
|
||||
status = status,
|
||||
photo = null,
|
||||
canUpload = dueToday,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user