alextjy asked on Discord whether gateway keys can be reordered. They could not: the Gateway page listed them in the order caller-keys.json held them, and nothing changed that order. - access: a "move-key" action puts one key at a place in the list, under the same file lock as every other key change. Nothing else about the key changes, and the sharing key's mirror in settings is left alone (its pointer would otherwise land on another key). - GUI: the Gateway page's key rows are dragged the way search APIs' rows are (shared dragRows, a grip shown on hover only, Alt+Up/Down, the existing "Drag to reorder" title). A refused move puts the list back from the server. New strings in zh, zh-TW, ja and de. - CLI: `magpie gateway-key move <id> <place>` (from 1); list already prints the stored order. - Usage > Requests: the key filter lists keys in the user's order, removed keys after. The Overview stays a ranking by use. Run (worktree at14b451c11, then rebased on origin/main): - gofmt -l clean; go vet (darwin) on access, cli, usageapi, gui; GOOS=linux -tags nogui and GOOS=windows go vet on access, cli, usageapi (mote). - go test access, cli, usageapi: ok (mote). internal/gui: every test ok except the real-window AppKit tests #4125 lists (TestCoveredWindowStaysUp, TestPanelCloseHidesIt and 7 more), killed at their deadlines with pboard not running on mote. - Broken by hand: with move-key removed, TestMoveKeyKeepsOrder, TestGatewayKeyCLIMove and TestLedgerKeyFilterInKeyOrder go red; with the mirror exclusion removed and the filter left unsorted, TestMoveKeyKeepsOrder ("the sharing key's mirror moved") and TestLedgerKeyFilterInKeyOrder go red. - GUI (WSL): gateway-key-arrange 20/20 (chromium and webkit; en, zh, zh-TW, ja, de; 1100 and 420px). Red by hand: no arrange (20 red), grip always shown (chromium 10/10 red), drop commits nothing (webkit 10/10 red). - GUI (WSL), the 68 files the change can reach (every caller-keys fixture user, gateway-*, search-*, usage-ledger*, i18n-keys, gui-ja, gui-de, gui-zh-tw, key-page, phone-rows, api-key-*): 900/923. The reds were run again at origin/main43966a53fand fail the same there (api-key-theme webkit, gateway-key-limit webkit, gateway-key-models webkit, search-first, usage-ledger-open-settled, usage-ledger-ttft, usage-ledger), each filed: #3307, #3523, #4081, #3795, #4262, #3104/#1876, and #4489 (usage-ledger-ttft, new). phone-rows, search-keys and connect-snippet-shell reds of the first run passed when run again at the head. usage-ledger's "zh: request routing links" went red once at the head (Usage view position on return) and passed in the first run. At the rebased head (on2ac423f4f): TestCoreScriptBudget and the other Budget/I18n/Asset tests in internal/gui ok (mote); gateway-key-arrange, i18n-keys and gateway-caller-keys 27/28 in WSL. The red is gateway-caller-keys webkit en "wider than 560 right after the resize" (#3797, red alone on main). A probe of that file, printing the page width and any element past it, read 560/560 with nothing wider in both engines, in two runs beside the arrange file. Not tried: dragging in the real app (WebKitGTK, WKWebView, WebView2), the full Go suite (started after the push).
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package usageapi
|
|
|
|
import (
|
|
"path/filepath"
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/access"
|
|
"github.com/yetone/magpie/internal/usage"
|
|
)
|
|
|
|
// The Requests page's Gateway key filter lists the keys in the order the
|
|
// user gave them on the Gateway page (alextjy on Discord), not by what
|
|
// each used; a key removed since goes after them, as it came.
|
|
func TestLedgerKeyFilterInKeyOrder(t *testing.T) {
|
|
home := t.TempDir()
|
|
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
|
for _, name := range []string{"Laptop", "Phone", "CI"} {
|
|
if _, err := access.Update("add-key", access.Change{Name: name}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
keys, _ := access.List()
|
|
to := 0
|
|
if _, err := access.Update("move-key", access.Change{Key: keys[2].ID, Index: &to}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
g := func(id string) Group { return Group{Group: usage.Group{ID: id, CallerKeyID: id}} }
|
|
// by tokens, as the ledger ranks them: gone first, then Phone, Laptop, CI
|
|
got := inKeyOrder([]Group{g("gone"), g(keys[1].ID), g(keys[0].ID), g(keys[2].ID)})
|
|
var ids []string
|
|
for _, x := range got {
|
|
ids = append(ids, x.CallerKeyID)
|
|
}
|
|
if want := []string{keys[2].ID, keys[0].ID, keys[1].ID, "gone"}; !slices.Equal(ids, want) {
|
|
t.Fatalf("filter order %v, want CI, Laptop, Phone, then the removed key: %v", ids, want)
|
|
}
|
|
}
|