@@ -41,7 +41,7 @@ func TestThemeHotkeyCyclesAndWraps(t *testing.T) {
4141
4242func TestStyleHotkeyCyclesAndWraps (t * testing.T ) {
4343 model := New (nil , time .Minute )
44- for want := stylePie ; want < styleCount ; want ++ {
44+ for want := styleStopwatch ; want < styleCount ; want ++ {
4545 updated , _ := model .Update (key ('s' ))
4646 model = updated .(Model )
4747 if model .meterStyle != want {
@@ -175,8 +175,8 @@ func TestFooterButtonsSupportHoverAndMouseClicks(t *testing.T) {
175175
176176 updated , _ = model .Update (footerMouseMessage (t , model , footerButtonStyle , tea .MouseActionPress ))
177177 model = updated .(Model )
178- if model .meterStyle != stylePie {
179- t .Fatalf ("style click selected %d, want %d" , model .meterStyle , stylePie )
178+ if model .meterStyle != styleStopwatch {
179+ t .Fatalf ("style click selected %d, want %d" , model .meterStyle , styleStopwatch )
180180 }
181181
182182 updated , command = model .Update (footerMouseMessage (t , model , footerButtonRefresh , tea .MouseActionPress ))
@@ -192,6 +192,46 @@ func TestFooterButtonsSupportHoverAndMouseClicks(t *testing.T) {
192192 }
193193}
194194
195+ func TestFooterHitGeometryMatchesRenderedButtonsAcrossSizes (t * testing.T ) {
196+ for _ , test := range []struct {
197+ name string
198+ width , height int
199+ empty bool
200+ withError bool
201+ style meterStyleID
202+ }{
203+ {name : "compact" , width : 40 , height : 24 },
204+ {name : "standard" , width : 80 , height : 24 },
205+ {name : "large error" , width : 120 , height : 40 , withError : true },
206+ {name : "empty quota" , width : 80 , height : 24 , empty : true },
207+ {name : "empty stopwatch" , width : 80 , height : 24 , empty : true , style : styleStopwatch },
208+ } {
209+ t .Run (test .name , func (t * testing.T ) {
210+ model := New (stubFetcher {snapshot : codex .DemoSnapshot ()}, time .Minute )
211+ if ! test .empty {
212+ model .snapshot = codex .DemoSnapshot ()
213+ }
214+ model .loading = false
215+ model .width = test .width
216+ model .height = test .height
217+ model .meterStyle = test .style
218+ if test .withError {
219+ model .err = errors .New ("stale quota signal" )
220+ }
221+ layout := model .dashboardLayout ()
222+ for _ , id := range []footerButtonID {footerButtonTheme , footerButtonStyle , footerButtonRefresh , footerButtonQuit } {
223+ mouse := footerMouseMessage (t , model , id , tea .MouseActionMotion )
224+ if mouse .Y != layout .footerY + 1 {
225+ t .Errorf ("rendered footer y=%d, calculated y=%d" , mouse .Y , layout .footerY + 1 )
226+ }
227+ if got := model .footerButtonAt (mouse .X , mouse .Y ); got != id {
228+ t .Errorf ("hit button %d, want %d" , got , id )
229+ }
230+ }
231+ })
232+ }
233+ }
234+
195235func TestFooterButtonHotkeyFlashesAndLatestPulseWins (t * testing.T ) {
196236 model := New (stubFetcher {snapshot : codex .DemoSnapshot ()}, time .Minute )
197237 model .snapshot = codex .DemoSnapshot ()
0 commit comments