cat / 012
clone

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

main
012 / e2e / screensheets_test.go
screensheets_test.go 3.0K
1package e2e23import ghostty "go.mitchellh.com/libghostty"45// Golden screens for working across sheets: hiding a sheet and the list6// of hidden ones, sheet names in formula suggestions, and where File >7// Import puts a file.89// hideSummary builds the two-sheet budget and hides Summary from its10// tab's menu.11func hideSummary(s *session) {12 summary(s)13 s.click(ghostty.MouseButtonRight, tabX(s.t, s, "Summary"), int(s.rows)-1)14 s.waitFor("Hide sheet")15 s.keys("<down>", "<down>", "<down>", "<enter>")16 s.waitFor("Hid Summary")17}1819// traceHidden hides Sheet1 and traces the precedents of Summary!B1,20// which reads only Sheet1.21func traceHidden(s *session) {22 summary(s)23 s.click(ghostty.MouseButtonRight, tabX(s.t, s, "Sheet1"), int(s.rows)-1)24 s.waitFor("Hide sheet")25 s.keys("<down>", "<down>", "<down>", "<enter>")26 s.waitFor("Hid Sheet1")27 s.waitForBar("B1", "=Sheet1!B7*12")28 s.keys("<alt+,>")29 s.waitFor("Reads only Sheet1, a hidden sheet; View > Hidden sheets shows it")30}3132// importLocation opens the import location picker for budget.tsv on a33// spreadsheet with something in it.34func importLocation(s *session) {35 s.keys("Notes", "<enter>")36 openImportPicker(s)37 s.keys("tsv", "<enter>")38 s.waitFor("Import location")39}4041var sheetScreens = []screen{42 {name: "sheets-menu-hide", setup: func(s *session) {43 summary(s)44 s.click(ghostty.MouseButtonRight, tabX(s.t, s, "Summary"), int(s.rows)-1)45 s.waitFor("Hide sheet")46 s.keys("<down>", "<down>", "<down>")47 }},48 {name: "sheets-hidden", setup: hideSummary},49 {name: "sheets-hidden-picker", setup: func(s *session) {50 hideSummary(s)51 s.keys("<alt+v>", "<down>")52 s.waitFor("List the hidden sheets")53 s.keys("<enter>")54 s.waitFor("1 of 1")55 }},56 {name: "trace-hidden", setup: traceHidden},57 {name: "autocomplete-sheet", setup: func(s *session) {58 summary(s)59 s.keys("<ctrl+pgup>", "<down>", "<down>", "<down>", "=B7/sum")60 s.waitFor("│ Summary!")61 }},62 {name: "autocomplete-sheet-narrow", opts: options{cols: 60, rows: 16}, setup: func(s *session) {63 summary(s)64 s.keys("<ctrl+pgup>", "<down>", "<down>", "<down>", "=su")65 s.waitFor("│ Summary!")66 }},67 {name: "autocomplete-sheet-point", setup: func(s *session) {68 summary(s)69 s.keys("<down>", "<down>", "<left>", "Rent share", "<tab>", "=sh", "<tab>", "<up>")70 s.waitFor("POINT")71 }},72 {name: "import-location", files: importDir, setup: importLocation},73 {name: "import-location-narrow", opts: options{cols: 60, rows: 16}, files: importDir, setup: importLocation},74 {name: "import-new-sheets", files: importDir, setup: func(s *session) {75 s.keys("Notes", "<enter>")76 openImportPicker(s)77 s.keys("q3", "<enter>")78 s.waitFor("Import location")79 s.keys("<enter>")80 s.waitFor("Imported q3.xlsx as")81 }},82}8384func init() {85 light := map[string]bool{"sheets-hidden-picker": true, "autocomplete-sheet": true, "import-location": true}86 for _, sc := range sheetScreens {87 screens = append(screens, sc)88 if light[sc.name] {89 sc.name += "-light"90 sc.opts.light = true91 screens = append(screens, sc)92 }93 }94}