summaryrefslogtreecommitdiff
path: root/internal/tui/flamegraph/renderer_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-05 22:31:23 +0200
committerPaul Buetow <paul@buetow.org>2026-03-05 22:31:23 +0200
commitc432bae0f3afaa05766ca8fcb1a3916f67d747a1 (patch)
tree5b61c01773a56dea1290f45845fb52bfdee66422 /internal/tui/flamegraph/renderer_test.go
parent63b9ad7c7692b3bedb4d0051c080946e38e058f9 (diff)
task 356: implement flamegraph terminal view renderer
Diffstat (limited to 'internal/tui/flamegraph/renderer_test.go')
-rw-r--r--internal/tui/flamegraph/renderer_test.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/internal/tui/flamegraph/renderer_test.go b/internal/tui/flamegraph/renderer_test.go
index 33d902f..32f260f 100644
--- a/internal/tui/flamegraph/renderer_test.go
+++ b/internal/tui/flamegraph/renderer_test.go
@@ -108,6 +108,65 @@ func TestBuildTerminalLayoutUsesPathSeparatorAndColor(t *testing.T) {
}
}
+func TestRenderTerminalViewShowsNarrowMessage(t *testing.T) {
+ out := RenderTerminalView(nil, 50, 10, 0)
+ if !strings.Contains(out, "terminal too narrow") {
+ t.Fatalf("expected narrow terminal warning, got %q", out)
+ }
+}
+
+func TestRenderTerminalViewIncludesToolbarAndStatus(t *testing.T) {
+ snapshot := &snapshotNode{
+ Name: "root",
+ Total: 10,
+ Children: []*snapshotNode{
+ {Name: "child", Total: 10},
+ },
+ }
+ frames := BuildTerminalLayout(snapshot, 80, 6)
+
+ out := RenderTerminalView(frames, 80, 6, 1)
+ if !strings.Contains(out, "Flame | frames:2") {
+ t.Fatalf("expected toolbar to include frame count, got %q", out)
+ }
+ if !strings.Contains(out, "Selected: child") {
+ t.Fatalf("expected status line to show selected frame, got %q", out)
+ }
+}
+
+func TestRenderTerminalViewShowsDeepLevelTruncationHint(t *testing.T) {
+ snapshot := &snapshotNode{
+ Name: "root",
+ Total: 4,
+ Children: []*snapshotNode{
+ {
+ Name: "a",
+ Total: 4,
+ Children: []*snapshotNode{
+ {
+ Name: "b",
+ Total: 4,
+ Children: []*snapshotNode{
+ {
+ Name: "c",
+ Total: 4,
+ Children: []*snapshotNode{
+ {Name: "d", Total: 4},
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+ frames := BuildTerminalLayout(snapshot, 80, 10)
+ out := RenderTerminalView(frames, 80, 4, 0)
+ if !strings.Contains(out, "showing deepest levels") {
+ t.Fatalf("expected truncation hint in toolbar, got %q", out)
+ }
+}
+
func mustFindFrame(t *testing.T, frames []tuiFrame, path string) tuiFrame {
t.Helper()
for _, frame := range frames {