feat(tui): click-to-inspect sparkline tooltips in detail view
CI / test (pull_request) Successful in 2m47s
CI / lint (pull_request) Successful in 56s
CI / vulncheck (pull_request) Successful in 46s

Click any sparkline character to see data point details — approximate
time, latency, and up/down status. Esc dismisses tooltip without
leaving detail view. Uses existing BubbleZone infrastructure with
zone-relative coordinate math for index resolution.
This commit was merged in pull request #97.
This commit is contained in:
2026-06-10 11:28:29 -04:00
parent 21a1563e53
commit f97ea3d66b
6 changed files with 152 additions and 18 deletions
+31
View File
@@ -139,3 +139,34 @@ func TestHeartbeatSparkline_PaddedWidth(t *testing.T) {
t.Errorf("should have dot padding for width > data, got %q", got)
}
}
func TestResolveSparklineIndex(t *testing.T) {
tests := []struct {
name string
x int
sparkWidth int
dataLen int
want int
}{
{"exact fit first", 0, 5, 5, 0},
{"exact fit last", 4, 5, 5, 4},
{"padding returns -1", 0, 10, 5, -1},
{"padding boundary", 4, 10, 5, -1},
{"first data after padding", 5, 10, 5, 0},
{"last data after padding", 9, 10, 5, 4},
{"truncated first visible", 0, 5, 20, 15},
{"truncated last visible", 4, 5, 20, 19},
{"single data point", 9, 10, 1, 0},
{"single data point on padding", 0, 10, 1, -1},
{"zero data", 0, 10, 0, -1},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := resolveSparklineIndex(tt.x, tt.sparkWidth, tt.dataLen)
if got != tt.want {
t.Errorf("resolveSparklineIndex(%d, %d, %d) = %d, want %d",
tt.x, tt.sparkWidth, tt.dataLen, got, tt.want)
}
})
}
}