feat: display formatted hour duration as a prefix in maintenance activity descriptions and add supporting tests
This commit is contained in:
@@ -39,6 +39,11 @@ data class MaintenanceActivity(
|
|||||||
else -> ActivityStatus.EM_ANDAMENTO
|
else -> ActivityStatus.EM_ANDAMENTO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val formattedHoras: String
|
||||||
|
get() = if (quantidadeHoras <= 0) "0h"
|
||||||
|
else if (quantidadeHoras % 1.0 == 0.0) "${quantidadeHoras.toInt()}h"
|
||||||
|
else "${quantidadeHoras}h"
|
||||||
|
|
||||||
@delegate:Transient
|
@delegate:Transient
|
||||||
val dataInicioMillis: Long by lazy {
|
val dataInicioMillis: Long by lazy {
|
||||||
(parseFullDateTime(dataInicio) ?: parseDateOnly(dataInicio))?.time ?: 0L
|
(parseFullDateTime(dataInicio) ?: parseDateOnly(dataInicio))?.time ?: 0L
|
||||||
|
|||||||
@@ -985,8 +985,14 @@ fun OSListItemCard(
|
|||||||
Spacer(modifier = Modifier.height(6.dp))
|
Spacer(modifier = Modifier.height(6.dp))
|
||||||
|
|
||||||
// Title Description
|
// Title Description
|
||||||
|
val displayDesc = if (activity.quantidadeHoras > 0) {
|
||||||
|
"${activity.formattedHoras} - ${activity.descricao}"
|
||||||
|
} else {
|
||||||
|
activity.descricao
|
||||||
|
}
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = activity.descricao,
|
text = displayDesc,
|
||||||
fontSize = 13.sp,
|
fontSize = 13.sp,
|
||||||
fontWeight = FontWeight.Medium,
|
fontWeight = FontWeight.Medium,
|
||||||
color = BrandBlack,
|
color = BrandBlack,
|
||||||
|
|||||||
@@ -499,8 +499,37 @@ class ExampleUnitTest {
|
|||||||
val resultNotFound = filterByTag("TAG-INEXISTENTE")
|
val resultNotFound = filterByTag("TAG-INEXISTENTE")
|
||||||
assertEquals(0, resultNotFound.size)
|
assertEquals(0, resultNotFound.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testFormattedHorasAndDescriptionPrefix() {
|
||||||
|
val act8h = com.example.data.model.MaintenanceActivity(
|
||||||
|
numeroOs = "OS-1", descricao = "PARADA ANUAL 2026", setor = "Geral", equipe = "Mecânica", recurso = "Sem Recurso",
|
||||||
|
dataInicio = "18/08/2026", dataFim = "22/08/2026", percentualExecucao = 0, quantidadeHoras = 8.0
|
||||||
|
)
|
||||||
|
val actDecimal = com.example.data.model.MaintenanceActivity(
|
||||||
|
numeroOs = "OS-2", descricao = "SOLDA EIXO", setor = "Geral", equipe = "Mecânica", recurso = "Sem Recurso",
|
||||||
|
dataInicio = "18/08/2026", dataFim = "22/08/2026", percentualExecucao = 0, quantidadeHoras = 12.5
|
||||||
|
)
|
||||||
|
val actZero = com.example.data.model.MaintenanceActivity(
|
||||||
|
numeroOs = "OS-3", descricao = "INSPEÇÃO", setor = "Geral", equipe = "Mecânica", recurso = "Sem Recurso",
|
||||||
|
dataInicio = "18/08/2026", dataFim = "22/08/2026", percentualExecucao = 0, quantidadeHoras = 0.0
|
||||||
|
)
|
||||||
|
|
||||||
|
assertEquals("8h", act8h.formattedHoras)
|
||||||
|
assertEquals("12.5h", actDecimal.formattedHoras)
|
||||||
|
assertEquals("0h", actZero.formattedHoras)
|
||||||
|
|
||||||
|
val getDisplayDesc = { activity: com.example.data.model.MaintenanceActivity ->
|
||||||
|
if (activity.quantidadeHoras > 0) "${activity.formattedHoras} - ${activity.descricao}" else activity.descricao
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals("8h - PARADA ANUAL 2026", getDisplayDesc(act8h))
|
||||||
|
assertEquals("12.5h - SOLDA EIXO", getDisplayDesc(actDecimal))
|
||||||
|
assertEquals("INSPEÇÃO", getDisplayDesc(actZero))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user