Navigation: review r2 fixes

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 13:04:05 -04:00
1 parent cfdccfec5c
commit 01f5c1ca08
16 files changed
+196 -31

No files matched your search

+23
View File
@@ -1,6 +1,7 @@
package mujica
import (
"fmt"
"testing"
"github.com/egoist/mygo/ui"
@@ -100,6 +101,28 @@ func TestCommandPaletteAnnouncesHighlight(t *testing.T) {
}
}
func TestCommandPaletteFilterRevealsHighlight(t *testing.T) {
var cmds []Command
for i := range 30 {
cmds = append(cmds, Command{ID: fmt.Sprint(i), Label: fmt.Sprintf("Command %02d", i), Keywords: []string{"royal"}})
}
open := true
tt := ui.NewTester(func(c *ui.Context) {
Use(c, Settings{})
CommandPalette(c, &open, cmds, CommandPaletteOptions{})
}, 800, 600)
tt.Key(0, ui.KeyUp) // wraps to the last, scrolling to the bottom
tt.Frame()
if r, _ := tt.Find("Command 00"); r.H > 0 {
t.Fatalf("list did not scroll to the end: first row at %+v", r)
}
tt.Type("royal")
tt.Frame()
if r, _ := tt.Find("Command 00"); r.H == 0 {
t.Fatal("highlighted first match is off screen after filtering")
}
}
func TestCommandPaletteEmptyClickEscape(t *testing.T) {
a := &paletteApp{open: true}
tt := ui.NewTester(a.view, 800, 600)