summaryrefslogtreecommitdiff
path: root/internal/tui/flamegraph/renderer_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-09 07:54:33 +0200
committerPaul Buetow <paul@buetow.org>2026-03-09 07:54:33 +0200
commit1277f03a01fafd5ce7931bf9d48dc92f089c6894 (patch)
tree9a6b779b7f81f1b9bbdf876c5831830e7a95ee3c /internal/tui/flamegraph/renderer_test.go
parente43701561ddd4da60bee5cddbdc974d6811f3b79 (diff)
tui: fix flamegraph click re-rooting
Diffstat (limited to 'internal/tui/flamegraph/renderer_test.go')
-rw-r--r--internal/tui/flamegraph/renderer_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/tui/flamegraph/renderer_test.go b/internal/tui/flamegraph/renderer_test.go
index 7adc82d..354b40a 100644
--- a/internal/tui/flamegraph/renderer_test.go
+++ b/internal/tui/flamegraph/renderer_test.go
@@ -294,6 +294,37 @@ func TestRenderTerminalViewFilterKeepsNonMatchingBranchesVisible(t *testing.T) {
}
}
+func TestBuildTerminalLayoutWithPathNormalizesZoomRootChildrenToFullWidth(t *testing.T) {
+ snapshot := &snapshotNode{
+ Name: "root",
+ Total: 100,
+ Children: []*snapshotNode{
+ {
+ Name: "zoom",
+ Total: 80,
+ Children: []*snapshotNode{
+ {Name: "left", Total: 10},
+ {Name: "right", Total: 10},
+ },
+ },
+ {Name: "other", Total: 20},
+ },
+ }
+
+ frames := buildTerminalLayoutWithPath(snapshot.Children[0], 120, 12, "root"+pathSeparator+"zoom")
+ left := mustFindFrame(t, frames, "root"+pathSeparator+"zoom"+pathSeparator+"left")
+ right := mustFindFrame(t, frames, "root"+pathSeparator+"zoom"+pathSeparator+"right")
+ if got := left.Width + right.Width; got != 120 {
+ t.Fatalf("expected zoom-root children to fill full width 120, got %d", got)
+ }
+ if left.Col != 0 {
+ t.Fatalf("expected left child to start at column 0, got %d", left.Col)
+ }
+ if right.Col != left.Width {
+ t.Fatalf("expected right child to start after left child, got %d want %d", right.Col, left.Width)
+ }
+}
+
func TestFilterSampleCoverageAvoidsDoubleCountingNestedMatches(t *testing.T) {
frames := []tuiFrame{
{Path: "root", Total: 100},