summaryrefslogtreecommitdiff
path: root/internal/ui/table_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-27 00:10:51 +0300
committerPaul Buetow <paul@buetow.org>2026-06-27 00:10:51 +0300
commit25c1fe6439892e9b5ba5bf36c195cfe538490352 (patch)
tree875eafb1633c2c503590c9e1c74c51fae92b1535 /internal/ui/table_test.go
parentbca7d87f11a3ee88c75dc1ed706009d63022ef98 (diff)
fr0 review fixes: preserve recurrence error cmd, normalize agent hotkey ctrl+ case, detail-view ctrl+r, esc-reset test
Diffstat (limited to 'internal/ui/table_test.go')
-rw-r--r--internal/ui/table_test.go126
1 files changed, 126 insertions, 0 deletions
diff --git a/internal/ui/table_test.go b/internal/ui/table_test.go
index 30716f1..505f937 100644
--- a/internal/ui/table_test.go
+++ b/internal/ui/table_test.go
@@ -1545,6 +1545,132 @@ func TestRecurringSeriesRecurrenceHotkey(t *testing.T) {
}
}
+func TestRecurringSeriesRecurrenceEscExitsAndResetsSeriesState(t *testing.T) {
+ fake := &fakeTaskwarrior{
+ tasks: []task.Task{
+ {ID: 7, UUID: "child", Parent: "root", Description: "child", Status: "pending", Recur: "daily", RType: "periodic"},
+ },
+ }
+ m, err := NewWithTaskwarrior(nil, "firefox", fake)
+ if err != nil {
+ t.Fatalf("NewWithTaskwarrior: %v", err)
+ }
+
+ mv, _ := (&m).Update(ctrlRKey())
+ m = *mv.(*Model)
+ if !m.recurEditing || !m.recurSeries || m.recurRoot != "root" {
+ t.Fatalf("series edit not active: editing=%v series=%v root=%q", m.recurEditing, m.recurSeries, m.recurRoot)
+ }
+
+ mv, _ = (&m).Update(tea.KeyPressMsg{Code: tea.KeyEscape})
+ m = *mv.(*Model)
+
+ if m.recurEditing {
+ t.Fatalf("esc did not exit recurrence editing")
+ }
+ if m.recurSeries || m.recurRoot != "" {
+ t.Fatalf("series state not reset on esc: series=%v root=%q", m.recurSeries, m.recurRoot)
+ }
+ if len(fake.seriesRecurrences) != 0 {
+ t.Fatalf("esc committed a series update: %#v", fake.seriesRecurrences)
+ }
+}
+
+func TestRecurringSeriesRecurrenceFailurePreservesErrorCommand(t *testing.T) {
+ fake := &fakeTaskwarrior{
+ tasks: []task.Task{
+ {ID: 7, UUID: "child", Parent: "root", Description: "child", Status: "pending", Recur: "daily", RType: "periodic"},
+ },
+ setSeriesRecurrenceErr: errors.New("series failed"),
+ }
+ m, err := NewWithTaskwarrior(nil, "firefox", fake)
+ if err != nil {
+ t.Fatalf("NewWithTaskwarrior: %v", err)
+ }
+
+ mv, _ := (&m).Update(ctrlRKey())
+ m = *mv.(*Model)
+ m.recurInput.SetValue("weekly")
+
+ mv, cmd := (&m).Update(tea.KeyPressMsg{Code: tea.KeyEnter})
+ m = *mv.(*Model)
+
+ if cmd == nil {
+ t.Fatalf("expected timed error command")
+ }
+ if !m.recurEditing {
+ t.Fatalf("recurrence input should stay active after failure")
+ }
+ if m.blinkID != 0 {
+ t.Fatalf("success blink started for failed recurrence edit: blinkID=%d", m.blinkID)
+ }
+ if !strings.Contains(m.statusMsg, "series failed") {
+ t.Fatalf("statusMsg = %q, want recurrence error", m.statusMsg)
+ }
+}
+
+func TestRecurringSeriesRecurrenceFailureKeepsTimedErrorWhenBlinkDisabled(t *testing.T) {
+ fake := &fakeTaskwarrior{
+ tasks: []task.Task{
+ {ID: 7, UUID: "child", Parent: "root", Description: "child", Status: "pending", Recur: "daily", RType: "periodic"},
+ },
+ setSeriesRecurrenceErr: errors.New("series failed"),
+ }
+ m, err := NewWithTaskwarrior(nil, "firefox", fake)
+ if err != nil {
+ t.Fatalf("NewWithTaskwarrior: %v", err)
+ }
+ m.blinkEnabled = false
+
+ mv, _ := (&m).Update(ctrlRKey())
+ m = *mv.(*Model)
+ m.recurInput.SetValue("weekly")
+
+ mv, cmd := (&m).Update(tea.KeyPressMsg{Code: tea.KeyEnter})
+ m = *mv.(*Model)
+
+ if cmd == nil {
+ t.Fatalf("expected timed error command when blink is disabled")
+ }
+ if !strings.Contains(m.statusMsg, "series failed") {
+ t.Fatalf("statusMsg = %q, want recurrence error", m.statusMsg)
+ }
+}
+
+func TestRecurringSeriesRecurrenceHotkeyInDetailMode(t *testing.T) {
+ fake := &fakeTaskwarrior{
+ tasks: []task.Task{
+ {ID: 7, UUID: "child", Parent: "root", Description: "child", Status: "pending", Recur: "daily", RType: "periodic"},
+ },
+ }
+ m, err := NewWithTaskwarrior(nil, "firefox", fake)
+ if err != nil {
+ t.Fatalf("NewWithTaskwarrior: %v", err)
+ }
+
+ mv, _ := (&m).Update(tea.KeyPressMsg{Code: tea.KeyEnter})
+ m = *mv.(*Model)
+ if !m.showTaskDetail {
+ t.Fatalf("enter did not open detail mode")
+ }
+
+ mv, _ = (&m).Update(ctrlRKey())
+ m = *mv.(*Model)
+
+ if !m.recurEditing {
+ t.Fatalf("detail ctrl+r did not activate recurrence editing")
+ }
+ if !m.recurSeries {
+ t.Fatalf("detail ctrl+r did not mark recurrence edit as series scoped")
+ }
+ if m.recurRoot != "root" {
+ t.Fatalf("recurring root = %q, want root", m.recurRoot)
+ }
+ if m.recurInput.Value() != "daily" {
+ t.Fatalf("recur input = %q, want daily", m.recurInput.Value())
+ }
+}
+
func TestRecurringSeriesRecurrenceHotkeyRejectsNonRecurringTask(t *testing.T) {
fake := &fakeTaskwarrior{
tasks: []task.Task{