cat / 012
clone

a spreadsheet for the terminal: lotus 1-2-3 looks, google sheets keys and formulas, one go binary

cat/module-path
012 / e2e / shell_test.go
shell_test.go 2.1K
1package e2e23import (4 "os"5 "path/filepath"6 "strings"7 "testing"89 ghostty "go.mitchellh.com/libghostty"10)1112// The app shell: menu bar, dropdowns, context menus, the command palette13// and the context-line confirmations.1415func TestAltFOpensFileMenuAndSaves(t *testing.T) {16 t.Parallel()17 dir := t.TempDir()18 s := start(t, dir)19 s.keys("42", "<enter>", "<alt+f>")20 s.waitFor("│ Save as")21 s.waitFor("MENU")22 // "s" highlights Save (Save as also starts with s); Enter runs it.23 s.keys("s", "<enter>")24 s.waitFor("Save as: SHEET1.012")25 s.keys("<enter>")26 s.eventually("saved file", func() bool {27 _, err := os.Stat(filepath.Join(dir, "SHEET1.012"))28 return err == nil29 })30 s.waitFor("READY")31}3233func TestMenuSetsColumnWidth(t *testing.T) {34 t.Parallel()35 s := start(t, "")36 s.keys("<alt+o>", "c", "<enter>", "20", "<enter>")37 s.waitFor("READY")38 s.eventually("wider column A", func() bool { return strings.HasPrefix(s.line(3), strings.Repeat(" ", 6)+strings.Repeat(" ", 9)+"A") })39}4041func TestPaletteSearchAndRun(t *testing.T) {42 t.Parallel()43 s := start(t, "")44 s.keys("<ctrl+k>")45 s.waitFor("Search the menus")46 s.keys("goto")47 s.waitFor("│ › goto")48 s.keys("<enter>")49 s.waitFor("Go to: A1")50 s.keys("C5", "<enter>")51 s.waitForBar("C5", "")52}5354func TestRightClickColumnMenu(t *testing.T) {55 t.Parallel()56 s := start(t, "")57 // Right-click column C's header: it selects the column and opens the58 // column menu under the mouse.59 x := 6 + 2*10 + 460 s.click(ghostty.MouseButtonRight, x, 3)61 s.waitFor("│ Resize column")62 s.waitFor(" C:C")63 s.keys("<esc>")64 s.waitFor("READY")6566 // Clicking an item runs it.67 s.click(ghostty.MouseButtonRight, x, 3)68 s.waitFor("│ Resize column")69 for y, l := range strings.Split(s.screen(), "\n") {70 if strings.Contains(l, "│ Resize column") {71 s.click(ghostty.MouseButtonLeft, x+3, y)72 }73 }74 s.waitFor("Column width (1-240): 10")75}7677func TestQuitAsksAboutUnsavedChanges(t *testing.T) {78 t.Parallel()79 s := start(t, "")80 s.keys("1", "<enter>", "<ctrl+q>")81 s.waitFor("You have unsaved changes.")82 s.keys("<esc>")83 s.waitFor("READY")84 s.keys("<ctrl+q>", "d")85 s.waitExit()86}