1package e2e23import (4 "path/filepath"5 "testing"6)78// Golden screens for following files: a log followed in its own sheet,9// the tab's live mark and a formula over the rows, the question of how10// many rows to keep, and a linked file that isn't there; the log and the11// missing file on a light terminal too.1213// appLog is a web server's log as a CSV file.14const appLog = `time,level,path,ms1509:14:02,info,/,121609:14:03,info,/login,481709:14:05,warn,/search,3101809:14:07,info,/cart,221909:14:08,error,/pay,12042009:14:10,info,/,92109:14:11,info,/orders,572209:14:13,warn,/search,2882309:14:14,info,/login,412409:14:16,info,/cart,192509:14:17,info,/,1126`2728func writeAppLog(t *testing.T, dir string) { writeText(t, filepath.Join(dir, "app.csv"), appLog) }2930// followLog follows app.csv in a new sheet, keeping its last 8 rows, and31// adds up their times beside it.32func followLog(s *session) {33 s.keys("Requests", "<enter>")34 s.keys("<ctrl+k>", "Import", "<enter>")35 s.waitFor("Type to filter, or a path")36 s.keys("app.csv", "<enter>")37 s.waitFor("Follow the file")38 s.keys("follow", "<enter>")39 s.waitFor("Follow app.csv:")40 s.keys("l")41 s.waitFor("Keep the last how many rows:")42 s.keys("8", "<enter>")43 s.waitFor("/orders")44 s.keys("<f5>", "F1", "<enter>", "Slowest", "<tab>", "=MAX(D:D)", "<enter>")45 s.keys("<f5>", "F2", "<enter>", "Errors", "<tab>", `=COUNTIF(B:B,"error")`, "<enter>")46 s.waitFor("1204")47}4849var followScreens = []screen{50 {name: "follow-log", files: writeAppLog, setup: followLog},51 {name: "follow-ask", files: writeAppLog, setup: func(s *session) { s.linkTableAsk("app.csv") }},52 {name: "follow-missing", files: func(t *testing.T, dir string) {53 writeText(t, filepath.Join(dir, "gone.012"),54 `{"version": 2, "cells": {"D1": "Nightly run"}, "regions": [{"name": "nightly", "at": "A1", "path": "nightly.csv"}]}`)55 }, setup: func(s *session) {56 s.keys("<ctrl+o>", "gone", "<enter>")57 s.waitFor("#REF!")58 s.waitFor("! nightly.csv: the file isn't there")59 }},60}6162// linkTableAsk links name at the active cell through the palette, up to63// the question of how many rows to keep.64func (s *session) linkTableAsk(name string) {65 s.t.Helper()66 s.keys("<ctrl+k>", "Link a table")67 s.waitFor("Link a table")68 s.keys("<enter>")69 s.waitFor("Type to filter, or a path")70 s.keys(name, "<enter>")71 s.waitFor("Follow " + name + ":")72}7374func init() {75 for _, sc := range followScreens {76 screens = append(screens, sc)77 if sc.name != "follow-ask" {78 light := sc79 light.name += "-light"80 light.opts.light = true81 screens = append(screens, light)82 }83 }84}