ConatusMoon2222 asked whether a routing group can have a note. It couldn't: a group had an id and a name, nothing else of the user's. A group now has an optional one-line note (provider.Group.Note, "note" in providers.json). SaveGroup cleans it: whitespace and newlines run together, cut at 200 characters (in runes), and an empty one is no note. It is the user's own word and is never sent to an agent or a vendor. - Routing page: the note shows under the group's name as one muted, ellipsized line, the whole of it on hover, and only when there is one. The group editor has a Note field under Name (Enter saves, as in Name). Every save of the group sends it: the editor, a manual group's pick and a routing picked from the row, so none of them wipes it. - CLI: `magpie group set <id> note=...` (note= clears it), `magpie group add ... note=...`; `magpie group <id>` and the list print it. - TUI: N in a group's view edits it; the view shows it under the head. - A copy, a shared group, a backup (StoredGroups/RestoreGroups) and sync (Mirror) carry it: they move whole Group structs. TestGroupNote checks each. Two existing GUI tests clicked rows that the extra editor row pushed under the view's foot bar at 420px in WebKit, which doesn't scroll the page's own scroller to a click: group-defaults' reach() now counts in sight as above the foot bar, and group-unlists' openAdvanced wheels the summary into view as its other helpers do. Both passed on origin/main and failed on this change before the fix. Run (on mote, at this head rebased on origin/main): - go test ./internal/provider ./internal/cli ./internal/tui ./internal/gui: ok - gofmt -l: clean; go vet ./... darwin, GOOS=linux -tags nogui, GOOS=windows: ok - GUI, chromium + webkit: group-note (en, zh, zh-TW, ja, de, and 390px), every group-*, routing-group-*, routing-groups-*, settings-groups, routing-manual, routing-save*, routing-tag-whole, fallback-group and i18n-* file: 752 tests, 752 pass Broken by hand, each red: - SaveGroup without CleanNote, and the CLI's note= without it: TestGroupNote and TestGroupNoteCLI fail on the uncleaned note. - the editor's Save body without note: group-note fails (the typed note never posted). - the pick and route-tag bodies without note: group-note fails (the note wiped by a pick). Not tried: the real TUI by hand, the real app in Linux WebKitGTK, and Windows (the change has no OS-specific code; windows vet ran).
44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package cli
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// A routing group's note (ConatusMoon2222 on X) is set from the terminal
|
|
// with note=, given at add or set, shown by magpie group <id> and under its
|
|
// row in magpie groups, and cleared with note= empty, when nothing shows.
|
|
func TestGroupNoteCLI(t *testing.T) {
|
|
groupsHome(t)
|
|
if _, err := addGroup("Work", []string{"models=a/m", "note=for the office key"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if gs := storedGroups(t); len(gs) != 1 || gs[0]["note"] != "for the office key" {
|
|
t.Fatalf("stored: %v", gs)
|
|
}
|
|
if err := groupCmd([]string{"group", "set", "work", "note= weekdays\n only "}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if gs := storedGroups(t); gs[0]["note"] != "weekdays only" {
|
|
t.Fatalf("set: %v", gs)
|
|
}
|
|
out, err := stdoutOf(t, func() error { return groupCmd([]string{"group", "work"}) })
|
|
if err != nil || !strings.Contains(out, "note") || !strings.Contains(out, "weekdays only") {
|
|
t.Fatalf("show: %v\n%s", err, out)
|
|
}
|
|
out, err = stdoutOf(t, groups)
|
|
if err != nil || !strings.Contains(out, "weekdays only") {
|
|
t.Fatalf("list: %v\n%s", err, out)
|
|
}
|
|
if err := groupCmd([]string{"group", "set", "work", "note="}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if gs := storedGroups(t); gs[0]["note"] != nil {
|
|
t.Fatalf("cleared: %v", gs)
|
|
}
|
|
out, _ = stdoutOf(t, func() error { return groupCmd([]string{"group", "work"}) })
|
|
if strings.Contains(out, "note") {
|
|
t.Fatalf("a group without a note shows one:\n%s", out)
|
|
}
|
|
}
|