gui: the pages go in the reader's own order, in the sidebar and a phone's tab bar (chet030714 on X)
Settings › General › Sidebar pages, where pages are hidden, now also puts them in order: a row is dragged by its grip (shown on hover, always on a touch screen), or moved with Alt+↑/↓. The order is kept for this browser in localStorage magpie.navOrder, beside magpie.navHidden. The sidebar and the header's tabs follow it at once, and a phone's tab bar (phonetabs.js) shows the first four with the rest under More. Providers is listed (it can be moved, never hidden). While the order isn't the home one the sidebar's group names (Work, Models, ...) are left out, since a reordered list breaks the groups; Default order (shown only then) removes the key and puts the pages and their names back. A page the kept order doesn't name (new in an update) goes after the page it follows at home. Plugin pages keep their place in their group. A reader who never reorders sees nothing change. navOrder and navArrange live in the new navorder.js, imported by navHides only once an order is kept (and by navpages.js with the menu), so what is left in app.js is that one line: +107 on both core budgets, explained there. old-webkit's list of on-demand scripts names navorder.js. Built on the unpushed WIP 10b9ee22c (page-order worktree), cherry-picked onto origin/main; the WIP test clicked the aria-disabled Providers row without force, and its reload checks now wait for the async import. Run: - nav-pages-order.test.cjs (new): Chromium and WebKit, en/zh/zh-TW/ja/de, 10/10 pass. Red on origin/main (no menu opens), 5/5 chromium. - The whole GUI suite (make test-ui) on mote at the first, inline version (navArrange ran on every start; the final version runs nothing new for a reader with no order), stopped after 4,171 ok / 171 not ok, none in a nav, sidebar or phone file. Five of the red files (agent-switch-accounts, gateway-key-arrange, first-untick, data-folder, api-key-theme) rerun on mica at this tree and at origin/mainc1ab9a494: 34 pass / 56 fail on both. - At the final tree on mica: every nav*, phone*, side*, sidebar*, i18n*, last-page, menu-scroll*, settings-search and old-webkit file: 377 pass / 42 fail; the reds (menu-scroll, nav-timeout, phone-no-sideways, side-effort, old-webkit) fail the same at origin/mainc1ab9a494, and last-page webkit's (two requests cut off counted as page errors, #5972's kind) passed 3 of 3 alone; go test ./internal/gui/...: ok. old-webkit's two reds are #6570/#6030 (navpages.js, headerpresets.js missing from its list) and #5919, the same on origin/main. Not tried: a finger drag on a real phone (the test taps the menu and checks the grip shows; the drag is the mouse path dragRows shares), and the real app's window (Wails); the GUI tests load the real assets.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -3385,6 +3385,24 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; }
|
||||
/* a menu of actions, where nothing is or can be ticked, keeps no room for
|
||||
a tick: its items line up with its heading */
|
||||
.proto-menu.pm-bare .pm-tick { display: none; }
|
||||
/* Settings' Sidebar pages (navpages.js): each page's row is dragged to its
|
||||
place, the grip at its end showing on the row under the pointer, as an
|
||||
iPhone's list being reordered has it; Providers is always shown */
|
||||
.nav-pages-list { position: relative; display: grid; gap: 1px; }
|
||||
.nav-pages-menu .pm-item { align-items: center; }
|
||||
.nav-pages-menu .pm-words { flex: 1; min-width: 0; }
|
||||
.nav-pages-menu .grip { flex: none; display: grid; place-items: center; align-self: stretch; width: 26px; margin: -6px -8px -7px 0; touch-action: none; cursor: grab; opacity: 0; transition: opacity .15s ease; }
|
||||
.nav-pages-menu .grip::before { content: ""; width: 6px; height: 11px; background: radial-gradient(circle, var(--muted) .9px, transparent 1.2px) 0 0 / 3px 3.75px; }
|
||||
.nav-pages-menu .pm-item:is(:hover, .dragging) .grip { opacity: 1; }
|
||||
/* apart: Safari before 15.4 drops a whole selector list with :focus-visible in it */
|
||||
.nav-pages-menu .pm-item:focus-visible .grip { opacity: 1; }
|
||||
@media (hover: none) { .nav-pages-menu .grip { opacity: 1; } }
|
||||
.nav-pages-menu .pm-fixed .pm-tick { opacity: .4; }
|
||||
.nav-pages-list.sorting { user-select: none; -webkit-user-select: none; }
|
||||
.nav-pages-list.sorting > .pm-item { transition: transform .16s cubic-bezier(.23, 1, .32, 1); cursor: grabbing; }
|
||||
.nav-pages-list.sorting > .pm-item.dragging { z-index: 2; background: var(--card-2); box-shadow: 0 0 0 1px var(--line); transition: none; will-change: transform; }
|
||||
@media (prefers-reduced-motion: reduce) { .nav-pages-list.sorting > .pm-item { transition: none; } }
|
||||
.nav-pages-reset { margin-top: 3px; }
|
||||
/* a group's heading in a menu of many: it ticks all of its items */
|
||||
.proto-menu .pm-group { margin-top: 3px; }
|
||||
.proto-menu .pm-group .pm-name { font-size: 11px; font-weight: 600; color: var(--muted); }
|
||||
|
||||
@@ -23392,6 +23392,8 @@ const navList = (k) => { try { return JSON.parse(localStorage.getItem("magpie.na
|
||||
const navMine = () => navList("Hidden");
|
||||
function navHides() {
|
||||
if (mode !== "window") return;
|
||||
// the reader's own order (navorder.js), imported only once there is one
|
||||
window.navArrange ? navArrange() : navList("Order").length && import("./navorder.js").then(navHides, () => {});
|
||||
for (const b of $("#nav").querySelectorAll("button[data-view]")) b.hidden = (gatewayMode && GATEWAY_HIDES.includes(b.dataset.view)) || featureHides(b) || navMine().includes(b.dataset.view);
|
||||
}
|
||||
function applyFeatures(list) {
|
||||
|
||||
@@ -836,6 +836,7 @@ const I18N = {
|
||||
"{n} hidden": "已隐藏 {n} 个",
|
||||
"Sidebar pages": "侧边栏页面",
|
||||
"All shown": "全部显示",
|
||||
"Always shown": "始终显示",
|
||||
"{n} at 0": "{n} 个为 0",
|
||||
"Fold the ones at 0": "收起为 0 的",
|
||||
"Nothing left here: every window used up, or a balance of 0": "已没有剩余额度的账号和密钥:每个额度窗口都已用完,或余额为 0",
|
||||
@@ -6190,6 +6191,7 @@ const I18N = {
|
||||
"{n} hidden": "已隱藏 {n} 個",
|
||||
"Sidebar pages": "側邊欄頁面",
|
||||
"All shown": "全部顯示",
|
||||
"Always shown": "始終顯示",
|
||||
"{n} at 0": "{n} 個為 0",
|
||||
"Fold the ones at 0": "收起為 0 的",
|
||||
"Nothing left here: every window used up, or a balance of 0": "已沒有剩餘額度的帳號和金鑰:每個額度時段都已用完,或餘額為 0",
|
||||
@@ -11508,6 +11510,7 @@ const I18N = {
|
||||
"{n} hidden": "{n} 件非表示",
|
||||
"Sidebar pages": "サイドバーのページ",
|
||||
"All shown": "すべて表示",
|
||||
"Always shown": "常に表示",
|
||||
"{n} at 0": "{n} 件が 0",
|
||||
"Fold the ones at 0": "0 のものをたたむ",
|
||||
"Nothing left here: every window used up, or a balance of 0": "残りがないアカウントとキー:すべてのウィンドウを使い切ったか、残高が 0",
|
||||
@@ -16844,6 +16847,7 @@ const I18N = {
|
||||
"{n} hidden": "{n} ausgeblendet",
|
||||
"Sidebar pages": "Seiten in der Seitenleiste",
|
||||
"All shown": "Alle sichtbar",
|
||||
"Always shown": "Immer sichtbar",
|
||||
"{n} at 0": "{n} bei 0",
|
||||
"Fold the ones at 0": "Die bei 0 einklappen",
|
||||
"Nothing left here: every window used up, or a balance of 0": "Konten und Schlüssel ohne Rest: jedes Zeitfenster aufgebraucht oder ein Guthaben von 0",
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// The pages in the reader's order (chet030714 on X), kept in localStorage
|
||||
// magpie.navOrder by Settings › General › Sidebar pages (navpages.js).
|
||||
// app.js navHides imports this once an order is kept, so a reader who never
|
||||
// reorders loads none of it.
|
||||
|
||||
// the order of the pages vs; one it doesn't name, new in an update, goes
|
||||
// after the page it follows at home
|
||||
window.navOrder = function (vs) {
|
||||
const o = [...new Set(navList("Order"))].filter((v) => vs.includes(v));
|
||||
vs.forEach((v, i) => { if (!o.includes(v)) o.splice(i && o.indexOf(vs[i - 1]) + 1, 0, v); });
|
||||
return o;
|
||||
};
|
||||
|
||||
// the built-in pages and their groups' names, in the order they come at home
|
||||
const nav = $("#nav");
|
||||
window.navHome = [...nav.querySelectorAll(":scope > .nav-gl:not([data-plugin-pages]), :scope > button[data-view]:not([data-plugin-page])")];
|
||||
|
||||
// the built-in pages put in that order, the phone's tab bar's too
|
||||
// (phonetabs.js reads #nav); a group's name goes while the order is the
|
||||
// reader's own, and comes back with the home order
|
||||
window.navArrange = function () {
|
||||
const home = navHome, vs = home.flatMap((e) => e.dataset.view || []), o = navOrder(vs), own = o.join() !== vs.join();
|
||||
let prev = null;
|
||||
for (const e of own ? o.map((v) => home.find((b) => b.dataset.view === v)) : home) {
|
||||
let nx = prev ? prev.nextElementSibling : nav.firstElementChild;
|
||||
while (nx?.matches(".nav-sub, .thumb")) nx = nx.nextElementSibling;
|
||||
if (nx !== e) nav.insertBefore(e, nx);
|
||||
prev = e;
|
||||
}
|
||||
for (const e of home) if (!e.dataset.view) own ? e.remove() : e.dataset.en && (e.textContent = t(e.dataset.en));
|
||||
};
|
||||
+110
-19
@@ -1,37 +1,128 @@
|
||||
// Settings › General › Sidebar pages (youimark on X: a docker gateway has
|
||||
// no use for Agents or Library): which pages this browser leaves out of
|
||||
// the sidebar, kept in localStorage magpie.navHidden as this reader's own
|
||||
// (navMine in app.js reads it). app.js imports this when Settings draws,
|
||||
// so it weighs nothing on the core.
|
||||
// (navMine in app.js reads it), and the order they go in (chet030714 on
|
||||
// X: Routing, Providers and Agents first in a phone's tab bar, the rest
|
||||
// under More), kept in magpie.navOrder (navorder.js).
|
||||
// A row is dragged to its place, or moved with Alt+↑/↓; Providers is
|
||||
// always shown. app.js imports this when Settings draws, so it weighs
|
||||
// nothing on the core.
|
||||
import "./navorder.js";
|
||||
const navPagesOf = (nav) => [...nav.querySelectorAll(":scope > button[data-view]")]
|
||||
.filter((b) => !(gatewayMode && GATEWAY_HIDES.includes(b.dataset.view)) && !featureHides(b))
|
||||
.map((b) => ({ v: b.dataset.view, name: (b.querySelector("span[data-t]") || b.querySelector("span"))?.textContent || b.textContent.trim(), plugin: "pluginPage" in b.dataset }));
|
||||
|
||||
function navPagesSave(k, list) {
|
||||
try {
|
||||
if (list) localStorage.setItem("magpie.nav" + k, JSON.stringify(list));
|
||||
else localStorage.removeItem("magpie.nav" + k);
|
||||
} catch { /* not kept */ }
|
||||
navHides();
|
||||
if (offView(view) !== view) show(offView(view));
|
||||
else if (!sideNav()) slide($("#nav"), "nav");
|
||||
navSubsAt = "";
|
||||
navSubs();
|
||||
window.renderNavPages();
|
||||
}
|
||||
|
||||
const words = (name) => { const w = el("span", "pm-words"); w.append(el("span", "pm-name", name)); return w; };
|
||||
|
||||
function navPagesMenu(anchor) {
|
||||
closeProtoMenu();
|
||||
const nav = $("#nav"), box = el("div", "pop proto-menu nav-pages-menu"), list = el("div", "nav-pages-list");
|
||||
box.setAttribute("role", "menu");
|
||||
const reset = el("button", "pm-item nav-pages-reset");
|
||||
reset.type = "button";
|
||||
reset.append(el("span", "pm-tick"), words(t("Default order")));
|
||||
reset.onclick = () => { navPagesSave("Order", null); draw(); list.querySelector(".pm-item")?.focus(NO_SCROLL); };
|
||||
hoverFocus(reset);
|
||||
box.append(el("div", "pm-head", t("Sidebar pages")), list, reset);
|
||||
const home = () => navHome.flatMap((e) => e.dataset.view || []);
|
||||
const movable = () => [...list.querySelectorAll(".pm-item[data-moves]")];
|
||||
const focus = (v) => list.querySelector(`[data-v="${CSS.escape(v)}"]`)?.focus(NO_SCROLL);
|
||||
// v to place to among the pages this menu lists, the others where they are
|
||||
const move = (v, to) => {
|
||||
const ps = movable().map((r) => r.dataset.v), all = navOrder(home());
|
||||
if (to < 0 || to >= ps.length || ps.indexOf(v) === to) return;
|
||||
const s = ps.filter((x) => x !== v);
|
||||
s.splice(to, 0, v);
|
||||
const o = all.map((x) => ps.includes(x) ? s.shift() : x);
|
||||
navPagesSave("Order", o.join() === home().join() ? null : o);
|
||||
draw();
|
||||
focus(v);
|
||||
};
|
||||
const item = (p, hid) => {
|
||||
const r = el("button", "pm-item"), on = p.v === "providers" || !hid.includes(p.v);
|
||||
r.type = "button";
|
||||
r.dataset.v = p.v;
|
||||
r.setAttribute("role", "menuitemcheckbox");
|
||||
r.setAttribute("aria-checked", String(on));
|
||||
r.classList.toggle("on", on);
|
||||
const tick = el("span", "pm-tick");
|
||||
if (on) tick.append(svg(CHECK, 12, 1.9));
|
||||
r.append(tick, words(p.name));
|
||||
if (p.v === "providers") {
|
||||
r.classList.add("pm-fixed");
|
||||
r.setAttribute("aria-disabled", "true");
|
||||
r.title = t("Always shown");
|
||||
}
|
||||
r.onclick = () => {
|
||||
if (r.dataset.dragged || p.v === "providers") return;
|
||||
const h = navMine();
|
||||
navPagesSave("Hidden", on ? [...h, p.v] : h.filter((x) => x !== p.v));
|
||||
draw();
|
||||
focus(p.v);
|
||||
};
|
||||
hoverFocus(r);
|
||||
// a plugin's page keeps its place in the Plugins group (pluginpages.js)
|
||||
if (!p.plugin) {
|
||||
r.dataset.moves = "";
|
||||
r.append(el("span", "grip"));
|
||||
r.setAttribute("aria-description", t("Drag to reorder · Alt+↑/↓ to move"));
|
||||
r.onpointerdown = (e) => dragRows(e, r, r, list, movable(), (to) => move(p.v, to));
|
||||
}
|
||||
return r;
|
||||
};
|
||||
const draw = () => {
|
||||
const hid = navMine();
|
||||
list.replaceChildren(...navPagesOf(nav).map((p) => item(p, hid)));
|
||||
reset.hidden = navOrder(home()).join() === home().join();
|
||||
};
|
||||
draw();
|
||||
const keys = (e) => {
|
||||
if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
|
||||
const items = [...box.querySelectorAll(".pm-item:not([hidden])")], i = items.indexOf(document.activeElement);
|
||||
if (!e.altKey) return stepFocus(e, items, i);
|
||||
const r = items[i];
|
||||
if (!r || !("moves" in r.dataset)) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
move(r.dataset.v, movable().indexOf(r) + (e.key === "ArrowDown" ? 1 : -1));
|
||||
};
|
||||
document.body.append(box);
|
||||
placeMenu(box, anchor, "left");
|
||||
anchor.classList.add("open");
|
||||
anchor.setAttribute("aria-expanded", "true");
|
||||
holdMenu(box, anchor, keys, (e) => { if (scrollCloses(box, e)) closeProtoMenu(); });
|
||||
list.querySelector(".pm-item")?.focus(NO_SCROLL);
|
||||
}
|
||||
|
||||
window.renderNavPages = function () {
|
||||
const row = $("#navPagesRow"), nav = $("#nav");
|
||||
if (!row) return;
|
||||
// only a window has a sidebar: the panel has no #nav (#6139)
|
||||
if (mode !== "window" || !nav) { row.hidden = true; return; }
|
||||
const pages = [...nav.querySelectorAll("button[data-view]")]
|
||||
.filter((b) => b.dataset.view !== "providers" && !(gatewayMode && GATEWAY_HIDES.includes(b.dataset.view)) && !featureHides(b))
|
||||
.map((b) => ({ v: b.dataset.view, name: b.querySelector("[data-t]")?.dataset.en || b.textContent.trim() }));
|
||||
row.hidden = !pages.length;
|
||||
const pages = navPagesOf(nav);
|
||||
row.hidden = pages.length < 2;
|
||||
if (row.hidden) return;
|
||||
const mine = navMine();
|
||||
const n = pages.filter((p) => mine.includes(p.v)).length;
|
||||
const n = pages.filter((p) => p.v !== "providers" && mine.includes(p.v)).length;
|
||||
let b = row.querySelector(".nav-pages-pick");
|
||||
if (!b) {
|
||||
b = el("button", "sess-pick pref-pick nav-pages-pick");
|
||||
b.type = "button";
|
||||
menuOf(b);
|
||||
b.onclick = () => {
|
||||
const now = navMine();
|
||||
openProtoMenu(b, pages.map((p) => ({ v: p.v, name: p.name })), pages.map((p) => p.v).filter((v) => !now.includes(v)), (shown) => {
|
||||
const keep = now.filter((v) => !pages.some((p) => p.v === v));
|
||||
const hide = [...keep, ...pages.map((p) => p.v).filter((v) => !shown.includes(v))];
|
||||
try { localStorage.setItem("magpie.navHidden", JSON.stringify(hide)); } catch { /* not kept */ }
|
||||
navHides();
|
||||
if (offView(view) !== view) show(offView(view));
|
||||
else if (!sideNav()) slide($("#nav"), "nav");
|
||||
window.renderNavPages();
|
||||
}, "Sidebar pages", "", "left", true);
|
||||
};
|
||||
b.onclick = () => b.classList.contains("open") ? closeProtoMenu() : navPagesMenu(b);
|
||||
row.append(b);
|
||||
}
|
||||
b.textContent = n ? t("{n} hidden", { n }) : t("All shown");
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,155 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// Settings › General › Sidebar pages puts the pages in the reader's order
|
||||
// (chet030714 on X: Routing, Providers and Agents first in a phone's tab
|
||||
// bar, the rest under More). A row of its menu is dragged to its place, or
|
||||
// moved with Alt+↑/↓; the sidebar follows the order and leaves out its
|
||||
// groups' names, a phone's tab bar shows the first four with the rest under
|
||||
// More, the order is kept for this browser (localStorage magpie.navOrder), a
|
||||
// page the kept order doesn't name goes after the page it follows at home,
|
||||
// and Default order puts it all back. Chromium and WebKit, every language. No
|
||||
// backend: the API is faked.
|
||||
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");
|
||||
const BASE = "http://magpie.test/";
|
||||
const HOME = ["agents", "sessions", "library", "providers", "routing", "groups", "gateway", "usage", "masking", "plugins"];
|
||||
const RESET = { en: "Default order", zh: "恢复默认顺序", "zh-TW": "恢復預設順序", ja: "既定の順に戻す", de: "Standardreihenfolge" };
|
||||
|
||||
function server(lang, web) {
|
||||
return async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const json = (d) => route.fulfill({ json: d });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:${JSON.stringify(lang)},theme:"light",web:${web}};` });
|
||||
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" } });
|
||||
if (url.pathname === "/api/settings") return json({ theme: "light", lang, version: "0.1.400", gateway: "http://127.0.0.1:3425", web, visionModels: [], imageGenModels: [], lanURLs: [] });
|
||||
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true } });
|
||||
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)];
|
||||
try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); }
|
||||
};
|
||||
}
|
||||
|
||||
async function open(browser, { lang = "en", web = false, phone = false } = {}) {
|
||||
const context = await browser.newContext(phone
|
||||
? { viewport: { width: 390, height: 844 }, deviceScaleFactor: 2, hasTouch: true, isMobile: browser.browserType().name() === "chromium", reducedMotion: "reduce" }
|
||||
: { viewport: { width: 1100, height: 760 }, reducedMotion: "reduce" });
|
||||
const page = await context.newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
page.errors = [];
|
||||
page.on("pageerror", (e) => page.errors.push(e.message));
|
||||
await page.route("**/*", server(lang, web));
|
||||
return page;
|
||||
}
|
||||
|
||||
// the built-in pages in the sidebar's order, and the groups' names it shows
|
||||
const order = (page) => page.$$eval("#nav > button[data-view]:not([data-plugin-page])", (bs) => bs.map((b) => b.dataset.view));
|
||||
const groups = (page) => page.$$eval("#nav > .nav-gl", (gs) => gs.filter((g) => !g.hidden).map((g) => g.textContent));
|
||||
const menuOrder = (page) => page.$$eval(".nav-pages-menu .nav-pages-list .pm-item", (rs) => rs.map((r) => r.dataset.v));
|
||||
// the sidebar in that order: a kept order is put in place by navorder.js,
|
||||
// imported as the page starts
|
||||
const arranged = (page, want) => page.waitForFunction((w) => [...document.querySelectorAll("#nav > button[data-view]:not([data-plugin-page])")].map((b) => b.dataset.view).join() === w.join(), want);
|
||||
const kept = (page) => page.evaluate(() => JSON.parse(localStorage.getItem("magpie.navOrder") || "null"));
|
||||
const move = (list, v, to) => { const o = list.filter((x) => x !== v); o.splice(to, 0, v); return o; };
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of Object.keys(RESET)) {
|
||||
test(`${engine} ${lang}: the pages go in the reader's order, in the sidebar and a phone's tab bar`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const page = await open(browser, { lang });
|
||||
await page.goto(BASE + "?view=settings");
|
||||
await page.waitForSelector("#navPagesRow:not([hidden]) .nav-pages-pick");
|
||||
assert.deepEqual(await order(page), HOME, "home order at first");
|
||||
const homeGroups = await groups(page);
|
||||
assert.equal(homeGroups.length, 4, "the sidebar's groups are named");
|
||||
await page.locator(".nav-pages-pick").click();
|
||||
await page.waitForSelector(".nav-pages-menu");
|
||||
assert.deepEqual(await menuOrder(page), HOME, "the menu lists every page, Providers too, in their order");
|
||||
assert.equal(await page.locator(".nav-pages-reset").isVisible(), false, "no Default order while it is the default");
|
||||
// Providers is always shown: a click leaves it ticked
|
||||
await page.locator('.nav-pages-menu [data-v="providers"]').click({ force: true });
|
||||
assert.equal(await page.locator('.nav-pages-menu [data-v="providers"]').getAttribute("aria-checked"), "true");
|
||||
// Routing to the top from the keyboard
|
||||
await page.locator('.nav-pages-menu [data-v="routing"]').focus();
|
||||
for (let i = 0; i < 4; i++) await page.keyboard.press("Alt+ArrowUp");
|
||||
let want = move(HOME, "routing", 0);
|
||||
assert.deepEqual(await menuOrder(page), want);
|
||||
assert.deepEqual(await order(page), want, "the sidebar follows at once");
|
||||
assert.deepEqual(await groups(page), [], "its groups' names go with the home order");
|
||||
assert.equal(await page.evaluate(() => document.activeElement?.dataset.v), "routing", "the moved row keeps the focus");
|
||||
// Providers dragged up to second by its row
|
||||
const from = await page.locator('.nav-pages-menu [data-v="providers"]').boundingBox();
|
||||
const onto = await page.locator('.nav-pages-menu [data-v="agents"]').boundingBox();
|
||||
await page.mouse.move(from.x + from.width - 10, from.y + from.height / 2);
|
||||
await page.mouse.down();
|
||||
for (let i = 1; i <= 12; i++) await page.mouse.move(from.x + from.width - 10, from.y + from.height / 2 + (onto.y - 4 - from.y) * i / 12);
|
||||
await page.waitForTimeout(80);
|
||||
await page.mouse.up();
|
||||
want = move(want, "providers", 1);
|
||||
assert.deepEqual(await menuOrder(page), want, "dragged into place");
|
||||
assert.equal(await page.locator('.nav-pages-menu [data-v="providers"]').getAttribute("aria-checked"), "true", "a drag ticks nothing off");
|
||||
assert.deepEqual(await kept(page), want, "kept");
|
||||
// hiding a page still works beside the order
|
||||
await page.locator('.nav-pages-menu [data-v="sessions"]').click();
|
||||
assert.equal(await page.locator('#nav button[data-view="sessions"]').isHidden(), true);
|
||||
await page.keyboard.press("Escape");
|
||||
assert.equal(await page.locator(".nav-pages-menu").count(), 0);
|
||||
|
||||
// kept for this browser: a reload draws it so from the start
|
||||
await page.goto(BASE + "?view=providers");
|
||||
await page.waitForSelector("#nav button.on");
|
||||
await arranged(page, want);
|
||||
assert.deepEqual(await groups(page), []);
|
||||
|
||||
// a phone's tab bar: the first four shown, the rest under More
|
||||
const phone = await open(browser, { lang, web: true, phone: true });
|
||||
await phone.goto(BASE);
|
||||
await phone.evaluate((o) => { localStorage.setItem("magpie.navOrder", JSON.stringify(o)); localStorage.setItem("magpie.navHidden", '["sessions"]'); }, want);
|
||||
await phone.goto(BASE + "?view=providers");
|
||||
await phone.waitForSelector("#nav .nav-more");
|
||||
await arranged(phone, want);
|
||||
const bar = await phone.$$eval("#nav > button", (bs) => bs.filter((b) => getComputedStyle(b).display !== "none" && b.getBoundingClientRect().width > 0).map((b) => b.dataset.view || "more"));
|
||||
const shown = want.filter((v) => v !== "sessions" && v !== "groups");
|
||||
assert.deepEqual(bar, [...shown.slice(0, 4), "more"], "the bar: " + JSON.stringify(bar));
|
||||
await phone.locator("#nav .nav-more").tap();
|
||||
const rest = await phone.$$eval(".nav-more-menu .pm-item", (rs) => rs.length);
|
||||
assert.ok(rest >= shown.length - 4, "More has the rest");
|
||||
// the order is set on the phone too, where its pages are hidden
|
||||
await phone.keyboard.press("Escape");
|
||||
await phone.goto(BASE + "?view=settings");
|
||||
await phone.waitForSelector("#navPagesRow:not([hidden]) .nav-pages-pick");
|
||||
await phone.locator(".nav-pages-pick").tap();
|
||||
await phone.waitForSelector(".nav-pages-menu .grip");
|
||||
assert.equal(await phone.locator('.nav-pages-menu [data-v="routing"] .grip').isVisible(), true, "a phone shows the grip");
|
||||
assert.deepEqual(phone.errors, []);
|
||||
|
||||
// a page the kept order doesn't name (new in an update) goes after
|
||||
// the page it follows at home
|
||||
await page.evaluate(() => localStorage.setItem("magpie.navOrder", JSON.stringify(["routing", "providers", "agents", "sessions", "library", "gateway", "usage", "masking", "plugins"])));
|
||||
await page.goto(BASE + "?view=settings");
|
||||
await page.waitForSelector(".nav-pages-pick");
|
||||
await arranged(page, ["routing", "groups", "providers", "agents", "sessions", "library", "gateway", "usage", "masking", "plugins"]);
|
||||
|
||||
// Default order puts the pages and their groups back
|
||||
await page.locator(".nav-pages-pick").click();
|
||||
await page.locator(".nav-pages-reset").click();
|
||||
assert.equal(await page.locator(".nav-pages-reset").isVisible(), false);
|
||||
assert.equal(await page.locator(".nav-pages-reset").innerText().catch(() => RESET[lang]), RESET[lang]);
|
||||
assert.deepEqual(await order(page), HOME);
|
||||
assert.deepEqual(await groups(page), homeGroups);
|
||||
assert.equal(await kept(page), null);
|
||||
assert.deepEqual(page.errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -183,9 +183,10 @@ test("compat.js is the first of the page's own scripts", async () => {
|
||||
// claudemagpie.js when Claude Desktop's twin button or Advanced fold first shows;
|
||||
// keyrates.js when a provider with two or more keys opens;
|
||||
// appearance.js when Settings draws General or the look changes;
|
||||
// navorder.js once a page order is kept, or Settings › Sidebar pages draws;
|
||||
// the checks above
|
||||
// still read them
|
||||
for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quotatable.js", "quitask.js", "checkinnow.js", "proxies.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "agentwindow.js", "balfound.js", "passerrors.js", "tlscerts.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js", "pageshare.js", "panelfirst.js", "panelarrange.js", "modelfind.js", "agentsmanager.js", "agentsuffix.js", "phonetabs.js", "pluginmd.js", "bark.js", "acctexport.js", "plugincounts.js", "navicons.js", "autoswitchtip.js", "codexprojects.js", "pipecheck.js", "addfloat.js", "plugingrid.js", "plugininstalled.js", "rotfig.js", "ompadvisor.js", "claudemagpie.js", "keyrates.js", "qianwenplan.js", "qianfanplan.js", "agymove.js", "updatetrust.js", "currencyprefs.js", "appearance.js", "mirroredit.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
|
||||
for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quotatable.js", "quitask.js", "checkinnow.js", "proxies.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "agentwindow.js", "balfound.js", "passerrors.js", "tlscerts.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js", "pageshare.js", "panelfirst.js", "panelarrange.js", "modelfind.js", "agentsmanager.js", "agentsuffix.js", "phonetabs.js", "pluginmd.js", "bark.js", "acctexport.js", "plugincounts.js", "navicons.js", "autoswitchtip.js", "codexprojects.js", "pipecheck.js", "addfloat.js", "plugingrid.js", "plugininstalled.js", "rotfig.js", "ompadvisor.js", "claudemagpie.js", "keyrates.js", "qianwenplan.js", "qianfanplan.js", "agymove.js", "updatetrust.js", "currencyprefs.js", "appearance.js", "mirroredit.js", "navorder.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
|
||||
});
|
||||
|
||||
test("the styles hold up in Safari 15.0", async () => {
|
||||
|
||||
Reference in New Issue
Block a user