mirror of
https://github.com/bleackstorm/satiea.git
synced 2026-12-03 07:41:56 +01:00
feat: support meal photo URIs and improve UI events
- Add `photoUris` field to `MealEntry` and update Firestore rules. - Implement `UiEvent` handling in `MainActivity` for navigation/links. - Remove sensitive email data from error logs and clean up manifest.
This commit is contained in:
1 parent
f0487453c9
commit
87bbb448c2
34 files changed
+2026
-1170
No files matched your search
@@ -8,32 +8,35 @@ import com.example.util.GoogleSheetsDataFormatter
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.util.Calendar
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
|
||||
class GoogleSheetsDataFormatterTest {
|
||||
|
||||
private val testZoneId = ZoneId.of("Europe/Paris")
|
||||
|
||||
@Test
|
||||
fun `formatMealsToRows with empty list returns only header row`() {
|
||||
val rows = GoogleSheetsDataFormatter.formatMealsToRows(emptyList())
|
||||
val rows = GoogleSheetsDataFormatter.formatMealsToRows(emptyList(), testZoneId)
|
||||
assertEquals(1, rows.size)
|
||||
assertEquals(GoogleSheetsDataFormatter.HEADERS, rows[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `formatMealsToRows formats meal fields accurately and sorts chronologically descending`() {
|
||||
val cal1 = Calendar.getInstance().apply {
|
||||
set(2026, Calendar.MARCH, 15, 12, 30, 0)
|
||||
set(Calendar.MILLISECOND, 0)
|
||||
}
|
||||
val cal2 = Calendar.getInstance().apply {
|
||||
set(2026, Calendar.MARCH, 15, 20, 0, 0)
|
||||
set(Calendar.MILLISECOND, 0)
|
||||
}
|
||||
val time1 = LocalDateTime.of(2026, 3, 15, 12, 30, 0)
|
||||
.atZone(testZoneId)
|
||||
.toInstant()
|
||||
.toEpochMilli()
|
||||
val time2 = LocalDateTime.of(2026, 3, 15, 20, 0, 0)
|
||||
.atZone(testZoneId)
|
||||
.toInstant()
|
||||
.toEpochMilli()
|
||||
|
||||
val meal1 = MealEntry(
|
||||
id = "meal-1",
|
||||
mealType = MealType.LUNCH.name,
|
||||
mealTimestamp = cal1.timeInMillis,
|
||||
mealTimestamp = time1,
|
||||
hungerBefore = 3,
|
||||
satietyAfter = 7,
|
||||
note = "Repas calme et savoureux",
|
||||
@@ -41,24 +44,24 @@ class GoogleSheetsDataFormatterTest {
|
||||
MealFoodItem("Riz complet", 150.0, FoodUnit.G).serialize(),
|
||||
MealFoodItem("Saumon", 120.0, FoodUnit.G).serialize()
|
||||
),
|
||||
photosBase64 = listOf("photo1")
|
||||
photoUris = listOf("file:///photo1.jpg")
|
||||
)
|
||||
|
||||
val meal2 = MealEntry(
|
||||
id = "meal-2",
|
||||
mealType = MealType.DINNER.name,
|
||||
mealTimestamp = cal2.timeInMillis,
|
||||
mealTimestamp = time2,
|
||||
hungerBefore = 4,
|
||||
satietyAfter = 8,
|
||||
note = "Dîner léger en famille",
|
||||
foodItemsSerialized = listOf(
|
||||
MealFoodItem("Soupe de légumes", 250.0, FoodUnit.ML).serialize()
|
||||
),
|
||||
photosBase64 = emptyList()
|
||||
photoUris = emptyList()
|
||||
)
|
||||
|
||||
// Pass in reverse order to test sorting
|
||||
val rows = GoogleSheetsDataFormatter.formatMealsToRows(listOf(meal1, meal2))
|
||||
val rows = GoogleSheetsDataFormatter.formatMealsToRows(listOf(meal1, meal2), testZoneId)
|
||||
|
||||
// 1 header + 2 data rows
|
||||
assertEquals(3, rows.size)
|
||||
|
||||
Reference in new issue
Block a user