test(03-02): add failing tests for WaitType display in vmux list

- TestDisplayWaitTypePermission, TestDisplayWaitTypeQuestion
- TestDisplayWaitTypeEmpty, TestDisplayWorkingNoWaitType

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pierre Martin
2026-03-23 19:46:18 +01:00
parent 79ad8fb16a
commit e60524961a

View File

@@ -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) { func TestFormatDuration(t *testing.T) {
tests := []struct { tests := []struct {
d time.Duration d time.Duration