Respect the Upcoming range for default due dates (#107, #128)

This commit is contained in:
makiolaj committed 2026-11-18 20:58:12 +01:00
1 parent 9b178fc80b
commit dd1a801560
8 files changed
+67 -15

No files matched your search

@@ -35,5 +35,18 @@ class SettingsVisibilityTest {
val upcoming = limited.visibleIn(TaskFilter.Smart(SmartList.UPCOMING), listOf(near, far), now, zone)
assertThat(upcoming.map { it.taskId }).containsExactly(1L)
assertThat(limited.visibleIn(TaskFilter.Smart(SmartList.ALL), listOf(near, far), now, zone)).hasSize(2)
assertThat(limited.viewOf(TaskFilter.Smart(SmartList.UPCOMING), listOf(near, far), now, zone).hiddenByRange).isTrue()
assertThat(limited.viewOf(TaskFilter.Smart(SmartList.UPCOMING), listOf(near), now, zone).hiddenByRange).isFalse()
}
@Test
fun `a hidden list is not counted as kept out by the range`() {
val zone = ZoneId.of("UTC")
val now = Instant.fromEpochMilliseconds(1000 * 86_400_000L)
val hiddenFar = testTask(id = 2, listId = 2, due = Instant.fromEpochMilliseconds(1100 * 86_400_000L))
val limited = settings.copy(upcomingRange = UpcomingRange.WEEK)
val view = limited.viewOf(TaskFilter.Smart(SmartList.UPCOMING), listOf(hiddenFar), now, zone)
assertThat(view.tasks).isEmpty()
assertThat(view.hiddenByRange).isFalse()
}
}
@@ -57,6 +57,21 @@ class NewTaskDefaultsTest {
}
}
@Test
fun `a default due past a limited Upcoming gives way to the preset (#128)`() {
val (start, end) = DayWindow.today(now, zone)
val upcomingEnd = UpcomingRange.WEEK.end(now, zone)
val preset = SmartList.UPCOMING.dueWindows.presetDue(localToday)
val dates = newTaskDates(DefaultDueDate.NEXT_MONTH, DefaultStartDate.NONE, preset, localToday, now) {
it.showsIn(SmartList.UPCOMING, null, start, end, upcomingEnd)
}
assertThat(dates.due).isEqualTo(allDayInstantOf(localToday.plusDays(1)))
val unlimited = newTaskDates(DefaultDueDate.NEXT_MONTH, DefaultStartDate.NONE, preset, localToday, now) {
it.showsIn(SmartList.UPCOMING, null, start, end)
}
assertThat(unlimited.due).isEqualTo(allDayInstantOf(localToday.plusMonths(1)))
}
@Test
fun `the default due applies where the view still shows the task, else its preset`() {
val (start, end) = DayWindow.today(now, zone)