summaryrefslogtreecommitdiff
path: root/internal/handlers/widget_test.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-07-17 08:53:57 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-07-17 08:53:57 +0000
commit244d751412a0a1e3ede8bd91e114a4ef4e1a7eaa (patch)
tree7b86c6069b6446288fd4289d4d72a67f4ed60f81 /internal/handlers/widget_test.go
parent533e8ac3aa2d0a3a1bda50a984356c9fcc40076d (diff)
fix(widget): autofocus quick-add title field, redesign as blank edit form
Quick Add's text field never requested focus or triggered the keyboard, so tapping it opened a sheet with no visible way to type. Added a FocusRequester + delayed requestFocus()/keyboard show (ModalBottomSheet needs a beat to finish its enter animation before focus requests land). While in there, rebuilt the quick-add sheet to match the task edit popup instead of being a bare title field: due date, recurrence, project, and label chips, plus a description field, reusing the same dialogs the edit popup already uses. POST /api/widget/add now returns the created task's id so the client can chain the same project/labels/recurrence/due-date setter calls edit already relies on.
Diffstat (limited to 'internal/handlers/widget_test.go')
-rw-r--r--internal/handlers/widget_test.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/handlers/widget_test.go b/internal/handlers/widget_test.go
index 02df111..749af3a 100644
--- a/internal/handlers/widget_test.go
+++ b/internal/handlers/widget_test.go
@@ -721,18 +721,26 @@ func TestHandleWidgetAdd_CreatesTask(t *testing.T) {
t.Fatalf("expected 200, got %d", w.Code)
}
+ var resp widgetAddResponse
+ if err := json.NewDecoder(w.Body).Decode(&resp); err != nil {
+ t.Fatalf("failed to decode response: %v", err)
+ }
+ if resp.ID == "" {
+ t.Fatal("expected a non-empty id in the response")
+ }
+
tasks, err := s.GetUndatedNativeTasks()
if err != nil {
t.Fatalf("failed to read back tasks: %v", err)
}
found := false
for _, task := range tasks {
- if task.Content == "Buy milk" {
+ if task.Content == "Buy milk" && task.ID == resp.ID {
found = true
}
}
if !found {
- t.Error("expected a task with content 'Buy milk' to have been created")
+ t.Error("expected a task with content 'Buy milk' and matching id to have been created")
}
}