@@ -18,44 +18,36 @@ func TestCalculateBodyHeight(t *testing.T) {
1818 wantMax int
1919 }{
2020 {
21- name : "empty content returns minimum height " ,
21+ name : "empty content fills available space " ,
2222 content : "" ,
2323 screenHeight : 50 ,
2424 screenWidth : 100 ,
25- wantMin : 8 ,
26- wantMax : 8 ,
25+ wantMin : 20 , // body fills available space (50 - overhead)
26+ wantMax : 50 ,
2727 },
2828 {
29- name : "single line returns minimum height " ,
29+ name : "single line fills available space " ,
3030 content : "hello world" ,
3131 screenHeight : 50 ,
3232 screenWidth : 100 ,
33- wantMin : 8 ,
34- wantMax : 8 ,
33+ wantMin : 20 ,
34+ wantMax : 50 ,
3535 },
3636 {
37- name : "multiple lines grows height" ,
38- content : "line1\n line2\n line3\n line4\n line5\n line6" ,
39- screenHeight : 50 ,
40- screenWidth : 100 ,
41- wantMin : 8 ,
42- wantMax : 8 ,
43- },
44- {
45- name : "many lines capped at max height (50% of screen)" ,
46- content : strings .Repeat ("line\n " , 50 ),
47- screenHeight : 50 ,
37+ name : "small screen uses minimum height" ,
38+ content : "" ,
39+ screenHeight : 20 ,
4840 screenWidth : 100 ,
49- wantMin : 8 , // at least minimum
50- wantMax : 14 , // (50-22)/2 = 14
41+ wantMin : 8 , // minimum height enforced
42+ wantMax : 20 ,
5143 },
5244 {
53- name : "long lines wrap and increase height " ,
54- content : strings . Repeat ( "a" , 200 ), // should wrap on ~76 char width
55- screenHeight : 50 ,
45+ name : "large screen fills more space " ,
46+ content : "" ,
47+ screenHeight : 100 ,
5648 screenWidth : 100 ,
57- wantMin : 8 ,
58- wantMax : 8 , // wrapped lines still within minimum
49+ wantMin : 50 , // more screen = more body space
50+ wantMax : 100 ,
5951 },
6052 }
6153
@@ -79,41 +71,37 @@ func TestCalculateBodyHeight(t *testing.T) {
7971func TestUpdateBodyHeightSetsHeight (t * testing.T ) {
8072 m := NewFormModel (nil , 100 , 50 , "" , nil )
8173
82- // Initially should have minimum height of 8
74+ // Should fill available space regardless of content
8375 m .updateBodyHeight ()
8476 // The textarea height is internal, so we just verify no panic
8577
86- // Add content and update
78+ // Add content and update - height stays the same (fills available space)
8779 m .bodyInput .SetValue ("line1\n line2\n line3\n line4\n line5" )
8880 m .updateBodyHeight ()
89- // Verify no panic and height should be 5
9081
91- // Verify that with large content, height is capped
82+ // Large content - height is the same (fills available space)
9283 m .bodyInput .SetValue (strings .Repeat ("line\n " , 100 ))
9384 m .updateBodyHeight ()
94- // Should be capped at max height (50% of screen)
9585}
9686
97- func TestMaxHeightIs50PercentOfScreen (t * testing.T ) {
87+ func TestBodyHeightFillsAvailableSpace (t * testing.T ) {
9888 screenHeights := []int {40 , 60 , 80 , 100 }
9989
10090 for _ , screenHeight := range screenHeights {
10191 t .Run ("screen_height_" + string (rune ('0' + screenHeight / 10 )), func (t * testing.T ) {
10292 m := NewFormModel (nil , 100 , screenHeight , "" , nil )
10393
104- // Add lots of content to trigger max height
105- m .bodyInput .SetValue (strings .Repeat ("line\n " , 100 ))
106-
10794 height := m .calculateBodyHeight ()
10895
109- // formOverhead is 22, so maxHeight = (screenHeight - 22) / 2
110- expectedMax := (screenHeight - 22 ) / 2
111- if expectedMax < 8 {
112- expectedMax = 8
96+ // Body should fill available space (screen minus overhead)
97+ // In advanced mode: boxChrome(6) + common(6) + advanced(10) = 22
98+ expectedHeight := screenHeight - 22
99+ if expectedHeight < 8 {
100+ expectedHeight = 8
113101 }
114102
115- if height > expectedMax {
116- t .Errorf ("height %d exceeds expected max %d for screen height %d" , height , expectedMax , screenHeight )
103+ if height != expectedHeight {
104+ t .Errorf ("height %d != expected %d for screen height %d" , height , expectedHeight , screenHeight )
117105 }
118106 })
119107 }
0 commit comments