cat / 012
clone

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

main
012 / e2e / screenshare_test.go
screenshare_test.go 2.7K
1package e2e23import (4 "os"5 "path/filepath"6 "testing"7)89// Golden screens for a workbook shared over 012 serve: two others in it10// (their pointers in their colors, their initials on the row headers,11// the cells they just changed marked, their names on the status line),12// the list of who's here, an undo refused because another changed the13// cell since, and a follower in a one-writer room. The first is also14// recorded on a light terminal and in the high-contrast theme.1516// householdBudget is a small budget in budget.012.17func householdBudget(t *testing.T, dir string) {18 book := `{"version": 2, "cells": {"A1": "Household budget", "A3": "Rent", "B3": "1200", "A4": "Food", "B4": "450",19 "A5": "Power", "B5": "90", "A6": "Total", "B6": "=SUM(B3:B5)"}}`20 if err := os.WriteFile(filepath.Join(dir, "budget.012"), []byte(book), 0o644); err != nil {21 t.Fatal(err)22 }23}2425// bobAndCy are two others in the budget: bob changes the food line and26// moves to D4, cy adds a line and stays under it.27var bobAndCy = []peer{28 {user: "bob", keys: []string{"<down>", "<down>", "<down>", "<right>", "480", "<enter>", "<up>", "<right>", "<right>"}, sees: "1770"},29 {user: "cy", keys: []string{"<down>", "<down>", "<down>", "<down>", "<down>", "<down>", "Gym", "<enter>"}, sees: "Gym"},30}3132var shareScreens = []screen{33 {name: "share-who", user: "ann", ssh: []string{"budget.012"}, files: householdBudget, peers: bobAndCy, setup: func(s *session) {34 s.waitFor("Sharing budget.012 with bob and cy")35 s.keys("<ctrl+k>", "who's here", "<enter>")36 s.waitFor("Sheet1!D4")37 }},38 {name: "share-undo-refused", user: "ann", ssh: []string{"budget.012"}, files: householdBudget, peers: bobAndCy[:1], setup: func(s *session) {39 s.waitFor("Sharing budget.012 with bob")40 s.keys("<down>", "<down>", "<right>", "1300", "<enter>")41 s.waitFor("1870")42 bob := s.peers[0]43 bob.waitFor("1870")44 bob.keys("<left>", "<left>", "<up>", "1250", "<enter>")45 s.waitFor("1820")46 s.keys("<ctrl+z>")47 s.waitFor("Can't undo")48 }},49 {name: "share-follow", serve: []string{"--share", "view"}, user: "ann", ssh: []string{"budget.012"}, files: householdBudget, peers: bobAndCy[:1],50 setup: func(s *session) {51 s.waitFor("bob writes")52 s.keys("x")53 s.waitFor("bob writes here and you follow")54 }},55}5657func init() {58 presence := screen{name: "share-presence", user: "ann", ssh: []string{"budget.012"}, files: householdBudget, peers: bobAndCy, setup: func(s *session) {59 s.waitFor("Sharing budget.012 with bob and cy")60 }}61 light, hc := presence, presence62 light.name += "-light"63 light.opts.light = true64 hc.name += "-high-contrast"65 hc.opts.config = highContrastConfig66 screens = append(screens, presence, light, hc)67 screens = append(screens, shareScreens...)68}