cat / 012
clone

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

main
012 / e2e / screenfiles_test.go
screenfiles_test.go 1.7K
1package e2e23import (4 "os"5 "path/filepath"6 "testing"7)89// Golden screens for files and settings: questions about replacing a10// file, restoring kept changes over ssh, and checking an API key.11var fileScreens = []screen{12 {name: "save-as-replace", files: func(t *testing.T, dir string) {13 if err := os.WriteFile(filepath.Join(dir, "budget.012"), []byte("A1 old\n"), 0o644); err != nil {14 t.Fatal(err)15 }16 }, setup: func(s *session) {17 budget(s)18 s.keys("<ctrl+s>", "budget", "<enter>")19 s.waitFor("budget.012 exists.")20 }},21 // Over ssh, a file whose changes a session kept when the server22 // stopped.23 {name: "recovery-offer", opts: options{startsOn: "were kept."}, ssh: []string{"budget.012"}, files: func(t *testing.T, dir string) {24 os.Mkdir(filepath.Join(dir, ".012-recovery"), 0o700)25 for path, a1 := range map[string]string{"budget.012": "Household budget 2025", ".012-recovery/budget-20260927-140203.012": "Household budget 2026"} {26 book := `{"version": 2, "cells": {"A1": "` + a1 + `", "A3": "Rent", "B3": "1200"}}`27 if err := os.WriteFile(filepath.Join(dir, path), []byte(book), 0o600); err != nil {28 t.Fatal(err)29 }30 }31 }, setup: func(s *session) {32 s.waitFor("Unsaved changes to budget.012 were kept.")33 }},34 // Nothing listens on port 1: the key is stored, and its check fails.35 {name: "api-key-check-failed", opts: options{env: []string{"TYPESAFE_BASE_URL=http://127.0.0.1:1"}}, setup: func(s *session) {36 s.keys("<alt+f>", "<up>", "<up>", "<right>", "<down>", "<down>", "<down>", "<down>")37 s.waitFor("Store the TypeSafe API key")38 s.keys("<enter>", "test-key", "<enter>")39 s.waitFor("Key saved, but the check failed")40 }},41}4243func init() { screens = append(screens, fileScreens...) }