zhujiu (Discord #feedback) asked for a 不再提示 on the question a tray Quit asks while agents go through magpie (8826a15ea), and a switch in Settings to turn it on and off again. - The question (quitask.js, an in-app sheet) has a "Don't ask again" checkbox above its buttons, unticked each time. It goes with the Quit chosen: Quit and Disconnect and quit post window/quit?now=1&noAsk=1, which saves settings.quitNoAsk (settings.SetQuitNoAsk, under the file lock) before quitting; a failed save keeps magpie open. Cancel saves nothing. - AskQuit quits at once when quitNoAsk is set (quitAtOnce); otherwise as before. The default is unchanged: it asks. - Settings › General has "Ask before quitting" On/Off (segs, app-only), after Open at login. settingsapi.Keys lists quitNoAsk, and Merge carries it when a save doesn't send it, so the tray panel or an older page can't turn the question back on. - zh, zh-TW, ja, de strings. Five app.js comments shortened to stay in the core script budget (no raise). Run at the pushed head (on origin/mainf95bacdfb), on mote: - gofmt clean; go vet darwin, linux, windows (nogui too). - go test internal/settings, internal/settingsapi ok; internal/gui -run "Budget|Quit" ok. - internal/cli: TestEveryRouteHasACommandOrIsNamed red for POST /api/usage/checkin-account, frome87140242, filed as #4826; this change adds no route. - GUI, chromium and webkit: quit-ask-setting (25: en, zh, zh-TW, ja, de at 1100 and 420), quit-ask (35), settings-general, settings-sections, settings-search, settings-tabs-stick, wsl-agents-setting, agent-prefs, i18n-keys, old-webkit, auto-backup, all pass. Broken by hand, each red: - api.go's noAsk ignored: TestQuitDontAskAgain "wasn't saved". - quitAtOnce not reading the setting: TestQuitDontAskAgain "still asks". - Merge carry dropped: TestQuitNoAskKeptUnlessSent. - SetQuitNoAsk saving false: TestSetQuitNoAsk. - quitask.js without &noAsk=1: quit-ask's two Don't ask again tests. Not tried: a real tray Quit with the box ticked in the built app on macOS, Windows or Linux; only the sheet in Playwright and the handler in Go. Not the whole GUI suite.
31 lines
972 B
Go
31 lines
972 B
Go
package settings
|
|
|
|
import "testing"
|
|
|
|
// A Quit asks first by default (zhujiu on Discord asked for a way not to
|
|
// be asked again); the question's "Don't ask again" sets QuitNoAsk alone,
|
|
// keeping what the user set elsewhere, and turns back off the same way.
|
|
func TestSetQuitNoAsk(t *testing.T) {
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
if Load().QuitNoAsk {
|
|
t.Fatal("a Quit doesn't ask by default")
|
|
}
|
|
s := Load()
|
|
s.Theme, s.NoBird = "dark", true
|
|
if err := Save(s); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := SetQuitNoAsk(true); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := Load(); !got.QuitNoAsk || got.Theme != "dark" || !got.NoBird {
|
|
t.Fatalf("after SetQuitNoAsk(true): quitNoAsk %v, theme %q, noBird %v", got.QuitNoAsk, got.Theme, got.NoBird)
|
|
}
|
|
if err := SetQuitNoAsk(false); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := Load(); got.QuitNoAsk || got.Theme != "dark" {
|
|
t.Fatalf("after SetQuitNoAsk(false): quitNoAsk %v, theme %q", got.QuitNoAsk, got.Theme)
|
|
}
|
|
}
|