返回 DeepSeek-Reasonix
todopanel_test.go
根目录 / internal / cli / todopanel_test.go
1 package cli
2
3 import (
4 "strings"
5 "testing"
6
7 "github.com/charmbracelet/x/ansi"
8 )
9
10 // TestRenderTodoPanelNesting proves a level-1 sub-step renders indented under
11 // its level-0 phase in the pinned task panel.
12 func TestRenderTodoPanelNesting(t *testing.T) {
13 m := newTestChatTUI()
14 m.width = 60
15 m.todoArgs = `{"todos":[` +
16 `{"content":"Phase A","status":"in_progress","level":0},` +
17 `{"content":"sub one","status":"pending","level":1}]}`
18
19 out := ansi.Strip(m.renderTodoPanel())
20 if !strings.Contains(out, "Phase A") {
21 t.Fatalf("panel missing phase:\n%s", out)
22 }
23 if !strings.Contains(out, " ○ sub one") {
24 t.Fatalf("sub-step not indented under its phase:\n%s", out)
25 }
26 }
27
28 func TestRenderTodoPanelScrollsToInProgressTodo(t *testing.T) {
29 m := newTestChatTUI()
30 m.width = 72
31 m.todoArgs = `{"todos":[` +
32 `{"content":"Item 01","status":"completed"},` +
33 `{"content":"Item 02","status":"completed"},` +
34 `{"content":"Item 03","status":"completed"},` +
35 `{"content":"Item 04","status":"completed"},` +
36 `{"content":"Item 05","status":"completed"},` +
37 `{"content":"Item 06","status":"completed"},` +
38 `{"content":"Item 07","status":"completed"},` +
39 `{"content":"Item 08","status":"completed"},` +
40 `{"content":"Item 09","status":"in_progress","activeForm":"Working item 09"},` +
41 `{"content":"Item 10","status":"pending"}]}`
42
43 out := ansi.Strip(m.renderTodoPanel())
44 if !strings.Contains(out, "Working item 09") {
45 t.Fatalf("panel should keep the in-progress todo visible:\n%s", out)
46 }
47 if strings.Contains(out, "Item 01") {
48 t.Fatalf("panel should window around the active todo instead of pinning the first rows:\n%s", out)
49 }
50 }
51
51 lines GO