summaryrefslogtreecommitdiff
path: root/internal/handlers/timeline_logic_test.go
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/handlers/timeline_logic_test.go
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/handlers/timeline_logic_test.go')
-rw-r--r--internal/handlers/timeline_logic_test.go33
1 files changed, 33 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
}