summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-07-15 18:30:28 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-07-16 02:54:17 +0000
commitc1ba9994367dd077ba2422d31a658a0c62e2520b (patch)
tree39ce22a4d7b7dc62981d36e7de83df605f5e2af6 /internal
parent37c323481d2e124e75bf3480dbc3bf53cad915e0 (diff)
test(tasks): add tests for project color threading
Tests verify ProjectColor is populated in BuildTimeline and copied to WidgetItem.
Diffstat (limited to 'internal')
-rw-r--r--internal/handlers/timeline_logic_test.go33
-rw-r--r--internal/handlers/widget_test.go25
2 files changed, 58 insertions, 0 deletions
diff --git a/internal/handlers/timeline_logic_test.go b/internal/handlers/timeline_logic_test.go
index 89581a3..7b5c47e 100644
--- a/internal/handlers/timeline_logic_test.go
+++ b/internal/handlers/timeline_logic_test.go
@@ -498,6 +498,39 @@ func TestSaveAndGetCalendarEvents(t *testing.T) {
}
}
+func TestBuildTimeline_PopulatesProjectColorForNativeTasks(t *testing.T) {
+ s, cleanup := setupTestDB(t)
+ defer cleanup()
+ project, err := s.CreateProject("Sailing prep", "#3B82F6")
+ if err != nil {
+ t.Fatal(err)
+ }
+ now := time.Now()
+ if _, err := s.DB().Exec(`
+ INSERT INTO native_tasks (id, content, due_date, project_id) VALUES ('rec-1', 'Water plants', ?, ?)
+ `, now, project.ID); err != nil {
+ t.Fatal(err)
+ }
+
+ items, err := BuildTimeline(context.Background(), s, now.Add(-time.Hour), now.Add(24*time.Hour))
+ if err != nil {
+ t.Fatalf("BuildTimeline: %v", err)
+ }
+
+ var found *models.TimelineItem
+ for i := range items {
+ if items[i].ID == "rec-1" {
+ found = &items[i]
+ }
+ }
+ if found == nil {
+ t.Fatal("expected to find rec-1 in the timeline")
+ }
+ if found.ProjectColor != "#3B82F6" {
+ t.Errorf("ProjectColor = %q, want %q", found.ProjectColor, "#3B82F6")
+ }
+}
+
func timePtr(t time.Time) *time.Time {
return &t
}
diff --git a/internal/handlers/widget_test.go b/internal/handlers/widget_test.go
index a6ff095..f934dba 100644
--- a/internal/handlers/widget_test.go
+++ b/internal/handlers/widget_test.go
@@ -1189,3 +1189,28 @@ func TestHandleWidgetTaskDetail_IncludesProjectAndLabels(t *testing.T) {
}
}
+func TestTimelineItemToWidgetItem_CopiesProjectColor(t *testing.T) {
+ item := models.TimelineItem{
+ ID: "rec-1",
+ Type: models.TimelineItemTypeTask,
+ Source: "doot",
+ ProjectColor: "#3B82F6",
+ }
+
+ wi := TimelineItemToWidgetItem(item)
+
+ if wi.ProjectColor == nil || *wi.ProjectColor != "#3B82F6" {
+ t.Errorf("ProjectColor = %v, want #3B82F6", wi.ProjectColor)
+ }
+}
+
+func TestTimelineItemToWidgetItem_NoProject_NilProjectColor(t *testing.T) {
+ item := models.TimelineItem{ID: "rec-1", Type: models.TimelineItemTypeTask, Source: "doot"}
+
+ wi := TimelineItemToWidgetItem(item)
+
+ if wi.ProjectColor != nil {
+ t.Errorf("ProjectColor = %v, want nil", wi.ProjectColor)
+ }
+}
+