1package e2e23// Golden screens for tables: a banded table with its header styled and4// a formula reading it by column, the name asked for on converting, the5// column suggestions inside a table's brackets, and the list of tables;6// on a light terminal and in the high-contrast theme too.78// sales types six rows of sales under a header, makes them the table9// Sales with banded rows, and sums its Amount column beside it, the10// cursor left on a cell of the table.11func sales(s *session) {12 s.keys("Region", "<tab>", "Month", "<tab>", "Units", "<tab>", "Amount", "<enter>")13 for _, row := range [][]string{14 {"North", "Jan", "12", "480"}, {"South", "Jan", "7", "280"}, {"East", "Feb", "20", "800"},15 {"North", "Feb", "9", "360"}, {"West", "Mar", "15", "600"}, {"South", "Mar", "4", "160"},16 } {17 s.keys(row[0], "<tab>", row[1], "<tab>", row[2], "<tab>", row[3], "<enter>")18 }19 s.keys("<ctrl+home>", "<ctrl+alt+t>")20 s.waitFor("Name for the table of A1:D7")21 s.keys("Sales", "<enter>")22 s.waitFor("Sales is a table")23 s.keys("<esc>", "<ctrl+home>", "<right>", "<right>", "<right>", "<right>", "<right>")24 s.keys("Total", "<enter>", "=SUM(Sales[Amount])", "<enter>")25 s.keys("Per unit", "<enter>", "=F2/SUM(Sales[Units])", "<enter>")26 s.keys("<ctrl+home>", "<down>", "<down>", "<right>", "<right>", "<right>")27 s.waitFor("Table Sales, column Amount")28 s.keys("<ctrl+k>", "banded rows", "<enter>")29 s.waitFor("Table Sales, column Amount")30}3132var tableScreens = []screen{33 {name: "table", setup: sales},34 {name: "table-name", setup: func(s *session) {35 s.keys("Item", "<tab>", "Cost", "<enter>", "Rent", "<tab>", "1450", "<enter>", "<up>", "<ctrl+alt+t>")36 s.waitFor("Name for the table of A1:B2: Table1")37 }},38 {name: "table-suggest", setup: func(s *session) {39 sales(s)40 s.keys("<ctrl+home>", "<down>", "<down>", "<down>", "<down>", "<down>", "<down>", "<down>", "<down>", "<right>", "<right>", "<right>", "<right>", "<right>")41 s.keys("=AVERAGE(Sales[u")42 s.waitFor("Sales[Region, Month, Units, Amount]")43 }},44 {name: "tables-picker", setup: func(s *session) {45 sales(s)46 s.keys("<alt+d>")47 s.waitFor("Named ranges")48 s.keys("<esc>")49 s.keys("<ctrl+k>", "tables")50 s.waitFor("│ › tables")51 s.keys("<enter>")52 s.waitFor("F2 rename")53 }},54 {name: "table-narrow", opts: options{cols: 60, rows: 16}, setup: sales},55}5657func init() {58 light := map[string]bool{"table": true, "table-suggest": true, "tables-picker": true}59 for _, sc := range tableScreens {60 screens = append(screens, sc)61 if light[sc.name] {62 l := sc63 l.name += "-light"64 l.opts.light = true65 screens = append(screens, l)66 }67 if sc.name == "table" {68 hc := sc69 hc.name += "-high-contrast"70 hc.opts.config = highContrastConfig71 screens = append(screens, hc)72 }73 }74}