- commit
- 30ba8702c01f270151e5e1644febfedf51f303c4
- parent
- c763843914fa664858cccf0444d8354247d14516
- author
- Dami <dami.etoile@gmail.com>
- kind
- test risk score 0.8 of 3, Jev's estimate
| M | docs/ | 3 | ++- |
| M | e2e/ | 33 | ++++++++++++++++++++++++++++++ |
| M | internal/ | 3 | +++ |
@@ -51,7 +51,8 @@ What gets recorded:
5151 (`run("data.sort_range", answer={"by": [{"column": "B"}], "header": True})`),5252 the filter picker's values and condition, find and replace, the chart5353 editor, and the pivot editor, each as the dialog left things when you54- pressed Enter;54+ pressed Enter. These name columns, ranges and cells as they were, with55+ either kind of references;5556 - charts moved or resized, by keys or by dragging, as5657 `run("chart.edit", answer={"chart": 1, "at": "F3"})`, one call for a5758 move made in steps;@@ -98,3 +98,36 @@ func TestMacroFromAnotherComputerAsks(t *testing.T) {
9898 s.keys("<down>", "<ctrl+alt+shift+1>")9999 s.waitForBar("C4:D4", "Total")100100 }101+102+// TestMacroRecordsTheSortBar records the choices made in a dialog and103+// replays them.104+func TestMacroRecordsTheSortBar(t *testing.T) {105+ dir := t.TempDir()106+ s := start(t, dir, "book.012")107+ s.keys("Month", "<tab>", "Sales", "<enter>", "Jan", "<tab>", "30", "<enter>", "Feb", "<tab>", "10", "<enter>", "Mar", "<tab>", "20", "<enter>")108+ s.keys("<ctrl+home>", "<ctrl+k>", "record macro")109+ s.waitFor("Record macro")110+ s.keys("<enter>")111+ s.waitFor("Recording (absolute references)")112+ s.keys("<ctrl+k>", "sort range", "<enter>")113+ s.waitFor("Sort A2:B4 by A Month A→Z")114+ s.keys("<right>", "<space>", "<enter>")115+ s.waitFor("Sorted A2:B4 by B Z→A")116+ s.waitForLine(gridRow1+1, " 2 Jan 30")117+ s.keys("<ctrl+k>", "stop and save", "<enter>")118+ s.waitFor("Save macro as: Macro 1")119+ s.keys("Sort", "<enter>", "<enter>")120+ s.waitFor("Saved macro Sort")121+122+ // Undone, then replayed from the palette.123+ s.keys("<ctrl+z>")124+ s.waitForLine(gridRow1+1, " 2 Feb 10")125+ s.keys("<ctrl+k>", "sort", "<enter>")126+ s.waitFor("Ran Sort")127+ s.waitForLine(gridRow1+1, " 2 Jan 30")128+ s.keys("<ctrl+s>")129+ s.eventually("saved", func() bool {130+ data, err := os.ReadFile(filepath.Join(dir, "book.012"))131+ return err == nil && strings.Contains(string(data), `run(\"data.sort_range\", answer={\"by\": [{\"column\": \"B\", \"order\": \"desc\"}], \"header\": True})`)132+ })133+}@@ -3,6 +3,7 @@ package ui
33 import (44 "errors"55 "fmt"6+ "log/slog"67 "strconv"78 "strings"89 @@ -289,7 +290,9 @@ func (h scriptHost) Run(id string, answer *string) error {
289290 // choices, as a recording writes them.290291 func (h scriptHost) answered(c *command, text string) error {291292 m := h.m293+ span := m.spans.Start("command", slog.String("id", c.id)) // as runCommand times commands292294 cmd, err := c.answer(m, text)295+ span.End()293296 m.macros.cmds = append(m.macros.cmds, cmd)294297 if err != nil {295298 if m.overlay != nil {