From 8ca820b05e9e699a7b563a2e37ff2a0629a5505a Mon Sep 17 00:00:00 2001 From: Doot Agent Date: Sun, 5 Jul 2026 08:22:17 +0000 Subject: fix: native tasks missing from Tasks tab and blank title on completion Bug 1: BuildUnifiedAtomList never called GetNativeTasks(), so doot-sourced tasks were absent from the web Tasks tab. Added GetNativeTasks() fetch and NativeTaskToAtom conversion (new model helper, SourceDoot constant). Bug 2: handleAtomToggle called getAtomDetails after CompleteNativeTask, but GetNativeTasks filters WHERE completed=0, so the task was already gone and the title came back blank. Moved getAtomDetails call to before the completion switch so all sources (including doot) capture title/dueDate first. Also fixed widget_test.go compile error: TestHandleWidgetComplete_NonTodoist called HandleWidgetComplete as a package-level function but it is a method on *Handler. Rewrote the file as package handlers (internal) and construct &Handler{} directly. Regression tests added for both bugs in atoms_test.go and handlers_test.go. Co-Authored-By: Claude Sonnet 4.6 --- internal/handlers/widget_test.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'internal/handlers/widget_test.go') diff --git a/internal/handlers/widget_test.go b/internal/handlers/widget_test.go index ed9d941..5b054a0 100644 --- a/internal/handlers/widget_test.go +++ b/internal/handlers/widget_test.go @@ -1,4 +1,4 @@ -package handlers_test +package handlers import ( "net/http" @@ -7,14 +7,13 @@ import ( "testing" "time" - "task-dashboard/internal/handlers" "task-dashboard/internal/models" ) func TestWidgetAuthMiddleware_NoToken(t *testing.T) { called := false inner := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { called = true }) - h := handlers.WidgetAuthMiddleware("secret", inner) + h := WidgetAuthMiddleware("secret", inner) req := httptest.NewRequest("GET", "/api/widget", nil) w := httptest.NewRecorder() @@ -30,7 +29,7 @@ func TestWidgetAuthMiddleware_NoToken(t *testing.T) { func TestWidgetAuthMiddleware_WrongToken(t *testing.T) { inner := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - h := handlers.WidgetAuthMiddleware("secret", inner) + h := WidgetAuthMiddleware("secret", inner) req := httptest.NewRequest("GET", "/api/widget", nil) req.Header.Set("Authorization", "Bearer wrong") @@ -45,7 +44,7 @@ func TestWidgetAuthMiddleware_WrongToken(t *testing.T) { func TestWidgetAuthMiddleware_CorrectToken(t *testing.T) { called := false inner := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { called = true }) - h := handlers.WidgetAuthMiddleware("secret", inner) + h := WidgetAuthMiddleware("secret", inner) req := httptest.NewRequest("GET", "/api/widget", nil) req.Header.Set("Authorization", "Bearer secret") @@ -69,7 +68,7 @@ func TestTimelineItemToWidgetItem_Task(t *testing.T) { URL: "https://todoist.com/task/abc", } - wi := handlers.TimelineItemToWidgetItem(item) + wi := TimelineItemToWidgetItem(item) if wi.ID != "abc" { t.Errorf("ID: got %q, want %q", wi.ID, "abc") @@ -97,7 +96,7 @@ func TestTimelineItemToWidgetItem_Event(t *testing.T) { EndTime: &end, } - wi := handlers.TimelineItemToWidgetItem(item) + wi := TimelineItemToWidgetItem(item) if wi.Type != "event" { t.Errorf("Type: got %q, want %q", wi.Type, "event") @@ -111,11 +110,11 @@ func TestTimelineItemToWidgetItem_Event(t *testing.T) { } func TestHandleWidgetComplete_NonTodoist(t *testing.T) { - h := handlers.HandleWidgetComplete(nil) + h := &Handler{} body := `{"id":"x","source":"calendar"}` req := httptest.NewRequest("POST", "/api/widget/complete", strings.NewReader(body)) w := httptest.NewRecorder() - h.ServeHTTP(w, req) + http.HandlerFunc(h.HandleWidgetComplete).ServeHTTP(w, req) if w.Code != http.StatusBadRequest { t.Fatalf("expected 400, got %d", w.Code) @@ -124,7 +123,7 @@ func TestHandleWidgetComplete_NonTodoist(t *testing.T) { func TestWidgetAuthMiddleware_EmptyToken(t *testing.T) { inner := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - h := handlers.WidgetAuthMiddleware("", inner) + h := WidgetAuthMiddleware("", inner) req := httptest.NewRequest("GET", "/api/widget", nil) req.Header.Set("Authorization", "Bearer ") -- cgit v1.2.3