summaryrefslogtreecommitdiff
path: root/internal/handlers/timeline_logic_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/handlers/timeline_logic_test.go')
-rw-r--r--internal/handlers/timeline_logic_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/internal/handlers/timeline_logic_test.go b/internal/handlers/timeline_logic_test.go
index 7b5c47e..1a6ea6c 100644
--- a/internal/handlers/timeline_logic_test.go
+++ b/internal/handlers/timeline_logic_test.go
@@ -169,6 +169,48 @@ func TestBuildTimeline(t *testing.T) {
}
}
+// TestBuildTimeline_UndatedGoogleTaskIsAllDay guards against a regression
+// where a Google Task with no due date got Time set to "now" but IsAllDay
+// left false (unlike nativeUndated doot tasks, which set IsAllDay: true).
+// TimelineItemToWidgetItem then treated the near-"now" Time as a real
+// scheduled Start, so the task could land among scheduledEvents and render
+// via the widget's EventBlock/HourRow -- rows whose click handler always
+// opens the source URL / Google Calendar instead of the task detail sheet.
+func TestBuildTimeline_UndatedGoogleTaskIsAllDay(t *testing.T) {
+ s := setupTestStore(t)
+
+ if err := s.SaveGoogleTasks([]models.GoogleTask{
+ {ID: "g1", Title: "Hardware store", Status: "needsAction", ListID: "l1"},
+ }); err != nil {
+ t.Fatalf("SaveGoogleTasks failed: %v", err)
+ }
+
+ start := time.Now().Add(-24 * time.Hour)
+ end := time.Now().Add(24 * time.Hour)
+ items, err := BuildTimeline(context.Background(), s, start, end)
+ if err != nil {
+ t.Fatalf("BuildTimeline failed: %v", err)
+ }
+
+ var found *models.TimelineItem
+ for i := range items {
+ if items[i].ID == "g1" {
+ found = &items[i]
+ }
+ }
+ if found == nil {
+ t.Fatal("expected undated google task g1 to appear in timeline")
+ }
+ if !found.IsAllDay {
+ t.Error("expected undated google task to be flagged IsAllDay so it stays a floating task on the widget, not a scheduled event")
+ }
+
+ wi := TimelineItemToWidgetItem(*found)
+ if wi.Start != nil {
+ t.Error("expected undated google task to have nil Start so the widget renders it via TaskRow, not EventBlock")
+ }
+}
+
func TestCalcCalendarBounds(t *testing.T) {
tests := []struct {
name string