From e60524961a17e74b54be81b4f77dc30a5f7195a5 Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Mon, 23 Mar 2026 19:46:18 +0100 Subject: [PATCH] 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) --- display_test.go | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) 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