1package e2e23import (4 "strings"5 "testing"67 ghostty "go.mitchellh.com/libghostty"8)910func TestNotes(t *testing.T) {11 t.Parallel()12 dir := t.TempDir()13 s := start(t, dir)14 s.keys("Rent", "<tab>", "1450", "<enter>", "<up>", "<right>")15 s.waitForName("B1")1617 // Insert > Note (Shift+F2): typed on the context line, Alt+Enter for18 // a new line.19 s.keys("<shift+f2>")20 s.waitFor("Note on B1:")21 s.keys("Due on the 1st", "<alt+enter>", "autopay", "<enter>")22 s.waitFor("Note Due on the 1st ↵ autopay")23 s.eventually("the note's mark", func() bool { return strings.Contains(s.line(gridRow1), "1450▝") })2425 // Hovering the cell from elsewhere shows the note in a box.26 s.keys("<left>")27 s.mouse(ghostty.MouseActionMotion, ghostty.MouseButtonUnknown, colX(1), gridRow1, 0)28 s.waitFor("┌─ Note ─")29 s.waitFor("│ autopay")3031 // It's saved with the sheet.32 s.keys("<ctrl+s>", "notes", "<enter>")33 s.eventually("saved", func() bool {34 return strings.Contains(s.line(29), "notes.012") && !strings.Contains(s.line(29), "modified")35 })36 s2 := start(t, dir, "notes.012")37 s2.keys("<right>")38 s2.waitFor("Note Due on the 1st ↵ autopay")39}4041func TestProtectedRange(t *testing.T) {42 t.Parallel()43 s := start(t, "")44 s.keys("Price", "<enter>", "10", "<enter>", "<up>", "<shift+up>")45 s.waitForName("A1:A2")4647 // Data > Protect sheets and ranges: protect the selection.48 s.keys("<alt+d>")49 s.waitFor("Protect sheets and ranges")50 s.keys("<esc>", "<ctrl+k>", "protect range", "<enter>")51 s.waitFor("Describe A1:A2 (optional):")52 s.keys("Prices", "<enter>")53 s.waitFor("A1:A2 is protected: edits to it ask first")5455 // Typing into it asks first; Esc backs out, Enter goes on.56 s.keys("<esc>", "9")57 s.waitFor("A1:A2 is protected.")58 s.waitFor("Enter Edit anyway")59 s.keys("<esc>")60 s.waitForBar("A2", "10")61 s.keys("9")62 s.waitFor("A1:A2 is protected.")63 s.keys("<enter>", "<enter>")64 s.waitForBar("A3", "")65 s.keys("<up>")66 s.waitForBar("A2", "9")6768 // Undo brings back the value, and outside the range nothing asks.69 s.keys("<ctrl+z>")70 s.waitForBar("A2", "10")71 s.keys("<right>", "5", "<enter>")72 s.waitForBar("B3", "")73}