diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-07-13 18:17:25 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-07-16 02:42:31 +0000 |
| commit | 5264453baab2b5810a98a49040cf18d771e13f23 (patch) | |
| tree | d12d98da2f9871c28a05cad49b9854afcf9557f8 /internal/handlers/timeline_multiday_test.go | |
| parent | 08ded9fc1114c86b7a748c589aa2b6e8d8202c1c (diff) | |
fix(web): account for Google Calendar's exclusive all-day end-date
A single-day all-day event's End.Date is one calendar day past its own
day (Google Calendar convention, already documented by
TestParseEventTime_AllDayEvent). isMultiDayEvent/multiDayVariant didn't
adjust for this, so every all-day event -- including single-day ones --
was misclassified as multi-day and duplicated across Today and
Tomorrow.
Diffstat (limited to 'internal/handlers/timeline_multiday_test.go')
| -rw-r--r-- | internal/handlers/timeline_multiday_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/internal/handlers/timeline_multiday_test.go b/internal/handlers/timeline_multiday_test.go index 3dc2005..7af2cbe 100644 --- a/internal/handlers/timeline_multiday_test.go +++ b/internal/handlers/timeline_multiday_test.go @@ -81,3 +81,49 @@ func TestMultiDayVariant_DayOutsideSpan_ReturnsEmpty(t *testing.T) { t.Errorf("variant = %q, want empty", got) } } + +func TestIsMultiDayEvent_SingleDayAllDayEvent_False(t *testing.T) { + // Exclusive end-date convention: a single-day all-day event on July 13 + // has Start=Jul13 00:00, End=Jul14 00:00 (one day past its own day). + start, _ := time.Parse(time.RFC3339, "2026-07-13T00:00:00Z") + end, _ := time.Parse(time.RFC3339, "2026-07-14T00:00:00Z") + item := models.TimelineItem{ + ID: "allday-1", Type: models.TimelineItemTypeEvent, + Time: start, EndTime: &end, IsAllDay: true, + } + if isMultiDayEvent(item) { + t.Error("expected a single-day all-day event (exclusive end-date) to not be multi-day") + } +} + +func TestIsMultiDayEvent_MultiDayAllDayEvent_True(t *testing.T) { + // A 3-day all-day event (Jul 13, 14, 15) has End=Jul16 00:00 (exclusive). + start, _ := time.Parse(time.RFC3339, "2026-07-13T00:00:00Z") + end, _ := time.Parse(time.RFC3339, "2026-07-16T00:00:00Z") + item := models.TimelineItem{ + ID: "allday-2", Type: models.TimelineItemTypeEvent, + Time: start, EndTime: &end, IsAllDay: true, + } + if !isMultiDayEvent(item) { + t.Error("expected a 3-day all-day event to be multi-day") + } +} + +func TestMultiDayVariant_MultiDayAllDayEvent_LastRealDayIsEnds(t *testing.T) { + // The 3-day all-day event above (Jul 13-15 inclusive, End=Jul16 exclusive) + // must report "ends" on Jul 15 (its real last day), not Jul 16. + start, _ := time.Parse(time.RFC3339, "2026-07-13T00:00:00Z") + end, _ := time.Parse(time.RFC3339, "2026-07-16T00:00:00Z") + item := models.TimelineItem{ + ID: "allday-2", Type: models.TimelineItemTypeEvent, + Time: start, EndTime: &end, IsAllDay: true, + } + renderDay, _ := time.Parse(time.RFC3339, "2026-07-15T00:00:00Z") + if got := multiDayVariant(item, renderDay); got != "ends" { + t.Errorf("variant on last real day = %q, want %q", got, "ends") + } + exclusiveEndDay, _ := time.Parse(time.RFC3339, "2026-07-16T00:00:00Z") + if got := multiDayVariant(item, exclusiveEndDay); got != "" { + t.Errorf("variant on the exclusive (non-real) end day = %q, want empty", got) + } +} |
