From e00c8639e077253cff17967144df3e90fe9c46b5 Mon Sep 17 00:00:00 2001 From: zeshuochen <241961433+zeshuochen@users.noreply.github.com> Date: Wed, 16 Sep 2026 22:32:55 +0100 Subject: [PATCH] fix: serialize task all-day flag as isAllDay --- CHANGELOG.md | 3 +++ internal/cli/cli_test.go | 4 ++-- internal/webapi/tasks.go | 2 +- internal/webapi/tasks_test.go | 26 ++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f99e15c..0606c68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ Version numbers follow [Semantic Versioning](https://semver.org/). ## [Unreleased] +### Fixed +- `task create/update --not-all-day` now sends `isAllDay` to the Web API. + ## [v0.2.7] - 2026-07-18 ### Added diff --git a/internal/cli/cli_test.go b/internal/cli/cli_test.go index bf14661..c01f61c 100644 --- a/internal/cli/cli_test.go +++ b/internal/cli/cli_test.go @@ -765,8 +765,8 @@ func TestTaskCreateDryRunJSON(t *testing.T) { if items := task["items"].([]any); len(items) != 1 { t.Fatalf("items len = %d, want 1", len(items)) } - if task["allDay"] != true { - t.Fatalf("allDay = %v, want true", task["allDay"]) + if task["isAllDay"] != true { + t.Fatalf("isAllDay = %v, want true", task["isAllDay"]) } } diff --git a/internal/webapi/tasks.go b/internal/webapi/tasks.go index 9ac76b1..a612672 100644 --- a/internal/webapi/tasks.go +++ b/internal/webapi/tasks.go @@ -16,7 +16,7 @@ type TaskMutation struct { Title string `json:"title,omitempty"` Content string `json:"content,omitempty"` Desc string `json:"desc,omitempty"` - AllDay *bool `json:"allDay,omitempty"` + AllDay *bool `json:"isAllDay,omitempty"` StartDate string `json:"startDate,omitempty"` DueDate string `json:"dueDate,omitempty"` TimeZone string `json:"timeZone,omitempty"` diff --git a/internal/webapi/tasks_test.go b/internal/webapi/tasks_test.go index 58d39d3..3c20c30 100644 --- a/internal/webapi/tasks_test.go +++ b/internal/webapi/tasks_test.go @@ -82,6 +82,32 @@ func TestTaskUpdateCanSendPriorityZero(t *testing.T) { } } +func TestTaskUpdateCanSendAllDayFalse(t *testing.T) { + var rawBody string + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + data, err := io.ReadAll(r.Body) + if err != nil { + t.Fatalf("read request: %v", err) + } + rawBody = string(data) + _ = json.NewEncoder(w).Encode(map[string]any{"ok": true}) + })) + defer server.Close() + + client := NewClient("test-token") + client.BaseURL = server.URL + allDay := false + if _, err := client.UpdateTask(context.Background(), TaskMutation{ID: "t1", ProjectID: "p1", AllDay: &allDay}); err != nil { + t.Fatalf("UpdateTask() error = %v", err) + } + if !strings.Contains(rawBody, `"isAllDay":false`) { + t.Fatalf("request body missing isAllDay false: %s", rawBody) + } + if strings.Contains(rawBody, `"allDay"`) { + t.Fatalf("request body contains legacy allDay key: %s", rawBody) + } +} + func TestProjectTasksUsesProjectEndpoint(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if got := r.Method + " " + r.URL.Path; got != "GET /project/p1/tasks" {