Files
magpie/internal/gui/plugin_arrange_test.go
T
yetone 16ed1a9524 gui: a setting's hint card starts at the pointer, not at the row's name (mmmg_btc on X)
Resting the pointer on Settings › About's 更新内容 row put the hint at the
far left of the row. 5710283da lined its text up with the row's name; the
pointer is what asked, so settingshints.js now keeps the pointer's x and a
card the pointer asked starts there (12px left of it, kept 16px inside the
window), with its grow-from origin at the pointer. A card a key asked
(focus) still lines up with the name. Every row hint comes through this one
module (Settings, a provider editor's fields, Routing groups), so they all
behave the same; native titles already show at the pointer.

Run on mote: provider-prefs-layout (card at the pointer; red on the old
code, 5 of 10), editor-hints, settings-hints (its pointer and key checks
changed), searcher-pick, settings-lines-wrap, sign-in-moves, and the gui-*
and i18n-* files, chromium and webkit; TestCoreScriptBudget; gofmt.
Reds: settings-hints "Settings' explanations show on hover and focus"
(chromium and webkit) fails the same way on base before reaching the
changed lines ("the card doesn't say the row's line"), and editor-hints in
webkit ("Tab didn't come back") fails on base too; both are filed.
Not tried: a live Mac window.
2026-11-11 04:45:46 -08:00

42 lines
1.3 KiB
Go

package gui
import (
"net/http"
"net/http/httptest"
"path/filepath"
"slices"
"strings"
"testing"
"github.com/yetone/magpie/internal/settings"
)
// The sidebar's plugin pages are listed in the order they were dragged to
// (0lVeer on X), and a save of the Settings page leaves that order be.
func TestPluginPagesArrangeKept(t *testing.T) {
h := t.TempDir()
t.Setenv("HOME", h)
t.Setenv("USERPROFILE", h)
t.Setenv("XDG_CONFIG_HOME", filepath.Join(h, ".config"))
t.Setenv("XDG_CACHE_HOME", filepath.Join(h, ".cache"))
t.Setenv("APPDATA", filepath.Join(h, "AppData", "Roaming"))
t.Setenv("LOCALAPPDATA", filepath.Join(h, "AppData", "Local"))
post := func(path, body string) {
t.Helper()
rec := httptest.NewRecorder()
Handler(nil, nil).ServeHTTP(rec, httptest.NewRequest("POST", path, strings.NewReader(body)))
if rec.Code != http.StatusOK {
t.Fatalf("%s: %d %s", path, rec.Code, rec.Body)
}
}
post("/api/plugin-pages/arrange", `{"order":["plugin-b"," plugin-b","plugin-a"]}`)
want := []string{"plugin-b", "plugin-a"}
if got := settings.Load().PluginPageOrder; !slices.Equal(got, want) {
t.Fatalf("order %v, want %v", got, want)
}
post("/api/settings", `{"theme":"dark"}`)
if got := settings.Load().PluginPageOrder; !slices.Equal(got, want) {
t.Fatalf("a Settings save left %v, want %v", got, want)
}
}