summaryrefslogtreecommitdiff
path: root/internal/api/google_tasks_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/google_tasks_test.go')
-rw-r--r--internal/api/google_tasks_test.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/api/google_tasks_test.go b/internal/api/google_tasks_test.go
index fbfdd63..bdb0187 100644
--- a/internal/api/google_tasks_test.go
+++ b/internal/api/google_tasks_test.go
@@ -185,3 +185,43 @@ func TestGetTasksByDateRange_OutOfRangeExcluded(t *testing.T) {
t.Errorf("expected task-in-range, got %s", tasks[0].ID)
}
}
+
+// TestGetTasksFromList_DueDateNotShiftedByNegativeOffsetTZ guards against a
+// regression where a task due "tomorrow" showed up "today" on the widget.
+// Google Tasks' due field is date-only but always serialized as midnight
+// UTC. Converting that instant into a negative-offset display timezone
+// (e.g. Pacific/Honolulu, UTC-10) instead of re-anchoring the same calendar
+// date to local midnight shifted every dated task back by one day.
+func TestGetTasksFromList_DueDateNotShiftedByNegativeOffsetTZ(t *testing.T) {
+ honolulu, err := time.LoadLocation("Pacific/Honolulu")
+ if err != nil {
+ t.Skipf("Pacific/Honolulu tzdata not available: %v", err)
+ }
+
+ body := tasksAPIResponse([]map[string]interface{}{
+ {
+ "id": "task-tomorrow",
+ "title": "Due tomorrow",
+ "status": "needsAction",
+ "due": "2026-07-29T00:00:00.000Z",
+ "updated": "2026-07-28T00:00:00Z",
+ },
+ })
+ server := newTasksServer(body)
+ defer server.Close()
+
+ client := newTestGoogleTasksClient(t, server, "@default", honolulu)
+ tasks, err := client.GetTasks(context.Background())
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+ if len(tasks) != 1 {
+ t.Fatalf("expected 1 task, got %d", len(tasks))
+ }
+ if tasks[0].DueDate == nil {
+ t.Fatal("expected DueDate to be set")
+ }
+ if y, m, d := tasks[0].DueDate.Date(); y != 2026 || m != time.July || d != 29 {
+ t.Errorf("expected due date 2026-07-29, got %04d-%02d-%02d (task shifted a day earlier than Google reported)", y, m, d)
+ }
+}