diff --git a/display_test.go b/display_test.go index f7f310d..78daf6a 100644 --- a/display_test.go +++ b/display_test.go @@ -236,6 +236,94 @@ func TestDisplayWithPreview(t *testing.T) { } } +// --- WaitType display tests --- + +func TestDisplayWaitTypePermission(t *testing.T) { + sessions := []SessionInfo{ + { + PID: 100, + SessionID: "sess-1", + Cwd: "/home/user/project", + State: "Needs Input", + WaitType: "permission", + }, + } + + var buf bytes.Buffer + DisplaySessionInfos(&buf, sessions, true, time.Now()) + output := buf.String() + + if !strings.Contains(output, "Needs Input: permission") { + t.Errorf("output should contain 'Needs Input: permission': %q", output) + } +} + +func TestDisplayWaitTypeQuestion(t *testing.T) { + sessions := []SessionInfo{ + { + PID: 100, + SessionID: "sess-1", + Cwd: "/home/user/project", + State: "Needs Input", + WaitType: "question", + }, + } + + var buf bytes.Buffer + DisplaySessionInfos(&buf, sessions, true, time.Now()) + output := buf.String() + + if !strings.Contains(output, "Needs Input: question") { + t.Errorf("output should contain 'Needs Input: question': %q", output) + } +} + +func TestDisplayWaitTypeEmpty(t *testing.T) { + sessions := []SessionInfo{ + { + PID: 100, + SessionID: "sess-1", + Cwd: "/home/user/project", + State: "Needs Input", + WaitType: "", + }, + } + + var buf bytes.Buffer + DisplaySessionInfos(&buf, sessions, true, time.Now()) + output := buf.String() + + if !strings.Contains(output, "[Needs Input]") { + t.Errorf("output should contain '[Needs Input]' without detail: %q", output) + } + if strings.Contains(output, ": ]") || strings.Contains(output, "Needs Input: ") { + t.Errorf("output should not have trailing colon when WaitType empty: %q", output) + } +} + +func TestDisplayWorkingNoWaitType(t *testing.T) { + sessions := []SessionInfo{ + { + PID: 100, + SessionID: "sess-1", + Cwd: "/home/user/project", + State: "Working", + WaitType: "permission", // should be ignored for Working state + }, + } + + var buf bytes.Buffer + DisplaySessionInfos(&buf, sessions, true, time.Now()) + output := buf.String() + + if strings.Contains(output, "permission") { + t.Errorf("Working state should not show WaitType: %q", output) + } + if !strings.Contains(output, "[Working]") { + t.Errorf("output should contain '[Working]': %q", output) + } +} + func TestFormatDuration(t *testing.T) { tests := []struct { d time.Duration