From c1ba9994367dd077ba2422d31a658a0c62e2520b Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Wed, 15 Jul 2026 18:30:28 +0000 Subject: test(tasks): add tests for project color threading Tests verify ProjectColor is populated in BuildTimeline and copied to WidgetItem. --- internal/handlers/timeline_logic_test.go | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'internal/handlers/timeline_logic_test.go') 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 } -- cgit v1.2.3