diff options
| author | Doot Agent <agent@doot.local> | 2026-07-06 00:00:59 +0000 |
|---|---|---|
| committer | Doot Agent <agent@doot.local> | 2026-07-06 00:00:59 +0000 |
| commit | 945c34590677e161a711ccaff0e1077197b1b178 (patch) | |
| tree | df26e8ba5a369b3323649c2fab95bd8e7a49b58e /internal/handlers/timeline_logic_test.go | |
| parent | cd14604bbef17f696475cf8737f1e41c9fa2dd06 (diff) | |
feat: remove Todoist integration entirely
Native tasks (native_tasks table) fully replace Todoist. All Todoist
API code, store functions, handlers, routes, templates, and tests have
been removed. Migration 021 drops the now-unused tasks cache table.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/handlers/timeline_logic_test.go')
| -rw-r--r-- | internal/handlers/timeline_logic_test.go | 146 |
1 files changed, 10 insertions, 136 deletions
diff --git a/internal/handlers/timeline_logic_test.go b/internal/handlers/timeline_logic_test.go index 03bc291..3678b62 100644 --- a/internal/handlers/timeline_logic_test.go +++ b/internal/handlers/timeline_logic_test.go @@ -46,20 +46,6 @@ func setupTestStore(t *testing.T) *store.Store { } schema := ` - CREATE TABLE IF NOT EXISTS tasks ( - id TEXT PRIMARY KEY, - content TEXT NOT NULL, - description TEXT, - project_id TEXT, - project_name TEXT, - due_date DATETIME, - priority INTEGER DEFAULT 1, - completed BOOLEAN DEFAULT FALSE, - labels TEXT, - url TEXT, - created_at DATETIME, - updated_at DATETIME DEFAULT CURRENT_TIMESTAMP - ); CREATE TABLE IF NOT EXISTS meals ( id TEXT PRIMARY KEY, recipe_name TEXT NOT NULL, @@ -118,15 +104,9 @@ func setupTestStore(t *testing.T) *store.Store { func TestBuildTimeline(t *testing.T) { s := setupTestStore(t) - + // Fix a base time: 2023-01-01 08:00:00 baseTime := time.Date(2023, 1, 1, 8, 0, 0, 0, time.UTC) - - // Task: 10:00 - taskDate := baseTime.Add(2 * time.Hour) - _ = s.SaveTasks([]models.Task{ - {ID: "t1", Content: "Task 1", DueDate: &taskDate}, - }) // Meal: Lunch (defaults to 12:00) mealDate := baseTime // Date part matters @@ -138,7 +118,7 @@ func TestBuildTimeline(t *testing.T) { cardDate := baseTime.Add(6 * time.Hour) _ = s.SaveBoards([]models.Board{ { - ID: "b1", + ID: "b1", Name: "Board 1", Cards: []models.Card{ {ID: "c1", Name: "Card 1", DueDate: &cardDate, ListID: "l1"}, @@ -161,27 +141,23 @@ func TestBuildTimeline(t *testing.T) { t.Fatalf("BuildTimeline failed: %v", err) } - if len(items) != 4 { - t.Errorf("Expected 4 items, got %d", len(items)) + if len(items) != 3 { + t.Errorf("Expected 3 items, got %d", len(items)) } // Expected Order: // 1. Event (09:00) - // 2. Task (10:00) - // 3. Meal (12:00) - // 4. Card (14:00) + // 2. Meal (12:00) + // 3. Card (14:00) if items[0].Type != models.TimelineItemTypeEvent { t.Errorf("Expected item 0 to be Event, got %s", items[0].Type) } - if items[1].Type != models.TimelineItemTypeTask { - t.Errorf("Expected item 1 to be Task, got %s", items[1].Type) + if items[1].Type != models.TimelineItemTypeMeal { + t.Errorf("Expected item 1 to be Meal, got %s", items[1].Type) } - if items[2].Type != models.TimelineItemTypeMeal { - t.Errorf("Expected item 2 to be Meal, got %s", items[2].Type) - } - if items[3].Type != models.TimelineItemTypeCard { - t.Errorf("Expected item 3 to be Card, got %s", items[3].Type) + if items[2].Type != models.TimelineItemTypeCard { + t.Errorf("Expected item 2 to be Card, got %s", items[2].Type) } } @@ -273,78 +249,6 @@ func TestCalcCalendarBounds(t *testing.T) { } } -func TestBuildTimeline_IncludesOverdueItems(t *testing.T) { - s := setupTestStore(t) - - // Base: "today" is Jan 2, 2023 - today := time.Date(2023, 1, 2, 0, 0, 0, 0, time.UTC) - yesterday := time.Date(2023, 1, 1, 10, 0, 0, 0, time.UTC) // overdue - todayNoon := time.Date(2023, 1, 2, 12, 0, 0, 0, time.UTC) // current - - // Save a task that is overdue (yesterday) and one that is current (today) - _ = s.SaveTasks([]models.Task{ - {ID: "overdue1", Content: "Overdue task", DueDate: &yesterday}, - {ID: "current1", Content: "Current task", DueDate: &todayNoon}, - }) - - // Query range: today through tomorrow - end := today.AddDate(0, 0, 1) - - items, err := BuildTimeline(context.Background(), s, today, end) - if err != nil { - t.Fatalf("BuildTimeline failed: %v", err) - } - - // Should include both the overdue task and the current task - if len(items) < 2 { - t.Errorf("Expected at least 2 items (overdue + current), got %d", len(items)) - for _, item := range items { - t.Logf(" item: %s (type=%s, time=%s)", item.Title, item.Type, item.Time) - } - } - - // Verify overdue task is marked as overdue - foundOverdue := false - for _, item := range items { - if item.ID == "overdue1" { - foundOverdue = true - if !item.IsOverdue { - t.Error("Expected overdue task to be marked IsOverdue=true") - } - if item.DaySection != models.DaySectionToday { - t.Errorf("Expected overdue task in Today section, got %s", item.DaySection) - } - } - } - if !foundOverdue { - t.Error("Overdue task was not included in timeline results") - } -} - -func TestBuildTimeline_ExcludesCompletedOverdue(t *testing.T) { - s := setupTestStore(t) - - yesterday := time.Date(2023, 1, 1, 10, 0, 0, 0, time.UTC) - today := time.Date(2023, 1, 2, 0, 0, 0, 0, time.UTC) - end := today.AddDate(0, 0, 1) - - // Save a completed overdue task — should NOT appear - _ = s.SaveTasks([]models.Task{ - {ID: "done1", Content: "Done overdue", DueDate: &yesterday, Completed: true}, - }) - - items, err := BuildTimeline(context.Background(), s, today, end) - if err != nil { - t.Fatalf("BuildTimeline failed: %v", err) - } - - for _, item := range items { - if item.ID == "done1" { - t.Error("Completed overdue task should not appear in timeline") - } - } -} - func TestBuildTimeline_ReadsCalendarEventsFromStore(t *testing.T) { s := setupTestStore(t) @@ -483,36 +387,6 @@ func TestSaveAndGetCalendarEvents(t *testing.T) { } } -func TestBuildTimeline_IncludesUndatedTodoistTasks(t *testing.T) { - s := setupTestStore(t) - - // Save a task with no due date - _ = s.SaveTasks([]models.Task{ - {ID: "undated1", Content: "Take out recycling"}, // DueDate is nil - }) - - start := time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC) - end := time.Date(2023, 1, 2, 0, 0, 0, 0, time.UTC) - - items, err := BuildTimeline(context.Background(), s, start, end) - if err != nil { - t.Fatalf("BuildTimeline failed: %v", err) - } - - found := false - for _, item := range items { - if item.ID == "undated1" { - found = true - if item.DaySection != models.DaySectionToday { - t.Errorf("Undated task should be in Today section, got %s", item.DaySection) - } - } - } - if !found { - t.Error("Undated Todoist task should appear in timeline Today section") - } -} - func timePtr(t time.Time) *time.Time { return &t } |
