routing: a long Accounts and keys shows its first rows, the rest behind Show N more (ferock4669, iyou00 on Discord)
With many keys the Routing page's Accounts and keys ran on and on: each card held every window, the models it answered and a meter. Now a card keeps its name, one line of what is left (or its rest) and how it fares, with Try now or Sign in again when it needs one. The models it answered are in its tooltip under its id, and a subscription's other windows are on hover over its figure. A list longer than 8 rows shows the first 8 and puts the rest behind "Show N more" at its foot (kept across a reload in magpie.routingActsAll). Never behind it: a row to sign in again, a resting account or model, failures with no answer, a remote whose allowance can't be read, rows under a fold the reader opened, and the heading of a provider with a row shown. Two more alone aren't folded. The button clicked stays where it is on the screen. "View usage" beside it opens Usage's Overview, where each account's card says it all, without making that tab the reader's own (window.openUsageOverview). The foot writes only what changed, so an idle page writes nothing (routing-live-calm). Tests: routing-acts-compact.test.cjs (new; chromium and webkit, en zh zh-TW ja de, 1300px and 420px). routing-account-windows, routing-read-allowances, routing-wallet-lapse, routing-accounts-narrow and routing-columns follow the card's new shape and the foot. Run on mote via mote-run, worktree based on origin/mainc7bbd3faf: - Whole Routing GUI set (routing-*, panel-routing*) + i18n-keys, chromium and webkit: 2487 pass, 29 fail, every red one of those below (many-keys and routing-levels #3620 too) - Same reds on clean origin/mainc7bbd3faf(11 files run there): the routing-rule-remove (#3096), rule-drag (#3789), row-swap (#3799), order-unknown (#4627), rules-line (#3593), steady, steps-cap and story-shrinks reds of #5088, in different languages run to run. - routing-folder went red 2 of 3 with this change (30/30 on main): its press() clicked Save while the group editor was still growing open, and the foot moved .rt-gsec 8px. press() now waits for the button to hold still: 3 runs x both engines 20/20, webkit alone 10/10. - TestCoreScriptBudget red, 1534154 > 1533802, identical on cleanc7bbd3faf(#5139): this change adds nothing to the core scripts. - routing-acts-compact twice, alone and beside 5 files: 22/22, 20/20. - Rebased onto origin/main14f6d10de(its routing client.js changes merged clean), at this commit, both engines: routing-remote-windows, week-low, free-expiring, group-strategy, acts-compact, live-calm, folder, account-windows, read-allowances, accounts-narrow, wallet-lapse, columns and i18n-keys all green. Pushed onc4245c4c2, which changes only internal/gateway's object_root and its doc after 14f6d10de; not run again on it. Broken by hand: - rows needing the reader no longer kept out of the collapse (m.keep ignored): routing-acts-compact red (Show 4 more never shown). - a row to sign in again under a shut fold not drawn: red (Zed's fold row 0 !== 1). - the foot's hidden/aria-expanded written every draw: routing-live-calm red in both engines (attrs: 6 !== 0), as in an earlier run of this. - the button's hold removed: routing-acts-compact red (chromium en 1300px, "the click moved the button: 572.9 → 592.1"). Not tried: the real app with a real long key list (fixtures only), the Linux WebKitGTK app, Windows.
This commit is contained in:
@@ -203,9 +203,12 @@ gateway's order and choice of seat don't change. Two stay two rows. See
|
||||
|
||||
### Routing account windows
|
||||
|
||||
A subscription account's row in Accounts and keys shows each of its
|
||||
windows under the one figure routing went by, with when each resets
|
||||
("5 hours 40% used · resets in 2h"), as the Usage page reads them (#1833).
|
||||
A subscription account's row in Accounts and keys shows the one figure
|
||||
routing went by, and each of its windows, with when each resets
|
||||
("5 hours 40% used · resets in 2h"), on hover over that figure (the
|
||||
`.st`'s title), as the Usage page reads them (#1833). A row with no figure
|
||||
of its own (a remote's, or an account not read yet) shows its windows as
|
||||
its one line instead (`.wins`, cut to one line, all of it on hover).
|
||||
`cardOf` in [`plugins/routing/client.js`](../../internal/gui/assets/plugins/routing/client.js) matches
|
||||
the route's account to app.js's `quotas`: a `subscription` card of this
|
||||
computer (no `from`) whose provider is the account's `agent` (a plugin's
|
||||
@@ -241,6 +244,29 @@ under its id (`render`, #1835). The row itself keeps one line: the
|
||||
fullest window while idle, what it is doing while it answers. See
|
||||
`routing-seat-windows.test.cjs`.
|
||||
|
||||
### Routing account cards
|
||||
|
||||
Each row under Accounts and keys keeps its name, one line of what is left
|
||||
(or its rest), and how it fares (tried, answered, failed, last answered),
|
||||
with Try now or Sign in again when it needs one (ferock4669 and iyou00 on
|
||||
Discord: many keys ran the list on and on). The models it answered are in
|
||||
its tooltip, under its id; a folded row of keys or accounts names none.
|
||||
`renderActs` in
|
||||
[`plugins/routing/client.js`](../../internal/gui/assets/plugins/routing/client.js)
|
||||
shows the first `ACTS_SHOWN` (8) rows of a longer list and puts the rest
|
||||
behind "Show N more" at its foot (`.rt-acts-foot`), kept across a reload
|
||||
in localStorage `magpie.routingActsAll`. The button clicked stays where it
|
||||
is on the screen while rows come in or go above it (`actMore.onclick`
|
||||
scrolls the page by what it moved). Never behind it: a row that needs
|
||||
the reader (to sign in again, resting, a model resting, failures with no
|
||||
answer, a remote whose allowance can't be read), the rows under a fold
|
||||
the reader opened themselves, and the heading of a provider with a row
|
||||
shown. A row to sign in again is drawn under its fold even while the fold
|
||||
is shut. Two more alone aren't folded. "View usage" beside it opens the
|
||||
Usage page's Overview (`window.openUsageOverview` in
|
||||
`plugins/usage/page.js`), where each account's card says it all, without
|
||||
keeping that tab as the reader's own. See `routing-acts-compact.test.cjs`.
|
||||
|
||||
### A provider's accounts together
|
||||
|
||||
A Usage card of several accounts (not a card of keys, which has its sum)
|
||||
|
||||
@@ -46,7 +46,7 @@ A window that leaves out `used` but tells its count, `amount` of `limit` with bo
|
||||
|
||||
## A wallet's balance
|
||||
|
||||
A prepaid wallet (SuperMagic's points, [#3950](https://github.com/yetone/magpie/issues/3950)) has a balance and nothing it is a share of. A usage window may send `balance` (a number, in `unit`) and leave out `used`, `limit` and `aside`: `{name: "积分", balance: 6291, unit: "积分"}`. The host passes a finite number on, at least 0, and anything else as `null` (`usageOf` in [`host.js`](../../internal/plugin/host.js)); `plugin.UsageWindow.Balance` and `provider.QuotaWindow.Balance` are `*float64`. [`quotaOfPlugin`](../../internal/provider/plugin_usage.go) keeps the figure and does not make the window `Text` or `Aside`, so the account is known to routing with no `Used` invented. `allowanceOf` copies it into `Limit.Balance`, and an empty wallet (0) counts as used up. `Allowance.Left(model)` is the least balance of the windows that count the model, with its unit. `weighRouted` sets `routes.Seat.Left` to it and `Seat.LeftIn` to the account's provider and unit; Smart, `pace` and `usage` put the seat with more left first where they would otherwise tie (`byLeft` in [`strategies.go`](../../internal/routes/strategies.go)), and only among seats that share one `LeftIn`, so balances in two units or two providers are never weighed against each other: each kind is put in the places its own seats take (the pool's order, or what magpie sent each lately for `pace` and `usage`), and the other kinds keep theirs. Before, a pool with two kinds was weighed by no balance, so a group of SuperMagic's and WorkBuddy's accounts spent SuperMagic's smallest balances first (#4095). The card, the Routing page (`Weighed.Balance`) and the CLI show the figure ("6,291 积分 left", `provider.BalanceText`) and no meter. A wallet window's `runsOutAt`/`runsOut` (its soonest batch to lapse) and the rows set aside after it (`aside` text: SuperMagic's day's, timed and permanent points) are display only: the card says them, and the Routing page reads them from the same card (`cardOf` in the routing plugin's `client.js`, live requests only), its row saying the lapse after the figure ("6,291 积分 left · 185 积分 expire 23:59", `runsOutText`, #3964) and its tooltip and account list each window (`winsOf`). Routing goes by the balance alone. Tests: `TestPluginWalletBalanceIsAReading`, `TestPluginHostPassesABalanceOn`, `TestWalletsGoByWhatTheyHaveLeft`, `TestWalletsOfSeveralProvidersEachGoByWhatTheyHaveLeft`, `TestWalletWithMoreLeftGoesFirst`, `TestGroupWalletsGoByWhatTheyHaveLeft`, `usage-wallet-balance.test.cjs`, `routing-wallet-balance.test.cjs`, `routing-wallet-lapse.test.cjs`.
|
||||
A prepaid wallet (SuperMagic's points, [#3950](https://github.com/yetone/magpie/issues/3950)) has a balance and nothing it is a share of. A usage window may send `balance` (a number, in `unit`) and leave out `used`, `limit` and `aside`: `{name: "积分", balance: 6291, unit: "积分"}`. The host passes a finite number on, at least 0, and anything else as `null` (`usageOf` in [`host.js`](../../internal/plugin/host.js)); `plugin.UsageWindow.Balance` and `provider.QuotaWindow.Balance` are `*float64`. [`quotaOfPlugin`](../../internal/provider/plugin_usage.go) keeps the figure and does not make the window `Text` or `Aside`, so the account is known to routing with no `Used` invented. `allowanceOf` copies it into `Limit.Balance`, and an empty wallet (0) counts as used up. `Allowance.Left(model)` is the least balance of the windows that count the model, with its unit. `weighRouted` sets `routes.Seat.Left` to it and `Seat.LeftIn` to the account's provider and unit; Smart, `pace` and `usage` put the seat with more left first where they would otherwise tie (`byLeft` in [`strategies.go`](../../internal/routes/strategies.go)), and only among seats that share one `LeftIn`, so balances in two units or two providers are never weighed against each other: each kind is put in the places its own seats take (the pool's order, or what magpie sent each lately for `pace` and `usage`), and the other kinds keep theirs. Before, a pool with two kinds was weighed by no balance, so a group of SuperMagic's and WorkBuddy's accounts spent SuperMagic's smallest balances first (#4095). The card, the Routing page (`Weighed.Balance`) and the CLI show the figure ("6,291 积分 left", `provider.BalanceText`) and no meter. A wallet window's `runsOutAt`/`runsOut` (its soonest batch to lapse) and the rows set aside after it (`aside` text: SuperMagic's day's, timed and permanent points) are display only: the card says them, and the Routing page reads them from the same card (`cardOf` in the routing plugin's `client.js`, live requests only), its row saying the lapse after the figure ("6,291 积分 left · 185 积分 expire 23:59", `runsOutText`, #3964) and its tooltip, and the account list's figure on hover, each window (`winsOf`). Routing goes by the balance alone. Tests: `TestPluginWalletBalanceIsAReading`, `TestPluginHostPassesABalanceOn`, `TestWalletsGoByWhatTheyHaveLeft`, `TestWalletsOfSeveralProvidersEachGoByWhatTheyHaveLeft`, `TestWalletWithMoreLeftGoesFirst`, `TestGroupWalletsGoByWhatTheyHaveLeft`, `usage-wallet-balance.test.cjs`, `routing-wallet-balance.test.cjs`, `routing-wallet-lapse.test.cjs`.
|
||||
|
||||
## Cache a vendor doesn't count
|
||||
|
||||
|
||||
@@ -214,6 +214,31 @@ function routingPage(part) {
|
||||
}
|
||||
};
|
||||
actHead.append(actLabel, actRead, el("span", "grow"), actNote);
|
||||
// under the list: the rest of a long one, behind Show N more (kept
|
||||
// across a reload, magpie.routingActsAll), and the way to each
|
||||
// account's allowances in full, the Usage page's Overview
|
||||
// (ferock4669, iyou00 on Discord: many keys ran the list on and on)
|
||||
const actFoot = el("div", "rt-acts-foot");
|
||||
const actMore = el("button", "text rt-acts-more");
|
||||
actMore.type = "button";
|
||||
let actsAll = false;
|
||||
try { actsAll = localStorage.getItem("magpie.routingActsAll") === "1"; } catch {}
|
||||
actMore.onclick = () => {
|
||||
actsAll = !actsAll;
|
||||
try { localStorage.setItem("magpie.routingActsAll", actsAll ? "1" : "0"); } catch {}
|
||||
// the button clicked stays where it is on the screen, the rows coming
|
||||
// in (or going) above it: neither engine's scroll anchoring does it
|
||||
// for every place the page can be scrolled to
|
||||
const v = $("#view-routing"), y = actMore.getBoundingClientRect().top;
|
||||
steady(() => renderActs(listed()));
|
||||
const moved = actMore.getBoundingClientRect().top - y;
|
||||
if (moved) v.scrollTop += moved;
|
||||
};
|
||||
const actUsage = el("button", "text rt-acts-usage");
|
||||
actUsage.type = "button";
|
||||
actUsage.dataset.feature = "usage"; // it opens on the Usage page
|
||||
actUsage.onclick = () => window.openUsageOverview();
|
||||
actFoot.append(actMore, el("span", "grow"), actUsage);
|
||||
const hist = el("div", "rt-cols");
|
||||
const colA = el("div", "rt-col"), colB = el("div", "rt-col");
|
||||
const filters = el("div", "rt-filters");
|
||||
@@ -260,7 +285,7 @@ function routingPage(part) {
|
||||
};
|
||||
filters.append(dayBar, groupBar);
|
||||
colA.append(reqHead, filters, reqs);
|
||||
colB.append(actHead, acts);
|
||||
colB.append(actHead, acts, actFoot);
|
||||
hist.append(colA, colB);
|
||||
more.append(hist);
|
||||
// the narrow and wide layouts go by a box's own width, as container
|
||||
@@ -1513,6 +1538,9 @@ function routingPage(part) {
|
||||
// more of them, else open. Which the reader opened or folded is kept, by
|
||||
// provider and model, or "group/<id>", whatever the default.
|
||||
const FOLD_AT = 3, LONG = 6;
|
||||
// Accounts and keys shows this many rows of a longer list, and every
|
||||
// one needing the reader, the rest behind Show N more
|
||||
const ACTS_SHOWN = 8;
|
||||
const folds = new Map(); // foldKey → { li, wire, st, tg, n, w, ids, up, open, pk }
|
||||
let keysOpen = new Set(), keysShut = new Set();
|
||||
try { keysOpen = new Set(JSON.parse(localStorage.getItem("magpie.routingKeysOpen") || "[]")); } catch {}
|
||||
@@ -4311,19 +4339,26 @@ function routingPage(part) {
|
||||
// after them: laid out in columns, a heading at a column's foot over
|
||||
// nothing, its accounts at the next one's top, WebKit having no
|
||||
// break-after: avoid (Jiabubu on Discord)
|
||||
const put = (e, leads) => {
|
||||
// each block put, with its provider and whether it is kept in sight:
|
||||
// one needing the reader (an error, a rest, a sign-in), or under a
|
||||
// fold the reader opened themselves. Show N more never hides those
|
||||
const meta = new Map();
|
||||
const put = (e, leads, keep = false) => {
|
||||
if (leads) return lead.push(e);
|
||||
if (!lead.length) return out.push(e);
|
||||
const b = el("div", "rt-lead");
|
||||
b.append(...lead.splice(0), e);
|
||||
const b = lead.length ? el("div", "rt-lead") : e;
|
||||
if (lead.length) b.append(...lead.splice(0), e);
|
||||
out.push(b);
|
||||
meta.set(b, { prov, keep, n: b === e ? 1 : b.querySelectorAll(".rt-act").length });
|
||||
};
|
||||
// refused for its sign-in, and not answered since
|
||||
const needsSignIn = (a) => a.w.kind === "account" && a.authAt > a.last;
|
||||
// each provider's keys and accounts, gathered once: each of hundreds
|
||||
// of keys looked through the whole list for its own (#3164)
|
||||
const kin = new Map(), kinOf = (w) => w.provider + "\u0000" + w.kind;
|
||||
for (const a of list) { const k = kinOf(a.w); kin.has(k) ? kin.get(k).push(a) : kin.set(k, [a]); }
|
||||
for (const a of list) {
|
||||
const w = a.w;
|
||||
let opened = false;
|
||||
if (w.provider !== prov) {
|
||||
prov = w.provider;
|
||||
const h = el("div", "rt-prov");
|
||||
@@ -4345,8 +4380,12 @@ function routingPage(part) {
|
||||
const ks = kin.get(kinOf(w));
|
||||
if (ks.length >= FOLD_AT) {
|
||||
const pk = w.provider + (w.kind === "account" ? "/@" : "/*"), open = isOpen(pk, w.kind === "account" && ks.length < LONG);
|
||||
if (ks[0] === a) put(keysRow(ks, pk, open, n, w.kind), open);
|
||||
if (!open) continue;
|
||||
// folded, an account to sign in again is still drawn under it:
|
||||
// what the reader has to fix is never folded away
|
||||
const signIns = !open && ks.some(needsSignIn);
|
||||
opened = open && keysOpen.has(pk);
|
||||
if (ks[0] === a) put(keysRow(ks, pk, open, n, w.kind), open || signIns, ks.some((k) => needsSignIn(k) || (k.rest && at(k.rest.until) > n)));
|
||||
if (!open && !needsSignIn(a)) continue;
|
||||
}
|
||||
}
|
||||
const row = el("div", "rt-act");
|
||||
@@ -4374,7 +4413,7 @@ function routingPage(part) {
|
||||
// in again, here where the card says so. Answered since, the
|
||||
// refusals are the day's past, not what it needs now (adorable_piglet
|
||||
// on Discord: "2 需要重新登录" on an account the editor showed in use)
|
||||
const signIn = w.kind === "account" && a.authAt > a.last;
|
||||
const signIn = needsSignIn(a);
|
||||
const fails = Object.entries(a.fails).map(([k, v]) => `${v} ${k === "auth" && a.authAt && !signIn ? t("sign-in refused (answered since)") : failWord(k)}`);
|
||||
tally.append(
|
||||
el("span", "", t("tried {n}", { n: a.tried })),
|
||||
@@ -4382,7 +4421,14 @@ function routingPage(part) {
|
||||
...(fails.length ? [el("span", "bad", fails.join(", "))] : []),
|
||||
...(a.last ? [el("span", "", t("last answered {time}", { time: clock(a.last) }))] : []));
|
||||
const stEl = el("div", "st " + cls, st);
|
||||
// a subscription account's windows each, with when they reset, as
|
||||
// the Usage page read them (#1833): the figure is the one window
|
||||
// routing went by, the others on hover and on the Usage page. Live
|
||||
// only: a kept day's requests were weighed by readings long gone.
|
||||
const ws = day ? [] : [...winsOf(w).map((text) => ({ text })), ...remoteWinsOf(w)];
|
||||
const figure = !!st && (resting || w.known || w.unlisted || w.noURL);
|
||||
if (resting && restTip(a.rest)) stEl.title = restTip(a.rest);
|
||||
else if (figure && ws.length) stEl.title = ws.map((x) => x.text).join("\n");
|
||||
row.append(name, stEl);
|
||||
if (parts.length) {
|
||||
const r0 = parts[0][1].rest;
|
||||
@@ -4390,25 +4436,21 @@ function routingPage(part) {
|
||||
if (restTip(r0)) part.title = restTip(r0);
|
||||
row.append(part);
|
||||
}
|
||||
// a subscription account's windows each, with when they reset, as
|
||||
// the Usage page read them (#1833): the figure above is the one
|
||||
// window routing went by. Live only: a kept day's requests were
|
||||
// weighed by readings long gone.
|
||||
const ws = day ? [] : [...winsOf(w).map((text) => ({ text })), ...remoteWinsOf(w)];
|
||||
if (ws.length) {
|
||||
// with no figure of its own (a remote's row, an account not read
|
||||
// yet), its windows are its one line of what is left, the rest of
|
||||
// the line on hover
|
||||
if (ws.length && !figure) {
|
||||
const line = el("div", "wins");
|
||||
line.append(...ws.map((x) => { const e = el("span", "", x.text); if (x.title) e.title = x.title; return e; }));
|
||||
if (ws.length > 1) line.title = ws.map((x) => x.text).join("\n");
|
||||
row.append(line);
|
||||
}
|
||||
row.append(tally);
|
||||
// the models it answered, on a line of their own, not wrapped in
|
||||
// among the numbers; a provider's one model is already its name
|
||||
// the models it answered on hover, with its id: a card says its name,
|
||||
// what is left and how it fares (ferock4669, iyou00 on Discord); a
|
||||
// provider's one model is already its name
|
||||
const mdls = [...a.models].filter((m) => !(w.kind === "provider" && m === w.model));
|
||||
if (mdls.length) {
|
||||
const ms = el("div", "mdls");
|
||||
ms.append(...mdls.map((m) => el("code", "mdl", m)));
|
||||
row.append(ms);
|
||||
}
|
||||
const remoteBad = ws.some((x) => x.title);
|
||||
const lifts = resting ? (a.rest.key ? [a.rest] : []) : parts.map(([, x]) => x.rest).filter((x) => x.key);
|
||||
if (lifts.length) {
|
||||
// any rest can be lifted by hand (#1869): a quota, a backoff, a
|
||||
@@ -4444,10 +4486,33 @@ function routingPage(part) {
|
||||
bar.append(bi);
|
||||
row.append(bar);
|
||||
}
|
||||
row.title = w.id;
|
||||
put(row);
|
||||
row.title = w.id + (mdls.length ? "\n" + mdls.join(", ") : "");
|
||||
put(row, false, opened || signIn || resting || parts.length > 0 || remoteBad || (!a.ok && Object.keys(a.fails).length > 0));
|
||||
}
|
||||
patch(acts, out);
|
||||
// a long list shows its first ACTS_SHOWN rows and every one kept in
|
||||
// sight, with its provider's heading; the rest behind Show N more.
|
||||
// A few more alone aren't folded: the button would take their room
|
||||
const hide = new Set(), seen = new Set();
|
||||
let shown = 0, hidden = 0;
|
||||
for (const b of out) {
|
||||
const m = meta.get(b);
|
||||
if (m.keep) seen.add(m.prov);
|
||||
else if (shown < ACTS_SHOWN) { shown += m.n; seen.add(m.prov); } else hide.add(b);
|
||||
}
|
||||
// a provider's heading, in one block with its first row, goes with
|
||||
// the rows of it shown
|
||||
for (const b of out) if (hide.has(b) && seen.has(meta.get(b).prov) && b.querySelector(":scope > .rt-prov")) hide.delete(b);
|
||||
for (const b of hide) hidden += meta.get(b).n;
|
||||
if (hidden <= 2) hide.clear();
|
||||
// written only when changed: a redraw with nothing new writes nothing
|
||||
const unhide = (e, h) => { if (e.hidden !== h) e.hidden = h; };
|
||||
unhide(actMore, !hide.size);
|
||||
setText(actMore, actsAll ? t("Show fewer") : t("Show {n} more", { n: hidden }));
|
||||
setAttr(actMore, "aria-expanded", String(actsAll));
|
||||
setText(actUsage, t("View usage"));
|
||||
unhide(actUsage, !list.length);
|
||||
unhide(actFoot, actMore.hidden && actUsage.hidden);
|
||||
patch(acts, actsAll ? out : out.filter((b) => !hide.has(b)));
|
||||
}
|
||||
|
||||
// signInAgain signs the account of seat w in again, in its provider's
|
||||
@@ -4501,13 +4566,8 @@ function routingPage(part) {
|
||||
el("span", "ok", t("answered {n}", { n: sum((a) => a.ok) })),
|
||||
...(bad.length ? [el("span", "bad", bad.join(", "))] : []),
|
||||
...(last ? [el("span", "", t("last answered {time}", { time: clock(last) }))] : []));
|
||||
// the models they answered are each one's, opened
|
||||
const kids = [name, el("div", "st" + (resting === ks.length ? " rest" : ""), st.join(" · ")), tally];
|
||||
const mdls = [...new Set(ks.flatMap((a) => [...a.models]))];
|
||||
if (mdls.length) {
|
||||
const ms = el("div", "mdls");
|
||||
ms.append(...mdls.map((m) => el("code", "mdl", m)));
|
||||
kids.push(ms);
|
||||
}
|
||||
// drawn again only when what it says changes
|
||||
if (kids.length !== row.children.length || kids.some((k, i) => !k.isEqualNode(row.children[i]))) row.replaceChildren(...kids);
|
||||
return row;
|
||||
|
||||
@@ -469,13 +469,12 @@ button.rt-session { cursor: pointer; }
|
||||
.rt-read.busy { cursor: default; color: var(--fg-2); }
|
||||
.rt-read.busy svg > * { transform-box: view-box; transform-origin: 50% 50%; animation: spin .8s linear infinite; }
|
||||
@media (prefers-reduced-motion: reduce) { .rt-read.busy svg > * { animation: none; } }
|
||||
/* a subscription account's windows each (#1833), under its one figure */
|
||||
.rt-act .wins { display: flex; flex-wrap: wrap; gap: 2px 12px; min-width: 0; color: var(--fg-2); font-size: 11px; font-variant-numeric: tabular-nums; }
|
||||
.rt-act .wins span { min-width: 0; overflow-wrap: anywhere; }
|
||||
/* a subscription account's windows (#1833), one line where it has no
|
||||
figure of its own, the rest of it on hover */
|
||||
.rt-act .wins { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-2); font-size: 11px; font-variant-numeric: tabular-nums; }
|
||||
.rt-act .wins span + span { margin-left: 12px; }
|
||||
.rt-act .tally { display: flex; flex-wrap: wrap; gap: 2px 12px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
|
||||
.rt-act .tally .bad { color: var(--red); }
|
||||
.rt-act .mdls { display: flex; flex-wrap: wrap; gap: 4px; }
|
||||
.rt-act .mdls code { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.rt-act .fix { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 11px; }
|
||||
.rt-act .bar { height: 3px; border-radius: 2px; background: var(--card-2); overflow: hidden; }
|
||||
.rt-act .bar i { display: block; height: 100%; border-radius: 2px; background: var(--muted); }
|
||||
@@ -1022,3 +1021,11 @@ body.window .rt-gedit > .bar { --vfoot: 8px; }
|
||||
.rt-gtpl-card .acts { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 4px; }
|
||||
.rt-gtplbtn { display: inline-flex; align-items: center; gap: 4px; }
|
||||
.rt-log-head .mask-badge { margin-left: 8px; }
|
||||
/* under Accounts and keys: Show N more, and the way to each account's
|
||||
allowances in full on the Usage page (ferock4669, iyou00 on Discord) */
|
||||
.rt-acts-foot { display: flex; align-items: center; gap: 12px; padding: 2px 12px 4px 33px; font-size: 11px; }
|
||||
.rt-acts-foot[hidden] { display: none; }
|
||||
.rt-acts-foot .grow { flex: 1; }
|
||||
.rt-acts-foot button.text { font-size: 11px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.rt-acts-foot button.text:hover { color: var(--fg); }
|
||||
.rt-acts-foot button.text[hidden] { display: none; }
|
||||
|
||||
@@ -1157,6 +1157,13 @@ window.openUsageRoute = (route) => {
|
||||
ledger = null;
|
||||
show("usage");
|
||||
};
|
||||
// Routing's account list sends its reader to each account's
|
||||
// allowances in full: the Overview, its tab not kept as the reader's own
|
||||
window.openUsageOverview = () => {
|
||||
if (usageTab === "requests") ledLeave();
|
||||
usageTab = "usage";
|
||||
show("usage");
|
||||
};
|
||||
// the one request a route from Routing listed gives way to the list as it
|
||||
// was before it
|
||||
function ledRouteOff() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// #1833: the Routing page's Accounts and keys list shows a subscription
|
||||
// account's windows each (Claude's 5 hours and 7 days), with when each
|
||||
// resets, as the Usage page read them: its card matched by the agent the
|
||||
// resets, as the Usage page read them, on hover over its one figure: its card matched by the agent the
|
||||
// account is signed in to and its user, whatever their case. Nothing new
|
||||
// is read for it: opening Routing asks /api/usage/quotas in the ordinary
|
||||
// way, never ?asked=1. An account with no card of its own (another
|
||||
@@ -82,14 +82,15 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.route("**/*", serve(lang, asks));
|
||||
await page.goto("http://magpie.test/?view=routing");
|
||||
const act = page.locator(".rt-act", { hasText: "work@example.com" }).first();
|
||||
await act.locator(".wins span").first().waitFor();
|
||||
assert.deepEqual(await act.locator(".wins span").allTextContents(), words[lang]);
|
||||
// the one figure routing went by stays above them
|
||||
// the one figure routing went by, the windows each on hover over
|
||||
// it: a card keeps one line of what is left (ferock4669 on Discord)
|
||||
await page.waitForFunction((want) => [...document.querySelectorAll(".rt-act")].some((e) => e.textContent.includes("work@example.com") && e.querySelector(".st")?.title === want), words[lang].join("\n"));
|
||||
assert.ok(await act.locator(".st").isVisible());
|
||||
assert.equal(await act.locator(".wins").count(), 0);
|
||||
const spare = page.locator(".rt-act", { hasText: "spare@example.com" }).first();
|
||||
await spare.waitFor();
|
||||
assert.equal(await spare.locator(".wins").count(), 0);
|
||||
// the windows wrap inside the row, never past the list
|
||||
// nothing in the row runs past the list
|
||||
const over = await act.evaluate((e) => Math.max(e.scrollWidth - e.clientWidth, document.documentElement.scrollWidth - innerWidth));
|
||||
assert.ok(over <= 1, `${lang} at ${width}: ${over}px past`);
|
||||
assert.ok(asks.length >= 1, "the readings were asked for");
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
// across them, which left a page of many providers of one key each one to a
|
||||
// line still. Under the requests they flow in columns now, each provider's
|
||||
// heading over its own; beside the requests (1150px and wider) the column
|
||||
// still holds one.
|
||||
// still holds one. Its "Show N more" is opened first, so every provider
|
||||
// is drawn.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -65,6 +66,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
t.after(() => browser.close());
|
||||
await page.goto("http://magpie.test/?view=routing");
|
||||
await page.locator(".rt-act", { hasText: "dan@example.com" }).waitFor();
|
||||
// a long list shows its first rows, the rest behind "Show N more"
|
||||
// at its foot (ferock4669 on Discord): opened, every provider here
|
||||
await page.locator(".rt-acts-foot button.rt-acts-more").click();
|
||||
await page.locator(".rt-acts .rt-prov", { hasText: "Baichuan" }).waitFor();
|
||||
|
||||
// the account rows' boxes: how many share the first one's line
|
||||
const rows = () => page.locator(".rt-acts .rt-act:not(.rt-keys)").evaluateAll((es) => es.map((e) => {
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// ferock4669 and iyou00 on Discord: with many keys, Routing's Accounts and
|
||||
// keys ran on and on ("key 这里如果有很多 key 就会拉的很长"). Now each card
|
||||
// keeps its name, one line of what is left and how it fares, the models it
|
||||
// answered on hover; a long list shows its first eight rows and the rest
|
||||
// behind "Show N more" at its foot, kept across a reload, the click moving
|
||||
// nothing. A row that needs the reader is never behind it: a key failing
|
||||
// with no answer, and an account to sign in again, drawn under its
|
||||
// provider's fold while the fold is shut, each under its heading. "View
|
||||
// usage" beside it opens the Usage page's Overview, where each account's
|
||||
// card says it all, without keeping that tab as the reader's own. Every
|
||||
// language, at a window's width and at 420px, in both engines.
|
||||
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 now = Date.now();
|
||||
const pad = (i) => String(i).padStart(2, "0");
|
||||
const tallies = {};
|
||||
// twelve providers of one key each, all answering
|
||||
for (let i = 1; i <= 12; i++) {
|
||||
tallies["p" + pad(i) + "-k"] = { id: "p" + pad(i) + "-k", provider: "p" + pad(i), name: "Alpha " + pad(i), who: "key-" + pad(i), kind: "key",
|
||||
agent: "claude", model: "m-" + pad(i), tried: 3, ok: 3, fails: {}, last: now - 60000, models: ["m-" + pad(i)] };
|
||||
}
|
||||
// a key failing, never answering: last in the list, and shown all the same
|
||||
tallies["yak-k"] = { id: "yak-k", provider: "yak", name: "Yak", who: "key-yak", kind: "key", agent: "claude", model: "m-yak", tried: 4, ok: 0, fails: { other: 4 }, last: 0 };
|
||||
// six accounts of one provider, folded; one refused for its sign-in since it last answered
|
||||
const users = ["a", "b", "c", "d", "e", "late"];
|
||||
for (const u of users) {
|
||||
tallies[JSON.stringify(["zed", u + "@example.com"])] = { id: "zed@" + u, provider: "zed", name: "Zed", who: u + "@example.com", kind: "account", agent: "zed",
|
||||
model: "m-zed", tried: 2, ok: 2, fails: u === "late" ? { auth: 2 } : {}, last: now - 600000, authAt: u === "late" ? now - 300000 : 0 };
|
||||
}
|
||||
// one request the gateway still keeps, answered by the first key: with
|
||||
// none, there is no list of accounts to tally
|
||||
const iso = (ms) => new Date(ms).toISOString();
|
||||
const { tried, ok, fails, last, models, ...seat } = tallies["p01-k"];
|
||||
const routes = [{ id: 1, seq: 1, time: iso(now - 61000), agent: "claude", model: "m-01", provider: "p01", done: true, status: 200, ms: 300,
|
||||
order: [seat], tries: [{ id: "p01-k", model: "m-01", start: iso(now - 61000), done: true, ms: 250, status: 200 }] }];
|
||||
const words = {
|
||||
en: { more: "Show 4 more", fewer: "Show fewer", usage: "View usage" },
|
||||
zh: { more: "显示其余 4 个", fewer: "收起", usage: "查看用量" },
|
||||
"zh-TW": { more: "顯示其餘 4 個", fewer: "收起", usage: "檢視用量" },
|
||||
ja: { more: "さらに 4 件表示", fewer: "折りたたむ", usage: "使用量を表示" },
|
||||
de: { more: "4 weitere anzeigen", fewer: "Weniger anzeigen", usage: "Nutzung anzeigen" },
|
||||
};
|
||||
|
||||
function serve(lang) {
|
||||
const state = { agents: [{ id: "claude", name: "Claude Code", path: "/test/claude", fields: [] }], profiles: [], settings: { lang, theme: "light", quotaLeft: false } };
|
||||
return async (r) => {
|
||||
const url = new URL(r.request().url());
|
||||
const json = (data) => r.fulfill({ json: data });
|
||||
if (url.pathname === "/boot.js") return r.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
|
||||
if (url.pathname === "/wails/runtime.js") return r.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json(state);
|
||||
if (url.pathname === "/api/gateway/trace") {
|
||||
if (url.searchParams.get("wait")) return new Promise(() => {}); // nothing more comes
|
||||
return json({ mine: true, now: new Date().toISOString(), seq: 1, totals: { requests: 50, rerouted: 0, errors: 6 }, routes });
|
||||
}
|
||||
if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [{ day: new Date(now).toISOString().slice(0, 10), requests: 50 }], routes: [], tallies });
|
||||
if (url.pathname === "/api/usage/quotas" || url.pathname === "/api/usage/quotas/history") return json([]);
|
||||
if (url.pathname === "/api/groups") return json({ models: [], groups: [], pools: [] });
|
||||
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true, url: "http://127.0.0.1:3999" } });
|
||||
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 r.fulfill({ body: await fs.readFile(file), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
const alpha = (from, to) => Array.from({ length: to - from + 1 }, (_, i) => "key-" + pad(from + i));
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
test(`${engine}: a long Accounts and keys shows its first rows and every one needing the reader`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
for (const width of [1300, 420]) for (const lang of Object.keys(words)) {
|
||||
await t.test(`${lang} at ${width}px`, async () => {
|
||||
const ctx = await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" });
|
||||
try {
|
||||
const page = await ctx.newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang));
|
||||
await page.addInitScript(() => { try { if (!sessionStorage.getItem("seeded")) { localStorage.setItem("magpie.usageTab", "requests"); sessionStorage.setItem("seeded", "1"); } } catch {} });
|
||||
await page.goto("http://magpie.test/?view=routing");
|
||||
const w = words[lang];
|
||||
const acts = page.locator(".rt-acts");
|
||||
const more = page.locator(".rt-acts-foot button.rt-acts-more");
|
||||
const names = () => acts.locator(".rt-act .nm b").allTextContents();
|
||||
const heads = () => acts.locator(".rt-prov b").allTextContents();
|
||||
await more.filter({ hasText: w.more }).waitFor();
|
||||
// the first eight, the failing key and the account to sign in
|
||||
// again, each under its heading; Zed's other five folded
|
||||
const folded = (await names()).filter((x) => !x.startsWith("key-") && !x.includes("@"));
|
||||
assert.equal(folded.length, 1, "Zed's fold row: " + folded);
|
||||
assert.deepEqual((await names()).filter((x) => x !== folded[0]), [...alpha(1, 8), "key-yak", "late@example.com"]);
|
||||
assert.deepEqual(await heads(), ["Alpha 01", "Alpha 02", "Alpha 03", "Alpha 04", "Alpha 05", "Alpha 06", "Alpha 07", "Alpha 08", "Yak", "Zed"]);
|
||||
const late = acts.locator(".rt-act", { hasText: "late@example.com" });
|
||||
assert.equal(await late.locator("button.rt-signin").count(), 1);
|
||||
assert.equal(await acts.locator(".rt-act", { hasText: "key-yak" }).locator(".tally .bad").count(), 1);
|
||||
// a card: its name, its line, how it fares; the models on hover
|
||||
const one = acts.locator(".rt-act", { hasText: "key-01" });
|
||||
assert.equal(await one.getAttribute("title"), "p01-k\nm-01");
|
||||
assert.equal(await acts.locator(".mdls, .wins, code").count(), 0);
|
||||
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth - innerWidth <= 1), true, "nothing past the window");
|
||||
// Show 4 more: all of them, and the button clicked stays where it
|
||||
// is on the screen (the rows come in above it)
|
||||
// wheeled to, as a reader would (the page holds still for a script's scroll)
|
||||
await page.mouse.move(width / 2, 300);
|
||||
for (let i = 0; i < 40 && (await more.boundingBox()).y > 600; i++) {
|
||||
await page.mouse.wheel(0, 120);
|
||||
await page.waitForTimeout(100);
|
||||
}
|
||||
await page.waitForTimeout(300);
|
||||
const box = await more.boundingBox();
|
||||
assert.ok(box.y > 0 && box.y + box.height < 760, "on the screen: " + JSON.stringify(box));
|
||||
assert.ok(box.x >= 0 && box.x + box.width <= width, JSON.stringify(box));
|
||||
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
|
||||
await more.filter({ hasText: w.fewer }).waitFor();
|
||||
const after = (await more.boundingBox()).y; // scrollTop is whole pixels
|
||||
assert.ok(Math.abs(after - box.y) <= 1, `the click moved the button: ${box.y} → ${after}`);
|
||||
assert.deepEqual((await names()).filter((x) => x !== folded[0]), [...alpha(1, 12), "key-yak", "late@example.com"]);
|
||||
assert.equal(await more.getAttribute("aria-expanded"), "true");
|
||||
// kept across a reload, then shown fewer again
|
||||
await page.reload();
|
||||
await more.filter({ hasText: w.fewer }).waitFor();
|
||||
assert.equal((await names()).filter((x) => x.startsWith("key-")).length, 13);
|
||||
await more.click();
|
||||
await more.filter({ hasText: w.more }).waitFor();
|
||||
assert.equal((await names()).filter((x) => x.startsWith("key-")).length, 9);
|
||||
// View usage: the Overview, each account's card in full; the
|
||||
// reader's own tab (Requests) stays theirs
|
||||
const usage = page.locator(".rt-acts-foot button.rt-acts-usage");
|
||||
assert.equal(await usage.textContent(), w.usage);
|
||||
await usage.click();
|
||||
await page.locator("#view-usage").waitFor({ state: "visible" });
|
||||
await page.locator("#usagePane").waitFor({ state: "visible" });
|
||||
assert.equal(await page.locator("#ledgerPane").isVisible(), false);
|
||||
assert.equal(await page.evaluate(() => localStorage.getItem("magpie.usageTab")), "requests");
|
||||
assert.deepEqual(errors, []);
|
||||
} finally {
|
||||
await ctx.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
// The Routing page's Requests and Accounts and keys, side by side (a report
|
||||
// with a screenshot: "这里排版是不是有问题啊?感觉好乱"): the two lists end on one
|
||||
// line, the accounts scrolling like the requests instead of running on down
|
||||
// the page beside an empty column; the models an account answered sit on a
|
||||
// line of their own, not wrapped in among its numbers; a provider's row
|
||||
// the page beside an empty column; the models an account answered are in
|
||||
// its tooltip, not wrapped in among its numbers; a provider's row
|
||||
// says its model once, under the provider's name, not the name again and the
|
||||
// model twice. One column, the accounts list is as long as it is. Side by
|
||||
// side only where each request still fits one line; narrower, one column of
|
||||
@@ -83,9 +83,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
const box = (s) => page.locator(s).evaluate((e) => { const b = e.getBoundingClientRect(); return { left: b.left, right: b.right, bottom: b.bottom, scroll: e.scrollHeight > e.clientHeight + 1 }; });
|
||||
const reqs = await box(".rt-reqs"), acts = await box(".rt-acts");
|
||||
const reqs = await box(".rt-reqs"), acts = await box(".rt-acts"), foot = await box(".rt-acts-foot");
|
||||
assert(acts.left >= reqs.right, "side by side");
|
||||
assert(Math.abs(acts.bottom - reqs.bottom) <= 1, `the lists end on one line: ${reqs.bottom} / ${acts.bottom}`);
|
||||
// the accounts' column ends at its foot (Show N more, View usage)
|
||||
assert(Math.abs(foot.bottom - reqs.bottom) <= 1 && foot.bottom >= acts.bottom, `the lists end on one line: ${reqs.bottom} / ${foot.bottom}`);
|
||||
assert(acts.scroll, "the rest of the accounts scroll");
|
||||
// a request on one line: its destination and numbers beside its model
|
||||
const oneLine = () => page.locator(".rt-req").evaluateAll((rs) => rs.every((r) => {
|
||||
@@ -107,20 +108,20 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const rw = requests.right - requests.left, aw = accounts.right - accounts.left;
|
||||
assert(rw > aw * 1.6, `${width}px: requests should have more room than accounts (${rw} / ${aw})`);
|
||||
assert(aw >= 260 && aw <= 360.5, `${width}px: account column stays readable and capped (${aw})`);
|
||||
const rightList = await box(".rt-acts"), leftList = await box(".rt-reqs");
|
||||
const rightList = await box(".rt-acts-foot"), leftList = await box(".rt-reqs");
|
||||
assert(Math.abs(rightList.bottom - leftList.bottom) <= 1, `${width}px: list bottoms stay aligned`);
|
||||
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth), false, `${width}px: no horizontal overflow`);
|
||||
const clipped = await page.locator(".rt-act .mdls code").evaluateAll((es) => es.some((e) => e.getBoundingClientRect().right > e.closest(".rt-act").getBoundingClientRect().right + 1));
|
||||
assert.equal(clipped, false, `${width}px: models stay inside the narrower account column`);
|
||||
assert(await oneLine(), `${width}px: side by side, each request still on one line`);
|
||||
}
|
||||
|
||||
// the Codex account's three models on their own line, none in the tally
|
||||
// the Codex account's three models in its tooltip, under its id, none
|
||||
// in the card: a card says its name, what is left and how it fares
|
||||
// (ferock4669 on Discord)
|
||||
const codex = page.locator(".rt-act", { hasText: "ann@example.com" });
|
||||
assert.deepEqual((await codex.locator(".mdls code").allInnerTexts()).sort(), ["gpt-5.6-luna", "gpt-5.6-terra", "gpt-6-luna"]);
|
||||
assert.equal(await codex.locator(".tally code").count(), 0);
|
||||
const tally = await codex.locator(".tally").boundingBox(), mdls = await codex.locator(".mdls").boundingBox();
|
||||
assert(mdls.y >= tally.y + tally.height - 0.5, "the models under the numbers");
|
||||
const [id, models] = (await codex.getAttribute("title")).split("\n");
|
||||
assert.equal(id, "codex:a");
|
||||
assert.deepEqual(models.split(", ").sort(), ["gpt-5.6-luna", "gpt-5.6-terra", "gpt-6-luna"]);
|
||||
assert.equal(await codex.locator("code").count(), 0);
|
||||
|
||||
// a provider's row: its model once, not its name again
|
||||
const ai = page.locator(".rt-act").first();
|
||||
|
||||
@@ -93,7 +93,15 @@ async function press(page, b) {
|
||||
await page.mouse.wheel(0, 300);
|
||||
await page.waitForTimeout(150);
|
||||
}
|
||||
const bb = await b.boundingBox();
|
||||
// the editor grows open for a moment: the button is clicked once it
|
||||
// holds still, not where it was on its way down
|
||||
let bb = await b.boundingBox();
|
||||
for (let i = 0; i < 40; i++) {
|
||||
await page.waitForTimeout(50);
|
||||
const now = await b.boundingBox();
|
||||
if (now.x === bb.x && now.y === bb.y) break;
|
||||
bb = now;
|
||||
}
|
||||
await page.mouse.click(bb.x + bb.width / 2, bb.y + bb.height / 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,8 +95,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang, [acct], asks, held));
|
||||
await page.goto("http://magpie.test/?view=routing");
|
||||
const act = page.locator(".rt-act", { hasText: "work@example.com" }).first();
|
||||
await act.locator(".wins span").filter({ hasText: w.before }).waitFor();
|
||||
const tip = (want) => page.waitForFunction((want) => [...document.querySelectorAll(".rt-act")].some((e) => e.textContent.includes("work@example.com") && (e.querySelector(".st")?.title || "").includes(want)), want);
|
||||
await tip(w.before);
|
||||
const b = page.locator("#rtReadAllowances");
|
||||
await b.waitFor({ state: "visible" });
|
||||
assert.equal(await b.getAttribute("title"), w.title);
|
||||
@@ -114,7 +114,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
// a second click while it turns asks nothing more
|
||||
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
|
||||
release();
|
||||
await act.locator(".wins span").filter({ hasText: w.after }).waitFor();
|
||||
await tip(w.after);
|
||||
await page.waitForFunction(() => !document.querySelector("#rtReadAllowances").classList.contains("busy"));
|
||||
assert.equal(await page.locator("#view-routing").evaluate((v) => v.scrollTop), top, "the click moved the page");
|
||||
// and nothing reads again by itself
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// said only the total, "6,291 积分 left". Now the row says what goes
|
||||
// first too, as the Usage card words it: "6,291 积分 left · 185 积分
|
||||
// expire 23:59", on the stage and in the accounts listed below, and the
|
||||
// tooltip and the list name the four rows. A wallet whose card tells no
|
||||
// tooltips of the stage and the list name the four rows. A wallet whose card tells no
|
||||
// lapse, and an account with a share, read as before. Every language, at
|
||||
// a window's width and at 420px, in both engines.
|
||||
const assert = require("node:assert/strict");
|
||||
@@ -105,7 +105,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
// the Usage page's readings come in beside the trace, and the stage is
|
||||
// drawn again with them: read the row until it says what it should,
|
||||
// or until it has had time to, and compare what it said last
|
||||
await page.locator(".rt-act .wins").first().waitFor();
|
||||
await page.waitForFunction(() => [...document.querySelectorAll(".rt-act .st")].some((e) => e.title));
|
||||
const settled = async (id, want) => {
|
||||
let got = "";
|
||||
for (let i = 0; i < 20 && got !== want; i++) {
|
||||
@@ -120,10 +120,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
// the tooltip names the four rows the Usage card shows
|
||||
const tip = await row("magicrew#big@example.com").getAttribute("title");
|
||||
for (const s of ["185 / 200 积分 · 今日 23:59 到期", "1,106 积分 · 最早 2026-11-03 到期", "5,000 积分"]) assert.ok(tip.includes(s), tip);
|
||||
// the accounts listed below: the figure and its lapse, then when it was read
|
||||
// the accounts listed below: the figure and its lapse, then when it
|
||||
// was read, each window on hover over it
|
||||
const acts = page.locator(".rt-act");
|
||||
await acts.filter({ hasText: "6,291" }).first().waitFor();
|
||||
const list = await acts.evaluateAll((as) => as.map((a) => ({ st: a.querySelector(".st")?.textContent || "", wins: a.querySelector(".wins")?.innerText || "" })));
|
||||
const list = await acts.evaluateAll((as) => as.map((a) => ({ st: a.querySelector(".st")?.textContent || "", wins: a.querySelector(".st")?.title || "" })));
|
||||
const b = list.find((a) => a.st.startsWith(big + " · "));
|
||||
assert.ok(b, `${big}: ${JSON.stringify(list)}`);
|
||||
assert.ok(b.wins.includes("185 / 200 积分 · 今日 23:59 到期") && b.wins.includes("5,000 积分"), b.wins);
|
||||
|
||||
Reference in New Issue
Block a user