Skip to content

Commit 9cd6169

Browse files
author
Peter Steinberger
committed
fix(calendar): preserve zero-minute popup reminders (openclaw#316) (thanks @salmonumbrella)
1 parent 14f4bea commit 9cd6169

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- Auth: keep Keep-only service-account fallback isolated to Keep commands so other Google services do not accidentally pick it up. (#414) — thanks @jgwesterlund.
2828
- Contacts: send the required `copyMask` when deleting "other contacts", avoiding People API 400 errors. (#384) — thanks @rbansal42.
2929
- Calendar: hide cancelled/deleted events from `calendar events` list output by explicitly setting `showDeleted=false`. (#362) — thanks @sharukh010.
30+
- Calendar: force-send `minutes=0` for `--reminder popup:0m` so zero-minute popup reminders survive Google Calendar API JSON omission rules. (#316) — thanks @salmonumbrella.
3031
- Calendar: use `Calendars.Get` for timezone lookups so service-account flows don’t 404 on `calendarList/primary`. (#325) — thanks @markwatson.
3132
- Auth: persist rotated OAuth refresh tokens returned during API calls so later commands keep working without re-auth. (#373) — thanks @joshp123.
3233
- Groups: include required label filters in transitive group searches so `groups list` doesn’t 400 on Cloud Identity. (#315) — thanks @salmonumbrella.

internal/cmd/calendar_create_update_test.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,77 @@ func TestCalendarUpdateCmd_SendUpdates(t *testing.T) {
656656
}
657657
}
658658

659+
func TestCalendarCreateCmd_ReminderPopupZeroForceSendsMinutes(t *testing.T) {
660+
origNew := newCalendarService
661+
t.Cleanup(func() { newCalendarService = origNew })
662+
663+
var gotEvent map[string]any
664+
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
665+
path := strings.TrimPrefix(r.URL.Path, "/calendar/v3")
666+
switch {
667+
case r.Method == http.MethodGet && path == "/users/me/calendarList":
668+
w.Header().Set("Content-Type", "application/json")
669+
_ = json.NewEncoder(w).Encode(map[string]any{
670+
"items": []map[string]any{
671+
{
672+
"id": "cal",
673+
"summary": "cal",
674+
"timeZone": "UTC",
675+
},
676+
},
677+
})
678+
return
679+
case r.Method == http.MethodPost && path == "/calendars/cal/events":
680+
if err := json.NewDecoder(r.Body).Decode(&gotEvent); err != nil {
681+
t.Fatalf("decode event: %v", err)
682+
}
683+
w.Header().Set("Content-Type", "application/json")
684+
_ = json.NewEncoder(w).Encode(map[string]any{
685+
"id": "ev",
686+
"summary": "Zero Reminder",
687+
})
688+
return
689+
}
690+
http.NotFound(w, r)
691+
}))
692+
defer srv.Close()
693+
694+
svc := newCalendarServiceFromServer(t, srv)
695+
newCalendarService = func(context.Context, string) (*calendar.Service, error) { return svc, nil }
696+
697+
ctx := newCalendarJSONContext(t)
698+
cmd := &CalendarCreateCmd{}
699+
if err := runKong(t, cmd, []string{
700+
"cal",
701+
"--summary", "Zero Reminder",
702+
"--from", "2025-01-01T10:00:00Z",
703+
"--to", "2025-01-01T11:00:00Z",
704+
"--reminder", "popup:0m",
705+
}, ctx, &RootFlags{Account: "a@b.com"}); err != nil {
706+
t.Fatalf("runKong: %v", err)
707+
}
708+
709+
reminders, ok := gotEvent["reminders"].(map[string]any)
710+
if !ok {
711+
t.Fatalf("expected reminders payload, got %#v", gotEvent["reminders"])
712+
}
713+
overrides, ok := reminders["overrides"].([]any)
714+
if !ok || len(overrides) != 1 {
715+
t.Fatalf("expected one override, got %#v", reminders["overrides"])
716+
}
717+
override, ok := overrides[0].(map[string]any)
718+
if !ok {
719+
t.Fatalf("expected override object, got %#v", overrides[0])
720+
}
721+
if method, _ := override["method"].(string); method != "popup" {
722+
t.Fatalf("expected popup reminder, got %#v", override)
723+
}
724+
minutes, ok := override["minutes"].(float64)
725+
if !ok || minutes != 0 {
726+
t.Fatalf("expected force-sent minutes=0, got %#v", override["minutes"])
727+
}
728+
}
729+
659730
func TestCalendarUpdateCmd_AddAttendeeNoOp(t *testing.T) {
660731
origNew := newCalendarService
661732
t.Cleanup(func() { newCalendarService = origNew })

0 commit comments

Comments
 (0)