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 / screenbars_test.go
screenbars_test.go 3.3K
1package e2e23import (4 "os"5 "path/filepath"6 "testing"7)89// scoresBook is a class's scores with the rules that draw their own:10// data bars on the points, arrows on the change, circles on the grade,11// the top two in green, duplicate names marked, a dropdown shown as12// chips and a checkbox of its own values.13const scoresBook = `{14 "version": 2,15 "widths": {"A": 10, "B": 9, "C": 9, "D": 8, "E": 10, "F": 8},16 "cells": {17 "A1": {"input":"Name","bold":true},18 "B1": {"input":"Points","bold":true,"align":"right"},19 "C1": {"input":"Change","bold":true,"align":"right"},20 "D1": {"input":"Grade","bold":true,"align":"right"},21 "E1": {"input":"Track","bold":true},22 "F1": {"input":"Passed","bold":true},23 "A2": "Ada", "B2": "92", "C2": "12", "D2": "4", "E2": "Math", "F2": "Yes",24 "A3": "Bo", "B3": "48", "C3": "-8", "D3": "2", "E3": "Art", "F3": "No",25 "A4": "Cy", "B4": "75", "C4": "3", "D4": "3", "E4": "Math", "F4": "Yes",26 "A5": "Bo", "B5": "30", "C5": "-2", "D5": "1", "F5": "No",27 "A6": "Dee", "B6": "100", "C6": "15", "D6": "5", "E6": "Music", "F6": "Yes"28 },29 "conditionalFormats": [30 {"ranges":"B2:B6","dataBar":{"color":"blue","min":{"type":"min"},"max":{"type":"max"}}},31 {"ranges":"C2:C6","iconSet":{"icons":"arrows","points":[{"type":"percent","value":"33"},{"type":"percent","value":"67"}]}},32 {"ranges":"D2:D6","iconSet":{"icons":"circles","points":[{"type":"percent","value":"20"},{"type":"percent","value":"40"},{"type":"percent","value":"60"},{"type":"percent","value":"80"}],"iconOnly":true}},33 {"ranges":"A2:A6","condition":"duplicate","text":"magenta","italic":true}34 ],35 "validations": [36 {"ranges":"E2:E6","criteria":"list","items":["Math","Art","Music"],"display":"chip"},37 {"ranges":"F2:F6","criteria":"checkbox","items":["Yes","No"]}38 ]39}40`4142func scoresFile(t *testing.T, dir string) {43 if err := os.WriteFile(filepath.Join(dir, "scores.012"), []byte(scoresBook), 0o644); err != nil {44 t.Fatal(err)45 }46}4748// openScores opens the scores.49func openScores(s *session) {50 s.keys("<ctrl+o>")51 s.waitFor("Open file:")52 s.keys("scores", "<enter>")53 s.waitFor("Dee")54}5556var barScreens = []screen{57 {name: "rules-bars", files: scoresFile, setup: func(s *session) {58 openScores(s)59 s.keys("<down>", "<down>", "<right>", "<right>", "<right>", "<right>")60 s.waitForBar("E3", "Art")61 }},62 {name: "rules-bars-high-contrast", opts: options{config: highContrastConfig}, files: scoresFile, setup: func(s *session) {63 openScores(s)64 s.keys("<down>", "<down>", "<right>", "<right>", "<right>", "<right>")65 s.waitForBar("E3", "Art")66 }},67 {name: "rules-editor-bar", files: scoresFile, setup: func(s *session) {68 openScores(s)69 s.keys("<ctrl+k>", "conditional formatting", "<enter>")70 s.waitFor("Conditional format rules")71 s.keys("<down>", "<enter>")72 s.waitFor("Show bar only")73 }},74 {name: "rules-editor-icons", files: scoresFile, setup: func(s *session) {75 openScores(s)76 s.keys("<ctrl+k>", "conditional formatting", "<enter>")77 s.waitFor("Conditional format rules")78 s.keys("<down>", "<down>", "<enter>")79 s.waitFor("Reverse icons")80 }},81}8283func init() {84 for _, sc := range barScreens {85 screens = append(screens, sc)86 if sc.name == "rules-bars" || sc.name == "rules-editor-icons" {87 sc.name += "-light"88 sc.opts.light = true89 screens = append(screens, sc)90 }91 }92}