gui: Settings is a page per part, under a tab each, the part kept in the address (#471: Settings is one long scroll of some 45 rows in 9 sections) — the page now opens with a tab list in the warm-ups' look (role=tablist, a tab each with aria-controls/aria-labelledby): General (appearance, language, text size, the icons, model names, login, Dock, session terminal), Usage (the menu bar's usage, refresh, logos, what usage shows, currency, number units, the two alerts, then the warm-up and check-in tabs), Network and sharing (proxy, local network), Models (images, web search), Privacy, Observability, Sync and backup, About; the part picked shows its rows alone. Every row, its id and what it saves are as they were; the duplicate heading of a one-section part and the Preferences heading are gone. The part is kept as ?view=settings&tab=<part> (dropped on any other view), so a reload or a link lands there, and remembered (magpie.settingsTab) for Settings opened again without one, as the tray's window/main?view=settings; an unknown one falls back to it. A part whose rows are all hidden on this system has no tab, and one picked falls back to the first shown. The arrows, Home and End move along the tabs, one in the Tab order; a click on a tab moves nothing on the page, the tabs staying where they were; a pill drawn while its part was hidden has its thumb put under its pick when shown (the warm-ups' fix, now shared). The tabs wrap to a line more when they don't fit (English in the 560x420 window, at 110 and 125%, a phone), no left-border stripe. The click hold also holds a click not yet held before taking the next (keys pressed within a frame on a tab list whose part shrank to the window: the second click was taken at the clamped top and the page stayed there). New strings General and Network and sharing are in i18n.js (常规, 网络与共享). Tests that reach a row now open or click its part: api-key-theme, currency, gateway-caller-keys, gateway-connect-keys, lan-docker, number-units, otel, redact-rule-row, s3-sync, search-api, settings-groups, sync-other-kind, tray-inuse, tray-logos, tray-usages, update-check, update-hide, usage-alert, webdav-settings-refresh, whats-new; those needing a scrolled page wheel a shorter window or in smaller steps, as a part is shorter than the whole page was. settings-sections.test.cjs (Chromium, WebKit, en, zh) fails without the change (10 of 10). go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (TestAccountProxy as on main); settings-sections, settings-groups, click-scroll, old-webkit, text-size and every settings test listed above pass.
This commit is contained in:
@@ -1910,6 +1910,15 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; }
|
||||
.warm-tabs button.on { color: var(--fg); background: var(--pill); }
|
||||
.warm-tabs button[hidden] { display: none; }
|
||||
.warm-panes { margin-bottom: 8px; }
|
||||
/* the page's parts (#471): a tab each at the top in the same look, a line
|
||||
more when they don't fit across (a narrow window, a larger text size),
|
||||
the part picked alone under them */
|
||||
#view-settings .set-head { height: auto; min-height: 26px; flex: none; }
|
||||
.set-tabs { flex-wrap: wrap; row-gap: 2px; min-width: 0; }
|
||||
.set-tabs button { flex: none; white-space: nowrap; }
|
||||
.set-page { flex: none; }
|
||||
.set-page[hidden] { display: none; }
|
||||
.set-page > .list:not(:last-child) { margin-bottom: 8px; }
|
||||
.row.pref { min-height: 50px; padding: 8px 12px 8px 14px; gap: 14px; }
|
||||
.row.pref .who { flex: 1 1 auto; }
|
||||
.row.pref .sub { margin-top: 2px; }
|
||||
|
||||
+88
-20
@@ -10712,29 +10712,27 @@ function setWarmTab(tab, remember) {
|
||||
b.setAttribute("aria-selected", String(on));
|
||||
b.tabIndex = on ? 0 : -1;
|
||||
$("#" + list).hidden = !on;
|
||||
// a pill drawn while its card was hidden measured nothing: its thumb is
|
||||
// put under the option picked, still, once the card is shown
|
||||
if (on) for (const th of $("#" + list).querySelectorAll(".segs > .thumb")) {
|
||||
const opt = th.parentElement.querySelector(":scope > .on");
|
||||
if (!opt || parseFloat(th.style.width) === opt.offsetWidth) continue;
|
||||
th.classList.add("still");
|
||||
th.style.transform = `translateX(${opt.offsetLeft}px)`;
|
||||
th.style.width = opt.offsetWidth + "px";
|
||||
void th.offsetWidth;
|
||||
th.classList.remove("still");
|
||||
}
|
||||
if (on) thumbsUnderPicks($("#" + list));
|
||||
}
|
||||
}
|
||||
{
|
||||
const tabs = $("#warmTabs");
|
||||
tabs.onclick = (e) => {
|
||||
const b = e.target.closest("button[data-warm]");
|
||||
if (b) setWarmTab(b.dataset.warm, true);
|
||||
};
|
||||
// the arrows, Home and End move along the tabs, as a tab list's do: the
|
||||
// tab reached is clicked, so the page is held as for a click
|
||||
// a pill drawn while its card was hidden measured nothing: its thumb is
|
||||
// put under the option picked, still, once the card is shown
|
||||
function thumbsUnderPicks(box) {
|
||||
for (const th of box.querySelectorAll(".segs > .thumb")) {
|
||||
const opt = th.parentElement.querySelector(":scope > .on");
|
||||
if (!opt || !opt.offsetParent || parseFloat(th.style.width) === opt.offsetWidth) continue;
|
||||
th.classList.add("still");
|
||||
th.style.transform = `translateX(${opt.offsetLeft}px)`;
|
||||
th.style.width = opt.offsetWidth + "px";
|
||||
void th.offsetWidth;
|
||||
th.classList.remove("still");
|
||||
}
|
||||
}
|
||||
// A tab list's keys: the arrows, Home and End move along its shown tabs,
|
||||
// and the tab reached is clicked, so the page is held as for a click
|
||||
function tabKeys(tabs, sel) {
|
||||
tabs.onkeydown = (e) => {
|
||||
const shown = [...tabs.querySelectorAll("button[data-warm]:not([hidden])")];
|
||||
const shown = [...tabs.querySelectorAll(sel + ":not([hidden])")];
|
||||
const i = shown.indexOf(document.activeElement);
|
||||
if (i < 0) return;
|
||||
const j = { ArrowLeft: i - 1, ArrowRight: i + 1, Home: 0, End: shown.length - 1 }[e.key];
|
||||
@@ -10746,6 +10744,69 @@ function setWarmTab(tab, remember) {
|
||||
b.click();
|
||||
};
|
||||
}
|
||||
{
|
||||
const tabs = $("#warmTabs");
|
||||
tabs.onclick = (e) => {
|
||||
const b = e.target.closest("button[data-warm]");
|
||||
if (b) setWarmTab(b.dataset.warm, true);
|
||||
};
|
||||
tabKeys(tabs, "button[data-warm]");
|
||||
}
|
||||
|
||||
// The Settings page is a page per part (#471: one long scroll of some 45
|
||||
// rows): a tab for each over them, in the warm-ups' look, its rows alone
|
||||
// under it. The part is kept in the address (?view=settings&tab=privacy) so
|
||||
// a reload comes back to it, and remembered for the window opened again.
|
||||
// A part with no row to show here (every one hidden on this system) has no
|
||||
// tab. A click on a tab, like every click, leaves the page where it is: the
|
||||
// tabs at the top stay where they were and the part comes in under them.
|
||||
const SET_TABS = ["general", "usage", "network", "models", "privacy", "otel", "sync", "about"];
|
||||
let setTab = "general";
|
||||
try { const k = localStorage.getItem("magpie.settingsTab"); if (SET_TABS.includes(k)) setTab = k; } catch {}
|
||||
let setShown = setTab; // the part shown: the one picked, or the first there
|
||||
// A part has a tab while a row of it shows: one not hidden itself nor within
|
||||
// it (a service's card under the warm-ups' tabs counts, picked or not). A
|
||||
// part not drawn yet, with no rows at all, keeps its tab.
|
||||
const partShows = (page) => {
|
||||
const rows = [...page.querySelectorAll(".row")];
|
||||
return !rows.length || rows.some((r) => {
|
||||
for (let n = r; n && n !== page; n = n.parentElement) if (n.hidden && !n.matches('[role="tabpanel"]')) return false;
|
||||
return true;
|
||||
});
|
||||
};
|
||||
function setSetTab(tab, remember) {
|
||||
if (remember) {
|
||||
setTab = tab;
|
||||
try { localStorage.setItem("magpie.settingsTab", tab); } catch {}
|
||||
}
|
||||
for (const id of SET_TABS) $("#setTab-" + id).hidden = !partShows($("#setPage-" + id));
|
||||
if (!SET_TABS.includes(tab) || $("#setTab-" + tab).hidden) tab = SET_TABS.find((id) => !$("#setTab-" + id).hidden) || "general";
|
||||
for (const id of SET_TABS) {
|
||||
const b = $("#setTab-" + id), on = id === tab;
|
||||
b.classList.toggle("on", on);
|
||||
b.setAttribute("aria-selected", String(on));
|
||||
b.tabIndex = on ? 0 : -1;
|
||||
$("#setPage-" + id).hidden = !on;
|
||||
if (on) thumbsUnderPicks($("#setPage-" + id));
|
||||
}
|
||||
setShown = tab;
|
||||
$("#setTabs").setAttribute("aria-label", t("Settings"));
|
||||
if (view === "settings") syncURL();
|
||||
}
|
||||
{
|
||||
const tabs = $("#setTabs");
|
||||
tabs.onclick = (e) => {
|
||||
const b = e.target.closest("button[data-set]");
|
||||
if (b) setSetTab(b.dataset.set, true);
|
||||
};
|
||||
tabKeys(tabs, "button[data-set]");
|
||||
// opened on a part (a reload, a link): that part, and remembered
|
||||
if (mode === "window" && params.get("view") === "settings" && SET_TABS.includes(params.get("tab"))) {
|
||||
setTab = params.get("tab");
|
||||
try { localStorage.setItem("magpie.settingsTab", setTab); } catch {}
|
||||
}
|
||||
setSetTab(setTab);
|
||||
}
|
||||
|
||||
function renderSettings() {
|
||||
const s = prefs;
|
||||
@@ -10856,6 +10917,8 @@ function renderSettings() {
|
||||
repo.title = "github.com/yetone/magpie";
|
||||
repo.onclick = () => api("open", { url: "https://github.com/yetone/magpie" }).catch(() => {});
|
||||
row(t("Community"), t("questions, ideas and feedback, on Discord or GitHub"), "", join, repo);
|
||||
// the parts' tabs, one gone whose rows are all hidden here
|
||||
setSetTab(setTab);
|
||||
}
|
||||
|
||||
function renderSessionTerminal(s, keep) {
|
||||
@@ -12038,6 +12101,10 @@ addEventListener("click", (e) => {
|
||||
purposeUntil = 0; // what came before the click (Space pressed on a button, a tremble) is no scroll
|
||||
const v = e.target.closest?.(".view");
|
||||
if (!v || v.hidden) { held = null; return; }
|
||||
// a click before a frame has held the one before it (a tab list's keys
|
||||
// pressed in quick turn) holds that one first: the page it shrank is put
|
||||
// back, so this one is taken where the reader left it, not at the top
|
||||
if (held?.v === v) hold(held);
|
||||
const chain = [];
|
||||
const from = e.target.closest?.("[data-unrolls]")?.parentElement || e.target;
|
||||
for (let n = from; n && n !== v; n = n.parentElement) {
|
||||
@@ -12085,6 +12152,7 @@ function syncURL() {
|
||||
const q = new URLSearchParams(location.search);
|
||||
if (view === "agents") q.delete("view"); else q.set("view", view);
|
||||
if (view === "providers" && typeof editing === "string") q.set("edit", editing); else q.delete("edit");
|
||||
if (view === "settings") q.set("tab", setShown); else q.delete("tab");
|
||||
const s = q.size ? "?" + q : location.pathname;
|
||||
if (s !== location.search) history.replaceState(null, "", s);
|
||||
}
|
||||
|
||||
@@ -1366,6 +1366,9 @@ const I18N = {
|
||||
|
||||
// settings
|
||||
"Preferences": "偏好",
|
||||
// the Settings page's parts, a tab each
|
||||
"General": "常规",
|
||||
"Network and sharing": "网络与共享",
|
||||
"Session terminal": "会话终端",
|
||||
"Used by the terminal button in Sessions; only apps registered for .command files appear": "用于会话列表中的终端按钮;仅显示已注册处理 .command 文件的应用",
|
||||
"System default ({name})": "系统默认({name})",
|
||||
|
||||
+141
-116
@@ -211,128 +211,153 @@
|
||||
<main class="view" id="view-plugins" hidden></main>
|
||||
|
||||
<main class="view" id="view-settings" hidden>
|
||||
<div class="row-head"><span class="label" data-t>Preferences</span></div>
|
||||
<div class="list prefs">
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Appearance</div><div class="sub om-hide" data-t>Light or dark, or whatever the system is showing</div><div class="sub om-only" data-t>Follows the Omarchy theme, as picked in Omarchy's menu</div></div>
|
||||
<div id="themeSegs" class="om-hide"></div><span class="om-only om-theme-name"></span>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Language</div><div class="sub" data-t>Applies at once, no restart</div></div>
|
||||
<div id="langSegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="textSizeRow">
|
||||
<div class="who"><div class="name" data-t>Text size</div><div class="sub" id="textSizeSub"></div></div>
|
||||
<div id="textSizeSegs"></div>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Tray icon</div><div class="sub" data-t>What clicking magpie’s icon in the menu bar or tray opens</div></div>
|
||||
<div id="traySegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="barIconRow" hidden>
|
||||
<div class="who"><div class="name" data-t>Bar icon</div><div class="sub" data-t>magpie’s icon beside Omarchy’s own in the bar; right-click opens the window</div></div>
|
||||
<div id="barIconSegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="trayUsageRow">
|
||||
<div class="who"><div class="name" data-t>Usage in the menu bar</div><div class="sub" id="trayUsageSub"></div></div>
|
||||
<div id="trayUsagePick"></div>
|
||||
</div>
|
||||
<div class="row pref" id="trayEveryRow" hidden>
|
||||
<div class="who"><div class="name" data-t>Menu bar refresh</div><div class="sub" data-t>How often the usage beside the icon is asked for again</div></div>
|
||||
<div id="trayEverySegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="trayLogosRow" hidden>
|
||||
<div class="who"><div class="name" data-t>Menu bar logos</div><div class="sub" data-t>Each subscription's logo before its numbers; off, the numbers alone with a thin line between subscriptions</div></div>
|
||||
<div id="trayLogosSegs"></div>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Usage shows</div><div class="sub" data-t>How much of each window is used, or how much is left, on the Usage page, the panel and the menu bar</div></div>
|
||||
<div id="quotaLeftSegs"></div>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Currency</div><div class="sub" id="currencySub"></div></div>
|
||||
<div id="currencySegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="unitsRow" hidden>
|
||||
<div class="who"><div class="name" data-t>Number units</div><div class="sub" data-t>How a large count of tokens or requests is shortened on the Usage page and the panel</div></div>
|
||||
<div id="unitsSegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="usageAlertRow">
|
||||
<div class="who"><div class="name" data-t>Usage alert</div><div class="sub" id="usageAlertSub"></div></div>
|
||||
<div id="usageAlertSegs" class="warm-at"></div>
|
||||
</div>
|
||||
<div class="row pref" id="balanceAlertRow">
|
||||
<div class="who"><div class="name" data-t>Low balance alert</div><div class="sub" id="balanceAlertSub"></div></div>
|
||||
<div id="balanceAlertSegs" class="warm-at"></div>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Provider in model names</div><div class="sub" data-t>Agents’ lists put each model’s provider after its name, or not after names you set</div></div>
|
||||
<div id="plainNamesSegs"></div>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Open at login</div><div class="sub" data-t>Start magpie in the tray when you log in, so agents find the gateway from the start</div></div>
|
||||
<div id="loginSegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="dockRow" hidden>
|
||||
<div class="who"><div class="name" data-t>Dock</div><div class="sub" data-t>Keep magpie in the Dock too, always or while its window is open, for Cmd-Tab and a menu bar too full to show its icon</div></div>
|
||||
<div id="dockSegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="sessionTerminalRow" hidden>
|
||||
<div class="who"><div class="name" data-t>Session terminal</div><div class="sub" data-t>Used by the terminal button in Sessions; only apps registered for .command files appear</div></div>
|
||||
<select id="sessionTerminalSelect" class="session-terminal-select" aria-label="Session terminal" data-ta></select>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Proxy</div><div class="sub" id="proxySub"></div></div>
|
||||
<div id="proxySegs" class="proxy-segs"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-head warm-head"><div class="warm-tabs" id="warmTabs" role="tablist">
|
||||
<button type="button" role="tab" id="warmTab-codex" data-warm="codex" aria-controls="codexWarmList">Codex</button>
|
||||
<button type="button" role="tab" id="warmTab-claude" data-warm="claude" aria-controls="claudeWarmList">Claude Code</button>
|
||||
<button type="button" role="tab" id="warmTab-wb" data-warm="wb" aria-controls="wbList" hidden>WorkBuddy</button>
|
||||
<div class="row-head set-head"><div class="warm-tabs set-tabs" id="setTabs" role="tablist" aria-label="Settings">
|
||||
<button type="button" role="tab" id="setTab-general" data-set="general" aria-controls="setPage-general" data-t>General</button>
|
||||
<button type="button" role="tab" id="setTab-usage" data-set="usage" aria-controls="setPage-usage" data-t>Usage</button>
|
||||
<button type="button" role="tab" id="setTab-network" data-set="network" aria-controls="setPage-network" data-t>Network and sharing</button>
|
||||
<button type="button" role="tab" id="setTab-models" data-set="models" aria-controls="setPage-models" data-t>Models</button>
|
||||
<button type="button" role="tab" id="setTab-privacy" data-set="privacy" aria-controls="setPage-privacy" data-t>Privacy</button>
|
||||
<button type="button" role="tab" id="setTab-otel" data-set="otel" aria-controls="setPage-otel" data-t>Observability</button>
|
||||
<button type="button" role="tab" id="setTab-sync" data-set="sync" aria-controls="setPage-sync" data-t>Sync and backup</button>
|
||||
<button type="button" role="tab" id="setTab-about" data-set="about" aria-controls="setPage-about" data-t>About</button>
|
||||
</div></div>
|
||||
<div class="warm-panes">
|
||||
<div class="list prefs" id="codexWarmList" role="tabpanel" aria-labelledby="warmTab-codex">
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Warm up on reset</div><div class="sub" id="warmSub"></div></div>
|
||||
<div id="warmSegs"></div>
|
||||
<section class="set-page" id="setPage-general" role="tabpanel" aria-labelledby="setTab-general">
|
||||
<div class="list prefs">
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Appearance</div><div class="sub om-hide" data-t>Light or dark, or whatever the system is showing</div><div class="sub om-only" data-t>Follows the Omarchy theme, as picked in Omarchy's menu</div></div>
|
||||
<div id="themeSegs" class="om-hide"></div><span class="om-only om-theme-name"></span>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Language</div><div class="sub" data-t>Applies at once, no restart</div></div>
|
||||
<div id="langSegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="textSizeRow">
|
||||
<div class="who"><div class="name" data-t>Text size</div><div class="sub" id="textSizeSub"></div></div>
|
||||
<div id="textSizeSegs"></div>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Tray icon</div><div class="sub" data-t>What clicking magpie’s icon in the menu bar or tray opens</div></div>
|
||||
<div id="traySegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="barIconRow" hidden>
|
||||
<div class="who"><div class="name" data-t>Bar icon</div><div class="sub" data-t>magpie’s icon beside Omarchy’s own in the bar; right-click opens the window</div></div>
|
||||
<div id="barIconSegs"></div>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Provider in model names</div><div class="sub" data-t>Agents’ lists put each model’s provider after its name, or not after names you set</div></div>
|
||||
<div id="plainNamesSegs"></div>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Open at login</div><div class="sub" data-t>Start magpie in the tray when you log in, so agents find the gateway from the start</div></div>
|
||||
<div id="loginSegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="dockRow" hidden>
|
||||
<div class="who"><div class="name" data-t>Dock</div><div class="sub" data-t>Keep magpie in the Dock too, always or while its window is open, for Cmd-Tab and a menu bar too full to show its icon</div></div>
|
||||
<div id="dockSegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="sessionTerminalRow" hidden>
|
||||
<div class="who"><div class="name" data-t>Session terminal</div><div class="sub" data-t>Used by the terminal button in Sessions; only apps registered for .command files appear</div></div>
|
||||
<select id="sessionTerminalSelect" class="session-terminal-select" aria-label="Session terminal" data-ta></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Daily warm-up</div><div class="sub" id="warmAtSub"></div></div>
|
||||
<div id="warmAtSegs" class="warm-at"></div>
|
||||
</section>
|
||||
<section class="set-page" id="setPage-usage" role="tabpanel" aria-labelledby="setTab-usage">
|
||||
<div class="list prefs">
|
||||
<div class="row pref" id="trayUsageRow">
|
||||
<div class="who"><div class="name" data-t>Usage in the menu bar</div><div class="sub" id="trayUsageSub"></div></div>
|
||||
<div id="trayUsagePick"></div>
|
||||
</div>
|
||||
<div class="row pref" id="trayEveryRow" hidden>
|
||||
<div class="who"><div class="name" data-t>Menu bar refresh</div><div class="sub" data-t>How often the usage beside the icon is asked for again</div></div>
|
||||
<div id="trayEverySegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="trayLogosRow" hidden>
|
||||
<div class="who"><div class="name" data-t>Menu bar logos</div><div class="sub" data-t>Each subscription's logo before its numbers; off, the numbers alone with a thin line between subscriptions</div></div>
|
||||
<div id="trayLogosSegs"></div>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Usage shows</div><div class="sub" data-t>How much of each window is used, or how much is left, on the Usage page, the panel and the menu bar</div></div>
|
||||
<div id="quotaLeftSegs"></div>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Currency</div><div class="sub" id="currencySub"></div></div>
|
||||
<div id="currencySegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="unitsRow" hidden>
|
||||
<div class="who"><div class="name" data-t>Number units</div><div class="sub" data-t>How a large count of tokens or requests is shortened on the Usage page and the panel</div></div>
|
||||
<div id="unitsSegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="usageAlertRow">
|
||||
<div class="who"><div class="name" data-t>Usage alert</div><div class="sub" id="usageAlertSub"></div></div>
|
||||
<div id="usageAlertSegs" class="warm-at"></div>
|
||||
</div>
|
||||
<div class="row pref" id="balanceAlertRow">
|
||||
<div class="who"><div class="name" data-t>Low balance alert</div><div class="sub" id="balanceAlertSub"></div></div>
|
||||
<div id="balanceAlertSegs" class="warm-at"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list prefs" id="claudeWarmList" role="tabpanel" aria-labelledby="warmTab-claude">
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Warm up on reset</div><div class="sub" id="claudeWarmSub"></div></div>
|
||||
<div id="claudeWarmSegs"></div>
|
||||
<div class="row-head warm-head"><div class="warm-tabs" id="warmTabs" role="tablist">
|
||||
<button type="button" role="tab" id="warmTab-codex" data-warm="codex" aria-controls="codexWarmList">Codex</button>
|
||||
<button type="button" role="tab" id="warmTab-claude" data-warm="claude" aria-controls="claudeWarmList">Claude Code</button>
|
||||
<button type="button" role="tab" id="warmTab-wb" data-warm="wb" aria-controls="wbList" hidden>WorkBuddy</button>
|
||||
</div></div>
|
||||
<div class="warm-panes">
|
||||
<div class="list prefs" id="codexWarmList" role="tabpanel" aria-labelledby="warmTab-codex">
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Warm up on reset</div><div class="sub" id="warmSub"></div></div>
|
||||
<div id="warmSegs"></div>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Daily warm-up</div><div class="sub" id="warmAtSub"></div></div>
|
||||
<div id="warmAtSegs" class="warm-at"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Daily warm-up</div><div class="sub" id="claudeWarmAtSub"></div></div>
|
||||
<div id="claudeWarmAtSegs" class="warm-at"></div>
|
||||
<div class="list prefs" id="claudeWarmList" role="tabpanel" aria-labelledby="warmTab-claude">
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Warm up on reset</div><div class="sub" id="claudeWarmSub"></div></div>
|
||||
<div id="claudeWarmSegs"></div>
|
||||
</div>
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Daily warm-up</div><div class="sub" id="claudeWarmAtSub"></div></div>
|
||||
<div id="claudeWarmAtSegs" class="warm-at"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list prefs" id="wbList" role="tabpanel" aria-labelledby="warmTab-wb">
|
||||
<div class="row pref" id="wbCheckinRow">
|
||||
<div class="who"><div class="name" data-t>Daily check-in</div><div class="sub" id="wbCheckinSub"></div></div>
|
||||
<div id="wbCheckinSegs"></div>
|
||||
<div class="list prefs" id="wbList" role="tabpanel" aria-labelledby="warmTab-wb">
|
||||
<div class="row pref" id="wbCheckinRow">
|
||||
<div class="who"><div class="name" data-t>Daily check-in</div><div class="sub" id="wbCheckinSub"></div></div>
|
||||
<div id="wbCheckinSegs"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-head"><span class="label" data-t>Local network</span></div>
|
||||
<div class="list prefs" id="lanList"></div>
|
||||
<div class="row-head"><span class="label" data-t>Images</span></div>
|
||||
<div class="list prefs" id="imagesList"></div>
|
||||
<div class="row-head"><span class="label" data-t>Web search</span></div>
|
||||
<div class="list prefs" id="searchList"></div>
|
||||
<div class="row-head"><span class="label" data-t>Privacy</span></div>
|
||||
<div class="list prefs" id="redactList"></div>
|
||||
<div class="row-head"><span class="label" data-t>Observability</span></div>
|
||||
<div class="list prefs" id="otelList"></div>
|
||||
<div class="row-head"><span class="label" data-t>Sync and backup</span></div>
|
||||
<div class="list prefs" id="syncList"></div>
|
||||
<div class="row-head"><span class="label" data-t>About</span></div>
|
||||
<div class="list prefs" id="about"></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="set-page" id="setPage-network" role="tabpanel" aria-labelledby="setTab-network">
|
||||
<div class="list prefs">
|
||||
<div class="row pref">
|
||||
<div class="who"><div class="name" data-t>Proxy</div><div class="sub" id="proxySub"></div></div>
|
||||
<div id="proxySegs" class="proxy-segs"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-head"><span class="label" data-t>Local network</span></div>
|
||||
<div class="list prefs" id="lanList"></div>
|
||||
</section>
|
||||
<section class="set-page" id="setPage-models" role="tabpanel" aria-labelledby="setTab-models">
|
||||
<div class="row-head"><span class="label" data-t>Images</span></div>
|
||||
<div class="list prefs" id="imagesList"></div>
|
||||
<div class="row-head"><span class="label" data-t>Web search</span></div>
|
||||
<div class="list prefs" id="searchList"></div>
|
||||
</section>
|
||||
<section class="set-page" id="setPage-privacy" role="tabpanel" aria-labelledby="setTab-privacy">
|
||||
<div class="list prefs" id="redactList"></div>
|
||||
</section>
|
||||
<section class="set-page" id="setPage-otel" role="tabpanel" aria-labelledby="setTab-otel">
|
||||
<div class="list prefs" id="otelList"></div>
|
||||
</section>
|
||||
<section class="set-page" id="setPage-sync" role="tabpanel" aria-labelledby="setTab-sync">
|
||||
<div class="list prefs" id="syncList"></div>
|
||||
</section>
|
||||
<section class="set-page" id="setPage-about" role="tabpanel" aria-labelledby="setTab-about">
|
||||
<div class="list prefs" id="about"></div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer class="foot">
|
||||
|
||||
@@ -418,7 +418,7 @@ light and dark; ARTIFACT_DIR gets screenshots at 100% and 150%.
|
||||
|
||||
`settings-groups.test.cjs` puts the Settings page's warm-ups and check-in
|
||||
under a tab per service (#124): Codex, Claude Code and WorkBuddy tabs where a
|
||||
heading would be, after Preferences, before Local network, Codex's picked to
|
||||
heading would be, in the Usage part after its list, Codex's picked to
|
||||
begin with and each showing its rows alone, named without the service; the
|
||||
last warm-up and today's check-in still on the short lines, no left-border
|
||||
stripe; a daily warm-up's time field only while it is on; each control
|
||||
@@ -429,6 +429,23 @@ where they were; the tab remembered across a reload, Codex's shown when the
|
||||
remembered WorkBuddy one is gone; the WorkBuddy tab only with an account
|
||||
signed in; in English and Chinese.
|
||||
|
||||
`settings-sections.test.cjs` checks the Settings page in parts (#471): a tab
|
||||
list at its top — General, Usage, Network and sharing, Models, Privacy,
|
||||
Observability, Sync and backup, About — each tab showing its part's rows
|
||||
alone, posting nothing and leaving the page and the tab where they were; a
|
||||
part's controls still posting what they did; one tab in the Tab order and
|
||||
the arrows, Home and End along them; the part kept in the address
|
||||
(?view=settings&tab=…) across a reload, out of it on another view, and
|
||||
remembered for Settings opened again without one; a link to a part opening
|
||||
on it. The tabs fit, on a line more where they must, in the 560×420 window
|
||||
at 100, 110 and 125% and in magpie web on a phone, nothing running off to
|
||||
the side. Chromium and WebKit, English and Chinese; ARTIFACT_DIR gets a
|
||||
screenshot of each size:
|
||||
|
||||
```sh
|
||||
node --test --test-concurrency=1 internal/gui/tests/settings-sections.test.cjs internal/gui/tests/settings-groups.test.cjs
|
||||
```
|
||||
|
||||
`update-check.test.cjs` checks the version row: the button stays, dimmed,
|
||||
through a check, a second click asks nothing, and the answer puts it back.
|
||||
A read still out cannot draw "checking" over that answer. A row drawn again
|
||||
|
||||
@@ -92,7 +92,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.locator("#modal").waitFor({ state: "hidden" });
|
||||
assert.equal(events.filter((e) => e.action === "rotate-key").length, 0);
|
||||
|
||||
await page.goto("http://magpie.test/?view=settings");
|
||||
await page.goto("http://magpie.test/?view=settings&tab=network");
|
||||
const on = page.locator("#lanList").getByRole("button", { name: "On", exact: true });
|
||||
await on.waitFor();
|
||||
const bounds = await on.boundingBox();
|
||||
@@ -115,15 +115,17 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.mouse.move(500, 400);
|
||||
await page.mouse.wheel(0, -5000);
|
||||
for (const choice of ["Dark", "Light", "System"]) {
|
||||
await page.locator("#setTab-general").click();
|
||||
await page.locator("#themeSegs").getByRole("button", { name: choice, exact: true }).click();
|
||||
await page.waitForFunction((want) => (document.documentElement.dataset.theme || "system") === want, choice.toLowerCase());
|
||||
await page.waitForFunction(() => !document.documentElement.classList.contains("theming"));
|
||||
await page.locator("#setTab-network").click();
|
||||
const { colors: c, elements: e } = await palette(page, { card: "#lanList", key: "#lanList .lan-url" });
|
||||
assert.equal(e.card.bg, c.card);
|
||||
assert.equal(e.key.color, c["fg-2"]);
|
||||
}
|
||||
await page.reload();
|
||||
await page.locator("#themeSegs button.on").waitFor();
|
||||
await page.locator("#themeSegs button.on").waitFor({ state: "attached" });
|
||||
assert.equal(await page.locator("#themeSegs button.on").textContent(), "System");
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
|
||||
@@ -94,6 +94,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
|
||||
// Settings: the currency row, its rate in the tooltip
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator("#setTab-usage").click();
|
||||
await page.locator("#currencySegs .opt").first().waitFor();
|
||||
const segs = page.locator("#currencySegs .opt");
|
||||
assert.equal(await segs.count(), 2);
|
||||
@@ -123,6 +124,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
// and back to Settings, ¥ CNY is still picked after a reload
|
||||
await page.reload();
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator("#setTab-usage").click();
|
||||
await page.locator("#currencySegs .opt").first().waitFor();
|
||||
assert.equal(await page.locator('#currencySegs .opt', { hasText: cny }).evaluate((b) => b.classList.contains("on")), true);
|
||||
|
||||
@@ -171,6 +173,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
|
||||
// Settings agrees
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator("#setTab-usage").click();
|
||||
await page.locator("#currencySegs .opt").first().waitFor();
|
||||
assert.equal(await page.locator("#currencySegs .opt", { hasText: cny }).evaluate((b) => b.classList.contains("on")), true);
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert(events.some((e) => e.action === "export" && e.query.includes("callerKey=laptop") && !e.query.includes("key=") && !e.query.includes("user=")));
|
||||
await page.reload();
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator("#setTab-network").click();
|
||||
const share = page.locator("#lanList").getByRole("button", { name: lang === "zh" ? "开启" : "On", exact: true });
|
||||
await share.waitFor();
|
||||
// Real wheel input lets the page remember the reader's scroll position.
|
||||
@@ -109,6 +110,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await confirmKeyAction(page, lanRow, w.remove);
|
||||
await page.waitForFunction(() => document.querySelectorAll("#gatewayKeys .acc[data-key]").length === 4);
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator("#setTab-network").click();
|
||||
await page.locator("#lanList .lan-address-row").waitFor();
|
||||
await page.locator("#lanList").getByRole("button", { name: lang === "zh" ? "关闭" : "Off", exact: true }).click();
|
||||
await page.locator("#lanList .lan-address-row").waitFor({ state: "detached" });
|
||||
|
||||
@@ -37,6 +37,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
}
|
||||
|
||||
await page.locator("#prefs").click();
|
||||
|
||||
await page.locator("#setTab-network").click();
|
||||
const on = page.locator("#lanList").getByRole("button", { name: w.on, exact: true });
|
||||
await on.waitFor();
|
||||
const bounds = await on.boundingBox();
|
||||
@@ -67,6 +69,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
};
|
||||
await page.route("**/api/caller-keys", lateList);
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator("#setTab-network").click();
|
||||
await page.locator("#lanList").waitFor();
|
||||
await page.locator("#nav").getByRole("button", { name: w.gateway, exact: true }).click();
|
||||
await started;
|
||||
@@ -166,6 +169,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await expectSecret("fixture-created-2");
|
||||
assert.equal(await page.locator("#connectKey code").textContent(), "Replacement");
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator("#setTab-network").click();
|
||||
await page.locator("#lanList .lan-address-row").waitFor();
|
||||
await page.locator("#lanList").getByRole("button", { name: w.off, exact: true }).click();
|
||||
await page.locator("#lanList .lan-address-row").waitFor({ state: "detached" });
|
||||
|
||||
@@ -77,13 +77,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
});
|
||||
|
||||
const open = async (lang, at, web, over) => {
|
||||
const page = await (await browser.newContext({ viewport: { width: 900, height: 700 }, reducedMotion: "reduce" })).newPage();
|
||||
const page = await (await browser.newContext({ viewport: { width: 900, height: 360 }, reducedMotion: "reduce" })).newPage();
|
||||
pages.push(page);
|
||||
page.setDefaultTimeout(5000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang, web, over));
|
||||
await page.goto(at + "/?view=settings");
|
||||
await page.goto(at + "/?view=settings&tab=network");
|
||||
await page.locator("#lanList .lan-address-text").waitFor();
|
||||
return { page, errors };
|
||||
};
|
||||
@@ -106,7 +106,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.locator("#view-settings").hover();
|
||||
for (let i = 0; i < 40; i++) {
|
||||
const box = await anthropic.boundingBox();
|
||||
if (box && box.y > 80 && box.y + box.height < 560) break;
|
||||
if (box && box.y > 80 && box.y + box.height < 340 && (await scroll()) > 0) break;
|
||||
await page.mouse.wheel(0, 120);
|
||||
await page.waitForTimeout(30);
|
||||
}
|
||||
|
||||
@@ -160,6 +160,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await rest(p, lang === "en", lang + " default");
|
||||
|
||||
await p.locator("#prefs").click();
|
||||
|
||||
await p.locator("#setTab-usage").click();
|
||||
await p.locator("#currencySegs .opt").first().waitFor();
|
||||
if (lang === "en") {
|
||||
assert.equal(await p.locator("#unitsRow").isHidden(), true, "no Number units row in English");
|
||||
|
||||
@@ -62,7 +62,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const page = await context.newPage();
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang, posts));
|
||||
await page.goto("http://magpie.test/?view=settings");
|
||||
await page.goto("http://magpie.test/?view=settings&tab=otel");
|
||||
await page.locator("#otelExportRow").waitFor();
|
||||
const off = lang === "zh" ? "关闭" : "Off";
|
||||
assert.equal(await page.locator("#otelExportRow .opt.on").textContent(), off);
|
||||
@@ -99,6 +99,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
p = await saved(() => page.locator("#otelMetricsRow .opt").nth(1).click(), 4);
|
||||
assert.equal(p.otel.metrics, true);
|
||||
assert.equal(await scroll(), before, "saving OTLP settings must not scroll");
|
||||
await page.locator("#setTab-usage").click();
|
||||
for (let i = 0; i < 60; i++) {
|
||||
const box = await page.locator("#currencySegs").boundingBox();
|
||||
if (box && box.y > 100 && box.y < 750) break;
|
||||
@@ -108,6 +109,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(p.otel.enabled, true);
|
||||
assert.equal(p.otel.endpoint, "https://collector.test/api/public/otel");
|
||||
assert.equal(p.otel.headers.Authorization, "Basic YWJjZA==");
|
||||
await page.locator("#setTab-otel").click();
|
||||
for (let i = 0; i < 60; i++) {
|
||||
const box = await page.locator("#otelExportRow").boundingBox();
|
||||
if (box && box.y > 100 && box.y < 650) break;
|
||||
|
||||
@@ -47,7 +47,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang));
|
||||
await page.goto("http://magpie.test/?view=settings");
|
||||
await page.goto("http://magpie.test/?view=settings&tab=privacy");
|
||||
const row = page.locator("#redactList .row.rule-row");
|
||||
await row.waitFor();
|
||||
await row.scrollIntoViewIfNeeded();
|
||||
|
||||
@@ -49,7 +49,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
test(`${engine} ${lang}: S3 sync settings`, async (t) => {
|
||||
const zh = lang === "zh";
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
const context = await browser.newContext({ viewport: { width: 900, height: 700 }, reducedMotion: "reduce" });
|
||||
const context = await browser.newContext({ viewport: { width: 900, height: 420 }, reducedMotion: "reduce" });
|
||||
const page = await context.newPage();
|
||||
const errors = [], posts = [];
|
||||
page.on("pageerror", (error) => errors.push(error.message));
|
||||
@@ -64,6 +64,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
|
||||
await page.goto("http://magpie.test/");
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator("#setTab-sync").click();
|
||||
const list = page.locator("#syncList");
|
||||
const first = list.locator(".row.pref").first();
|
||||
await first.waitFor({ state: "visible" });
|
||||
@@ -124,7 +125,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await form.locator("label.tick").first().click(); // path-style
|
||||
// the WebDAV address typed before is still there, and isn't sent;
|
||||
// going back and forth, the shorter form too, moves nothing
|
||||
// the fields filled scrolled the choice out of sight: wheeled back to it
|
||||
await page.mouse.move(450, 300);
|
||||
for (let i = 0; i < 40 && (await segTop()) < 40; i++) { await page.mouse.wheel(0, -40); await page.waitForTimeout(15); }
|
||||
await page.waitForTimeout(300);
|
||||
const at = await top();
|
||||
assert.ok(at > 0, "the settings page must still be scrolled");
|
||||
await form.locator(".segs .opt", { hasText: "WebDAV" }).click();
|
||||
await page.waitForTimeout(250);
|
||||
assert.equal(await top(), at, "picking WebDAV must not scroll the page");
|
||||
@@ -132,6 +138,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await form.locator(".segs .opt", { hasText: "S3" }).click();
|
||||
await page.waitForTimeout(250);
|
||||
assert.equal(await top(), at, "picking S3 again must not scroll the page");
|
||||
await toEnd(); // the save button, at the form's foot, wheeled into sight
|
||||
await save.click();
|
||||
await form.waitFor({ state: "detached" });
|
||||
assert.deepEqual(posts, [{ url: "s3://magpie-sync/team", user: "AKIDEXAMPLE", password: "s3cr3t", endpoint: "https://acct.r2.cloudflarestorage.com",
|
||||
|
||||
@@ -64,7 +64,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
const posted = [];
|
||||
await page.route("**/*", serve(lang, posted));
|
||||
await page.goto("http://magpie.test/?view=settings");
|
||||
await page.goto("http://magpie.test/?view=settings&tab=models");
|
||||
const list = page.locator("#searchList");
|
||||
const head = list.locator(".row.search-add");
|
||||
await head.waitFor();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// The Settings page's warm-ups and check-in, one section with a tab per
|
||||
// service (#124 Mrhe525: tabs rather than three stacked groups): after the
|
||||
// Preferences list, where a heading would be, the tabs Codex, Claude Code
|
||||
// service (#124 Mrhe525: tabs rather than three stacked groups): in the
|
||||
// Settings page's Usage part (#471), after its list, where a heading would
|
||||
// be, the tabs Codex, Claude Code
|
||||
// and WorkBuddy, and under them one card with the picked service's rows —
|
||||
// Codex's and Claude Code's Warm up on reset and Daily warm-up, WorkBuddy's
|
||||
// Daily check-in — the lines under them short, with how the last warm-up and
|
||||
@@ -61,11 +62,11 @@ function server(lang, posts, over) {
|
||||
|
||||
const L = {
|
||||
en: {
|
||||
prefs: "Preferences", lan: "Local network", reset: "Warm up on reset", daily: "Daily warm-up", checkin: "Daily check-in",
|
||||
reset: "Warm up on reset", daily: "Daily warm-up", checkin: "Daily check-in",
|
||||
on: "On", off: "Off", started: "last started", checked: "Ann checked in today +2, 3-day streak", tabs: "Warm-up and check-in",
|
||||
},
|
||||
zh: {
|
||||
prefs: "偏好", lan: "局域网", reset: "窗口重置时预热", daily: "每日定时预热", checkin: "每日自动签到",
|
||||
reset: "窗口重置时预热", daily: "每日定时预热", checkin: "每日自动签到",
|
||||
on: "开启", off: "关闭", started: "上次启动于", checked: "Ann 今日已签到 +2, 连续 3 天", tabs: "预热与签到",
|
||||
},
|
||||
};
|
||||
@@ -107,6 +108,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.route("**/*", server(lang, posts, over));
|
||||
const go = async () => {
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator("#setTab-usage").click();
|
||||
await page.locator("#warmSegs .opt").first().waitFor({ state: "attached" });
|
||||
};
|
||||
await page.goto("http://magpie.test/");
|
||||
@@ -124,19 +126,17 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
workbuddyCheckins: [{ user: "Ann", day: today, at: new Date().toISOString(), outcome: "claimed", credit: 2, streak: 3 }],
|
||||
});
|
||||
|
||||
// the headings, in order: the tabs where a heading would be, after
|
||||
// Preferences, before Local network
|
||||
const heads = await page.evaluate(() => [...document.querySelectorAll("#view-settings > .row-head:not([hidden])")]
|
||||
.map((h) => h.querySelector("#warmTabs") ? "tabs" : h.querySelector(".label")?.textContent));
|
||||
const at = heads.indexOf(w.prefs);
|
||||
assert(at >= 0, `Preferences heading: ${heads}`);
|
||||
assert.deepEqual(heads.slice(at, at + 3), [w.prefs, "tabs", w.lan]);
|
||||
// the Usage part: its list, then the tabs where a heading would be,
|
||||
// then the card
|
||||
const parts = await page.evaluate(() => [...document.querySelectorAll("#setPage-usage > *")]
|
||||
.map((h) => h.querySelector("#warmTabs") ? "tabs" : h.querySelector("#currencySegs") ? "usage" : h.className));
|
||||
assert.deepEqual(parts, ["usage", "tabs", "warm-panes"]);
|
||||
assert.deepEqual(await page.locator("#warmTabs [role=tab]:visible").allTextContents(), ["Codex", "Claude Code", "WorkBuddy"]);
|
||||
assert.equal(await page.locator("#warmTabs").getAttribute("role"), "tablist");
|
||||
assert.equal(await page.locator("#warmTabs").getAttribute("aria-label"), w.tabs);
|
||||
// no service rows left in Preferences
|
||||
for (const id of ["#warmSegs", "#warmAtSegs", "#claudeWarmSegs", "#claudeWarmAtSegs", "#wbCheckinSegs"]) {
|
||||
assert.equal(await page.locator("#view-settings .list.prefs").first().locator(id).count(), 0, id + " is out of the Preferences list");
|
||||
assert.equal(await page.locator("#setPage-usage > .list.prefs").first().locator(id).count(), 0, id + " is out of the Usage list");
|
||||
}
|
||||
|
||||
// Codex to begin with, its rows alone
|
||||
@@ -165,13 +165,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await page.locator("#warmAtSegs input.at").count(), 0);
|
||||
assert.equal(await page.locator("#claudeWarmAtSegs input.at").count(), 0);
|
||||
|
||||
// scrolled down (a real wheel) till the tabs are near the top: each
|
||||
// tab shows its rows alone, each control posts its setting, and
|
||||
// nothing moves the page
|
||||
await page.setViewportSize({ width: 900, height: 560 });
|
||||
// scrolled down (a real wheel), the Usage part not at its end (that
|
||||
// is the next test's): each tab shows its rows alone, each control
|
||||
// posts its setting, and nothing moves the page
|
||||
// (a window a little shorter than the part, the card in sight)
|
||||
const spare = await page.locator("#view-settings").evaluate((v) => v.scrollHeight - v.clientHeight);
|
||||
await page.setViewportSize({ width: 900, height: page.viewportSize().height + spare - 40 });
|
||||
await page.mouse.move(450, 200);
|
||||
const headTop = () => page.evaluate(() => document.querySelector("#warmTabs").getBoundingClientRect().top - document.querySelector("#view-settings").getBoundingClientRect().top);
|
||||
for (let i = 0; i < 60 && (await headTop()) > 40; i++) { await page.mouse.wheel(0, 40); await page.waitForTimeout(15); }
|
||||
await page.mouse.wheel(0, 20);
|
||||
await page.waitForTimeout(300);
|
||||
const before = await view(page);
|
||||
assert(before > 0, "the settings page must be long enough to scroll");
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// The Settings page in parts (#471: one long scroll of nine sections and
|
||||
// some 45 rows, the rarely used ones screens away): a tab list at the top —
|
||||
// General, Usage, Network and sharing, Models, Privacy, Observability, Sync
|
||||
// and backup, About — each tab showing its part's rows alone, so any section
|
||||
// is one click away once Settings is open. The part picked is kept in the
|
||||
// address (?view=settings&tab=…), so a reload lands on it, and remembered,
|
||||
// so the window opened again on Settings does too; a link with a tab opens
|
||||
// on it. The tabs are a tab list (role, aria-selected, one in the Tab
|
||||
// order, the arrows, Home and End move along them); a click or a key on one
|
||||
// never scrolls the page; a part's controls still post what they did. The
|
||||
// tabs fit — on a line more when they must — in the smallest window (560 x
|
||||
// 420) at 100, 110 and 125% text size and in magpie web on a phone, nothing
|
||||
// running off to the side. English and Chinese; no backend, the API is
|
||||
// faked here. ARTIFACT_DIR gets a screenshot of each size.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
|
||||
function settingsPayload(over) {
|
||||
return {
|
||||
theme: "light", lang: "en", tray: "panel", quotaLeft: false, currency: "usd", textSize: 100,
|
||||
dock: false, dockWindow: false, proxy: "", redact: false, redactPersonal: false, redactWords: [],
|
||||
codexWarmup: "", claudeWarmup: "", codexWarmAt: "", claudeWarmAt: "", workbuddyCheckin: false, noStats: false,
|
||||
trayUsage: "", trayUsageEvery: 3, vision: "", imageGen: "",
|
||||
version: "0.1.400", dir: "~/.config/magpie", gateway: "http://127.0.0.1:3425",
|
||||
proxyNow: "none", proxySource: "none", login: false,
|
||||
visionModels: [], imageGenModels: [], workbuddyCheckins: [], lanURLs: [],
|
||||
fx: { rate: 7.2, at: new Date().toISOString(), stale: false },
|
||||
...over,
|
||||
};
|
||||
}
|
||||
|
||||
function server(lang, posts, { web = false, size = 100 } = {}) {
|
||||
let cur = settingsPayload({ lang, textSize: size });
|
||||
return async (route) => {
|
||||
const req = route.request(), url = new URL(req.url());
|
||||
const json = (data) => route.fulfill({ json: data });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:${web},textSize:${size}};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light", textSize: size }, fx: cur.fx });
|
||||
if (url.pathname === "/api/settings") {
|
||||
if (req.method() === "POST") {
|
||||
const body = req.postDataJSON();
|
||||
posts.push(body);
|
||||
cur = { ...cur, ...body };
|
||||
}
|
||||
return json(cur);
|
||||
}
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
|
||||
if (url.pathname === "/api/window/fit") return route.fulfill({ status: 204 });
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
await route.fulfill({ body: await fs.readFile(file), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
const TABS = ["general", "usage", "network", "models", "privacy", "otel", "sync", "about"];
|
||||
const L = {
|
||||
en: ["General", "Usage", "Network and sharing", "Models", "Privacy", "Observability", "Sync and backup", "About"],
|
||||
zh: ["常规", "用量", "网络与共享", "模型", "隐私", "可观测性", "同步与备份", "关于"],
|
||||
};
|
||||
const LABEL = { en: "Settings", zh: "设置" };
|
||||
// what each part shows: an element of its own rows, drawn by the page
|
||||
const MARK = {
|
||||
general: "#themeSegs .opt", usage: "#currencySegs .opt", network: "#proxySegs", models: "#imagesList .row",
|
||||
privacy: "#redactList .row", otel: "#otelList .row", sync: "#syncList .row", about: "#about .row",
|
||||
};
|
||||
|
||||
// the tab picked, the parts shown, the tab focused, and the address's tab
|
||||
async function shown(page) {
|
||||
return page.evaluate(() => {
|
||||
const on = [...document.querySelectorAll("#setTabs [role=tab]")].filter((b) => b.getAttribute("aria-selected") === "true").map((b) => b.dataset.set);
|
||||
const parts = [...document.querySelectorAll("#view-settings > [role=tabpanel]")].filter((p) => p.getClientRects().length).map((p) => p.id.replace("setPage-", ""));
|
||||
const q = new URLSearchParams(location.search);
|
||||
return { on, parts, focus: document.activeElement?.dataset?.set || "", url: q.get("view") + "/" + q.get("tab") };
|
||||
});
|
||||
}
|
||||
const top = (page) => page.locator("#view-settings").evaluate((v) => v.scrollTop);
|
||||
// what runs off to the side: the page, the view, a tab past the view's edge
|
||||
const overflow = (page) => page.evaluate(() => {
|
||||
const out = [];
|
||||
const de = document.documentElement, v = document.querySelector("#view-settings");
|
||||
if (de.scrollWidth > de.clientWidth) out.push("page " + de.scrollWidth + ">" + de.clientWidth);
|
||||
if (v.scrollWidth > v.clientWidth) out.push("view " + v.scrollWidth + ">" + v.clientWidth);
|
||||
const r = v.getBoundingClientRect();
|
||||
for (const b of document.querySelectorAll("#setTabs [role=tab]")) {
|
||||
const br = b.getBoundingClientRect();
|
||||
if (br.left < r.left - 0.5 || br.right > r.right + 0.5) out.push("tab " + b.textContent);
|
||||
}
|
||||
return out;
|
||||
});
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
test(engine + ": Settings in parts, a tab each", async (t) => {
|
||||
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
const shots = [];
|
||||
t.after(async () => {
|
||||
if (process.env.ARTIFACT_DIR) {
|
||||
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
|
||||
for (const [name, buf] of shots) await fs.writeFile(path.join(process.env.ARTIFACT_DIR, `${engine}-settings-sections-${name}.png`), buf);
|
||||
}
|
||||
await browser.close();
|
||||
});
|
||||
const open = async (lang, posts, { width = 560, height = 420, zoom = 1, url = "/", web, size, ctx } = {}) => {
|
||||
const context = ctx || await browser.newContext({ viewport: { width, height }, deviceScaleFactor: zoom, reducedMotion: "reduce" });
|
||||
const page = await context.newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.errors = [];
|
||||
page.on("pageerror", (e) => page.errors.push(e.message));
|
||||
await page.route("**/*", server(lang, posts, { web, size }));
|
||||
await page.goto("http://magpie.test" + url);
|
||||
return page;
|
||||
};
|
||||
|
||||
for (const lang of ["en", "zh"]) {
|
||||
await t.test(lang + ": a tab per part, kept across a reload", async () => {
|
||||
const posts = [];
|
||||
const page = await open(lang, posts, { width: 900, height: 520 });
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator(MARK.general).first().waitFor();
|
||||
|
||||
// a tab list at the top of the page, before any part
|
||||
assert.equal(await page.locator("#setTabs").getAttribute("role"), "tablist");
|
||||
assert.equal(await page.locator("#setTabs").getAttribute("aria-label"), LABEL[lang]);
|
||||
assert.deepEqual((await page.locator("#setTabs [role=tab]:visible").allTextContents()).map((s) => s.trim()), L[lang]);
|
||||
assert.equal(await page.evaluate(() => document.querySelector("#view-settings").firstElementChild.contains(document.querySelector("#setTabs"))), true, "the tabs come first");
|
||||
assert.deepEqual(await shown(page), { on: ["general"], parts: ["general"], focus: "", url: "settings/general" });
|
||||
for (const id of TABS) {
|
||||
assert.equal(await page.locator("#setTab-" + id).getAttribute("aria-controls"), "setPage-" + id);
|
||||
assert.equal(await page.locator("#setPage-" + id).getAttribute("aria-labelledby"), "setTab-" + id);
|
||||
}
|
||||
// no coloured stripe down a tab's left side
|
||||
const stripes = await page.evaluate(() => [...document.querySelectorAll("#setTabs button, #view-settings .set-page")]
|
||||
.filter((e) => { const c = getComputedStyle(e); return c.borderLeftWidth !== c.borderRightWidth || c.borderLeftColor !== c.borderRightColor; }).length);
|
||||
assert.equal(stripes, 0, "no left-border accents");
|
||||
|
||||
// each tab shows its part alone, posts nothing, and moves nothing
|
||||
const tabY = (id) => page.locator("#setTab-" + id).evaluate((b) => b.getBoundingClientRect().top);
|
||||
for (const id of TABS) {
|
||||
const y0 = await tabY(id), posted = posts.length;
|
||||
await page.locator("#setTab-" + id).click();
|
||||
await page.waitForTimeout(200);
|
||||
const s = await shown(page);
|
||||
assert.deepEqual([s.on, s.parts, s.url], [[id], [id], "settings/" + id], id);
|
||||
assert(await page.locator(MARK[id]).first().isVisible(), id + ": its rows shown");
|
||||
for (const other of TABS) if (other !== id) assert.equal(await page.locator(MARK[other]).first().isVisible(), false, id + ": " + other + "'s rows hidden");
|
||||
assert.equal(await top(page), 0, id + ": the click must not scroll the page");
|
||||
assert(Math.abs((await tabY(id)) - y0) <= 1, id + ": the tab stays where it was");
|
||||
assert.equal(posts.length, posted, id + ": a tab posts nothing");
|
||||
}
|
||||
// the warm-ups are in Usage, still a tab each
|
||||
await page.locator("#setTab-usage").click();
|
||||
assert(await page.locator("#warmTab-codex").isVisible(), "the warm-ups under Usage");
|
||||
|
||||
// a part's control posts what it did
|
||||
await page.locator("#setTab-general").click();
|
||||
await page.locator("#themeSegs .opt").nth(2).click();
|
||||
for (let i = 0; i < 50 && !posts.length; i++) await page.waitForTimeout(40);
|
||||
assert.equal(posts.at(-1)?.theme, "dark", "the theme still saves");
|
||||
await page.locator("#setTab-usage").click();
|
||||
await page.locator("#currencySegs .opt").nth(1).click();
|
||||
for (let i = 0; i < 50 && posts.at(-1)?.currency !== "cny"; i++) await page.waitForTimeout(40);
|
||||
assert.equal(posts.at(-1).currency, "cny", "the currency still saves");
|
||||
|
||||
// the keyboard: one tab in the Tab order, the arrows, Home and End
|
||||
await page.locator("#setTab-privacy").click();
|
||||
assert.deepEqual(await page.locator("#setTabs [role=tab]").evaluateAll((bs) => bs.filter((b) => b.tabIndex === 0).map((b) => b.dataset.set)), ["privacy"]);
|
||||
await page.locator("#setTab-privacy").focus();
|
||||
await page.keyboard.press("ArrowRight");
|
||||
assert.deepEqual((await shown(page)).parts, ["otel"]);
|
||||
assert.equal((await shown(page)).focus, "otel");
|
||||
await page.keyboard.press("End");
|
||||
assert.deepEqual((await shown(page)).parts, ["about"]);
|
||||
await page.keyboard.press("ArrowRight");
|
||||
assert.deepEqual((await shown(page)).parts, ["general"]);
|
||||
await page.keyboard.press("ArrowLeft");
|
||||
assert.deepEqual((await shown(page)).parts, ["about"]);
|
||||
await page.keyboard.press("Home");
|
||||
assert.deepEqual((await shown(page)).parts, ["general"]);
|
||||
await page.keyboard.press("ArrowLeft");
|
||||
await page.keyboard.press("ArrowLeft");
|
||||
assert.deepEqual((await shown(page)).on, ["sync"]);
|
||||
assert.equal(await top(page), 0, "the keys move nothing");
|
||||
|
||||
// a reload comes back to the part
|
||||
await page.reload();
|
||||
await page.locator(MARK.sync).first().waitFor();
|
||||
assert.deepEqual(await shown(page), { on: ["sync"], parts: ["sync"], focus: "", url: "settings/sync" });
|
||||
|
||||
// another view leaves the tab out of the address; Settings again
|
||||
// brings it back
|
||||
await page.locator('#nav [data-view="usage"]').click();
|
||||
assert.equal(new URL(page.url()).searchParams.get("tab"), null);
|
||||
await page.locator("#prefs").click();
|
||||
assert.deepEqual((await shown(page)).url, "settings/sync");
|
||||
|
||||
// the window opened again on Settings (no tab in the address): the
|
||||
// part last picked
|
||||
const again = await open(lang, [], { url: "/?view=settings", ctx: page.context() });
|
||||
await again.locator(MARK.sync).first().waitFor();
|
||||
assert.deepEqual((await shown(again)).parts, ["sync"]);
|
||||
// a link to a part opens on it, and it is remembered
|
||||
const link = await open(lang, [], { url: "/?view=settings&tab=otel", ctx: page.context() });
|
||||
await link.locator(MARK.otel).first().waitFor();
|
||||
assert.deepEqual((await shown(link)).parts, ["otel"]);
|
||||
// one not known: the part remembered
|
||||
const bad = await open(lang, [], { url: "/?view=settings&tab=nope", ctx: page.context() });
|
||||
await bad.locator(MARK.otel).first().waitFor();
|
||||
assert.deepEqual((await shown(bad)).parts, ["otel"]);
|
||||
assert.deepEqual([...page.errors, ...again.errors, ...link.errors, ...bad.errors], []);
|
||||
});
|
||||
|
||||
await t.test(lang + ": the tabs fit the smallest window and a phone", async () => {
|
||||
const fits = async (page, what) => {
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator(MARK.general).first().waitFor();
|
||||
assert.deepEqual(await overflow(page), [], what + ": nothing runs off to the side");
|
||||
assert.equal(await page.locator("#setTabs [role=tab]:visible").count(), TABS.length, what + ": every tab shown");
|
||||
// the tabs take a few lines at most, and the part starts under them
|
||||
const h = await page.locator("#setTabs").evaluate((e) => e.getBoundingClientRect().height);
|
||||
assert(h <= 3 * 26, what + `: the tabs ${h}px tall`);
|
||||
const under = await page.evaluate(() => document.querySelector("#setPage-general").getBoundingClientRect().top - document.querySelector("#setTabs").getBoundingClientRect().bottom);
|
||||
assert(under >= 0, what + ": the part under the tabs");
|
||||
// the last tab, on the last line, reached with one click, moving nothing
|
||||
await page.locator("#setTab-about").click();
|
||||
await page.waitForTimeout(150);
|
||||
assert.deepEqual((await shown(page)).parts, ["about"], what);
|
||||
assert.equal(await top(page), 0, what + ": the click must not scroll the page");
|
||||
assert.deepEqual(await overflow(page), [], what + ": About fits");
|
||||
shots.push([lang + "-" + what.replace(/\W+/g, "-"), await page.screenshot()]);
|
||||
assert.deepEqual(page.errors, []);
|
||||
await page.context().close();
|
||||
};
|
||||
for (const size of [100, 110, 125]) {
|
||||
const zoom = size / 100;
|
||||
await fits(await open(lang, [], { width: Math.floor(560 / zoom), height: Math.floor(420 / zoom), zoom, size }), size + "%");
|
||||
}
|
||||
await fits(await open(lang, [], { width: 375, height: 667, web: true }), "web on a phone");
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -89,6 +89,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
|
||||
await page.goto("http://magpie.test/");
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator("#setTab-sync").click();
|
||||
const list = page.locator("#syncList");
|
||||
const first = list.locator(".row.pref").first();
|
||||
await first.waitFor({ state: "visible" });
|
||||
|
||||
@@ -76,6 +76,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.route("**/*", server(lang, posts));
|
||||
await page.goto("http://magpie.test/?view=usage");
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator("#setTab-usage").click();
|
||||
const pill = page.locator("#trayUsagePick button");
|
||||
await pill.waitFor();
|
||||
await pill.scrollIntoViewIfNeeded();
|
||||
|
||||
@@ -68,6 +68,7 @@ async function open(browser, lang, posts, platform, over) {
|
||||
await page.route("**/*", server(lang, posts, over));
|
||||
await page.goto("http://magpie.test/?view=usage");
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator("#setTab-usage").click();
|
||||
await page.locator("#trayUsagePick button").waitFor();
|
||||
return { context, page };
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
|
||||
await page.goto("http://magpie.test/?view=usage");
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator("#setTab-usage").click();
|
||||
const pill = page.locator("#trayUsagePick button");
|
||||
await pill.waitFor();
|
||||
await page.waitForFunction(() => document.querySelector("#trayUsagePick button").textContent.trim() === "Copilot");
|
||||
@@ -99,7 +100,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
|
||||
// scrolled down with a real wheel, the pill still in sight
|
||||
await pill.hover();
|
||||
for (let i = 0; i < 20 && !(await view(page)); i++) { await page.mouse.wheel(0, 120); await page.waitForTimeout(20); }
|
||||
for (let i = 0; i < 20 && !(await view(page)); i++) { await page.mouse.wheel(0, 20); await page.waitForTimeout(20); }
|
||||
await pill.scrollIntoViewIfNeeded();
|
||||
const before = await view(page);
|
||||
assert(before > 0, "the settings list must be scrolled");
|
||||
|
||||
@@ -87,12 +87,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
|
||||
const open = async (lang, ctl) => {
|
||||
const errors = [];
|
||||
const page = await (await browser.newContext({ viewport: { width: 900, height: 420 }, reducedMotion: "reduce" })).newPage();
|
||||
const page = await (await browser.newContext({ viewport: { width: 900, height: 300 }, reducedMotion: "reduce" })).newPage();
|
||||
pages.push(page);
|
||||
page.setDefaultTimeout(5000);
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang, ctl));
|
||||
await page.goto("http://magpie.test/?view=settings");
|
||||
await page.goto("http://magpie.test/?view=settings&tab=about");
|
||||
return { page, errors };
|
||||
};
|
||||
|
||||
@@ -104,8 +104,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
for (let i = 0; i < 40; i++) {
|
||||
const box = await row.boundingBox();
|
||||
const view = await page.locator("#view-settings").boundingBox();
|
||||
if (box && view && box.y >= view.y + 4 && box.y + box.height <= view.y + view.height - 4) break;
|
||||
await page.mouse.wheel(0, 180);
|
||||
if (box && view && box.y >= view.y + 4 && box.y + box.height <= view.y + view.height - 4 && (await viewTop(page)) > 0) break;
|
||||
await page.mouse.wheel(0, 8);
|
||||
await page.waitForTimeout(16);
|
||||
}
|
||||
await page.waitForTimeout(250);
|
||||
|
||||
@@ -131,7 +131,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
|
||||
await t.test(lang + ": Settings turns it off, and shows it again", async () => {
|
||||
const ctl = fresh({ skip: "0.1.401" });
|
||||
const { page, errors } = await open(lang, ctl, "?view=settings");
|
||||
const { page, errors } = await open(lang, ctl, "?view=settings&tab=about");
|
||||
const row = page.locator("#about .row.pref", { has: page.locator(".name", { hasText: w.pill }) });
|
||||
await row.locator(".sub", { hasText: w.hidden }).waitFor();
|
||||
// the version row still offers the update
|
||||
|
||||
@@ -118,7 +118,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const posted = async (n) => { for (let i = 0; i < 100 && posts.length < n; i++) await page.waitForTimeout(20); assert.equal(posts.length, n, "posts"); return posts[n - 1]; };
|
||||
const settled = () => page.waitForTimeout(300);
|
||||
|
||||
await page.goto("http://magpie.test/?view=settings");
|
||||
await page.goto("http://magpie.test/?view=settings&tab=usage");
|
||||
const usageSegs = page.locator("#usageAlertSegs .opt"), balSegs = page.locator("#balanceAlertSegs .opt");
|
||||
await usageSegs.first().waitFor();
|
||||
|
||||
@@ -204,7 +204,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
page.setDefaultTimeout(5000);
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang, posts, "denied"));
|
||||
await page.goto("http://magpie.test/?view=settings");
|
||||
await page.goto("http://magpie.test/?view=settings&tab=usage");
|
||||
await page.locator("#usageAlertSegs .opt").first().waitFor();
|
||||
await wheelTo(page);
|
||||
// nothing said while every alert is off
|
||||
|
||||
@@ -63,6 +63,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
|
||||
await page.goto("http://magpie.test/");
|
||||
await page.locator("#prefs").click();
|
||||
await page.locator("#setTab-sync").click();
|
||||
const list = page.locator("#syncList");
|
||||
const first = list.locator(".row.pref").first();
|
||||
await first.waitFor({ state: "visible" });
|
||||
|
||||
@@ -186,7 +186,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
|
||||
// Settings → What's new → Open opens them again, the waiting update's first
|
||||
ctl.update = { state: "ready", current: "0.1.604", latest: "0.1.605", notes: "## New Features\n\n- A new thing. (#470)", url: "https://github.com/yetone/magpie-releases/releases/tag/v0.1.605" };
|
||||
await page.goto("http://magpie.test/?view=settings");
|
||||
await page.goto("http://magpie.test/?view=settings&tab=about");
|
||||
const notesRow = page.locator("#about .row.pref.whatsnew-row");
|
||||
assert.equal(await notesRow.locator(".name").textContent(), w.again);
|
||||
const again = notesRow.getByRole("button", { name: w.open, exact: true });
|
||||
|
||||
Reference in New Issue
Block a user