Keep a deleted override for undo as its VTODO, not an embedded task row (#79)

This commit is contained in:
makiolaj committed 2026-11-20 13:07:39 +01:00
1 parent 69edcb2b71
commit 8dcc48b0ba
7 files changed
+112 -210

No files matched your search

@@ -1,7 +1,10 @@
package de.jeanlucmakiola.agendula.data.tasks.room
import com.google.common.truth.Truth.assertThat
import de.jeanlucmakiola.agendula.domain.TaskEnd
import de.jeanlucmakiola.agendula.domain.TaskStatus
import org.junit.jupiter.api.Test
import kotlin.time.Instant
class AdvancedDeletedEntityTest {
@@ -24,4 +27,48 @@ class AdvancedDeletedEntityTest {
fun noAlarmsDecodeToNone() {
assertThat(AdvancedDeletedEntity.decodeAlarms(AdvancedDeletedEntity.encodeAlarms(emptyList()), taskId = 1)).isEmpty()
}
@Test
fun aDeletedOverrideReadsBackAsItStood() {
val at = Instant.parse("2026-11-20T09:00:00Z")
val row = TaskEntity(
id = 42,
listId = 3,
uid = "series-1",
href = "/x.ics",
etag = "\"e\"",
title = "Just this once, really",
description = "line one\nline two; with a comma, too",
location = "Room 4",
url = "https://example.org/?a=1&b=2",
color = 0xFF336699.toInt(),
categories = listOf("home", "errands"),
status = TaskStatus.IN_PROCESS,
percentComplete = 40,
priority = 3,
classification = 1,
dtstart = at,
due = Instant.parse("2026-11-20T22:59:59Z"),
untimed = TaskEnd.DUE,
timezone = "Europe/Berlin",
recurrenceId = at,
masterId = 7,
sortOrder = 5,
createdAt = Instant.parse("2026-11-01T08:00:00Z"),
lastModified = Instant.parse("2026-11-19T08:00:00Z"),
sequence = 2,
unknownProperties = "X-CUSTOM;X-PARAM=1:kept\r\n",
remindersOff = true,
)
val alarm = TaskAlarmEntity(taskId = 42, minutesBefore = 15, reference = AlarmReference.START)
val stored = AdvancedDeletedEntity.of(copyId = 9, anchor = at, row = row, alarms = listOf(alarm))
val back = checkNotNull(stored.read())
assertThat(back.entity.copy(listId = row.listId, id = row.id, href = row.href, etag = row.etag, masterId = row.masterId))
.isEqualTo(row)
assertThat(back.alarms).isEmpty()
assertThat(AdvancedDeletedEntity.decodeAlarms(stored.alarms, taskId = 1).map { it.minutesBefore to it.reference })
.containsExactly(15 to AlarmReference.START)
}
}