Fix third review round of repeat from completion (#79)

This commit is contained in:
makiolaj committed 2026-11-17 11:31:20 +01:00
1 parent d59d4a3d44
commit ce39c6aec0
10 files changed
+214 -107

No files matched your search

@@ -68,7 +68,7 @@ class TaskFormWriterSeriesTest {
fun `dropping the rule ends the series and its exceptions`() {
val withExceptions = master.copy(exdate = "20260905T090000Z")
val plain = TaskFormWriter.withRule(withExceptions, null)
val plain = TaskFormWriter.withRule(withExceptions, null, fromCompletion = false)
assertThat(plain.rrule).isNull()
assertThat(plain.exdate).isNull()
@@ -78,7 +78,7 @@ class TaskFormWriterSeriesTest {
fun `an override never takes a rule`() {
val override = master.copy(id = 9, masterId = 7, rrule = null)
assertThat(TaskFormWriter.withRule(override, "FREQ=DAILY").rrule).isNull()
assertThat(TaskFormWriter.withRule(override, "FREQ=DAILY", fromCompletion = false).rrule).isNull()
}
@Test
@@ -78,6 +78,29 @@ class RepeatFromCompletionTest {
assertThat(next(spec, "2026-03-10T12:00:00Z")).isEqualTo("2026-03-12T00:00:00Z")
}
@Test
fun `a month on from the 31st is the last day of a short month`() {
val spec = allDay("FREQ=MONTHLY", "2026-01-05T00:00:00Z")
assertThat(next(spec, "2026-01-31T12:00:00Z")).isEqualTo("2026-02-28T00:00:00Z")
}
@Test
fun `weekdays every other week wait out all but the last week`() {
val spec = allDay("FREQ=WEEKLY;INTERVAL=2;BYDAY=FR", "2026-03-06T00:00:00Z")
// Done Wednesday 11 March: a week on is the 18th, and the Friday after it the 20th.
assertThat(next(spec, "2026-03-11T12:00:00Z")).isEqualTo("2026-03-20T00:00:00Z")
}
@Test
fun `an occurrence is on a schedule only where it generates one`() {
val spec = allDay("FREQ=WEEKLY", "2026-03-02T00:00:00Z")
assertThat(RepeatFromCompletion.onSchedule(spec, at("2026-03-16T00:00:00Z"), berlin)).isTrue()
assertThat(RepeatFromCompletion.onSchedule(spec, at("2026-03-17T00:00:00Z"), berlin)).isFalse()
}
@Test
fun `COUNT is left to the caller`() {
val spec = allDay("FREQ=DAILY;COUNT=1", "2026-03-02T00:00:00Z")
@@ -176,7 +176,7 @@ class TaskEditViewModelTest {
vm.onRecurrenceChange(null)
vm.onRecurrenceChange("FREQ=WEEKLY")
assertThat(vm.state.value.repeatsFromCompletion).isFalse()
assertThat(vm.state.value.savesFromCompletion).isFalse()
}
@Test
@@ -186,7 +186,7 @@ class TaskEditViewModelTest {
vm.onRepeatFromCompletionChange(true)
assertThat(vm.state.value.repeatFromOffered).isFalse()
assertThat(vm.state.value.repeatsFromCompletion).isFalse()
assertThat(vm.state.value.savesFromCompletion).isFalse()
repository.task = task(null, due).copy(isRecurring = true, recurrenceRule = "FREQ=DAILY", parentId = 3)
val sub = TaskEditViewModel(repository, settingsPrefs()).apply { bindEdit(TASK_ID) }