1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
package dashboard
import (
"strings"
"testing"
common "ior/internal/tui/common"
)
func TestTabNavigationWraps(t *testing.T) {
if got := nextTab(TabLatency); got != TabStream {
t.Fatalf("expected next after latency+gaps to be stream, got %v", got)
}
if got := nextTab(TabStream); got != TabFlame {
t.Fatalf("expected next after stream to be flame, got %v", got)
}
if got := nextTab(TabFlame); got != TabOverview {
t.Fatalf("expected wrap to overview from flame, got %v", got)
}
if got := prevTab(TabOverview); got != TabFlame {
t.Fatalf("expected wrap to flame, got %v", got)
}
}
func TestRenderTabBarContainsLabels(t *testing.T) {
out := renderTabBar(TabOverview, 100)
for _, label := range []string{"Overview", "Syscalls", "Files", "Processes", "Latency+Gaps", "Stream", "Flame"} {
if !strings.Contains(out, label) {
t.Fatalf("expected tab label %q in tab bar", label)
}
}
}
func TestRenderTabBarSmallWidthUsesSingleLine(t *testing.T) {
out := renderTabBar(TabOverview, 70)
lines := strings.Split(out, "\n")
if len(lines) != 1 {
t.Fatalf("expected single-line tab bar at width 70, got %d lines", len(lines))
}
if strings.Contains(out, "7:Flam") {
t.Fatalf("tab label should not be wrapped/split in small width output")
}
}
func TestRenderHelpBarSmallWidthCanWrapToTwoLines(t *testing.T) {
out := renderHelpBar(common.DefaultKeyMap(), 70)
lines := strings.Split(out, "\n")
if len(lines) != 2 {
t.Fatalf("expected exactly two section lines at width 70, got %d lines", len(lines))
}
if !strings.Contains(lines[0], "Global:") {
t.Fatalf("expected Global section line, got %q", lines[0])
}
if !strings.Contains(lines[1], "Dashboard:") {
t.Fatalf("expected Dashboard section line, got %q", lines[1])
}
}
func TestRenderHelpHintWithStatusIncludesFilterSummary(t *testing.T) {
out := renderHelpHintWithStatus(120, "filter: syscall~read")
if !strings.Contains(out, "filter: syscall~read") {
t.Fatalf("expected filter summary in help hint, got %q", out)
}
}
func TestRenderHelpBarWithStatusIncludesFilterSummary(t *testing.T) {
out := renderHelpBarWithStatus(common.DefaultKeyMap(), 0, "filter: pid=42")
if !strings.Contains(out, "filter: pid=42") {
t.Fatalf("expected filter summary in help bar, got %q", out)
}
}
func TestRenderHelpBarIncludesSortBinding(t *testing.T) {
out := renderHelpBar(common.DefaultKeyMap(), 0)
if !strings.Contains(out, "s sort table") {
t.Fatalf("expected sort binding in rendered help bar, got %q", out)
}
}
|