usage: a card's captions read at 4.5:1 on the card (Jiabubu)
Jiabubu (Discord, #feedback) found the Usage Overview cards' captions, "重置于 …", "本周期" and a curve's dates, small and hard to read in both themes. They were --faint: 1.95:1 on a light card, 2.16:1 on a dark one, under WCAG AA's 4.5:1. Every caption on a card is --muted now: a window's reset line, the curve's range and axis dates, "Last reading", a balance curve's pace, a credit day's note, the all-accounts head and its unknown, a card's error line, and on the tray panel's allowance card .pq-sub, .pq-rn, "until …" and an auto-reset's used line. Light's --muted is 3.66:1 on white, so a card (and its tinted all-accounts box) takes --ctl-fg, the token documented as a control's quiet text at 4.5:1 on every surface; dark keeps its --muted. The reset line's "held" reason lost its 0.75 opacity (it read under 4.5:1); it keeps the caption colour. Sizes are unchanged; the figures keep --fg-2 at 600. Measured in the page (Chromium and WebKit, same numbers): Usage card, light: captions 1.95 -> 5.95:1; figures 8.64:1 Usage card, dark: captions 2.16 -> 4.64:1; figures 8.03:1 Panel card, light: .pq-sub 2.79 -> 5.95:1 Panel card, dark: .pq-sub 3.66 -> 5.54:1 (computed from the tokens) quota-caption-contrast.test.cjs checks every caption on a Usage card at 4.5:1 or better, each below the card's figure by 1.5 or more, and the panel card's captions at 4.5:1, in Chromium and WebKit, light and dark, en/zh/zh-TW/ja/de, at 900 and 420 wide. Broken by hand: with origin/main's app.css it fails at "light en 900: .quota-reset reads at 1.95:1"; with only .pq-sub put back on --faint it fails at "light en panel: .pq-sub reads at 2.79:1". Run on mote at this tree (on origin/main8abdf53a8), with mote at load 164-191 from other sessions: the new test 2 of 2 ok; the GUI files this can reach (360 files, every one naming a usage card, the panel card, the routing page, app.css, i18n or a budget; both engines, every language, narrow widths), 5573 of 5668 ok. The 22 red files were run again alone at this head and at8abdf53a8: three were this change (routing-save-blank and routing-save-keeps-the-row wheeled until Save was in sight, which it now is at once, so they wheel to the editor's foot; quota-holds took a faded "not enough data" as muted, now the reset line's caption colour), fixed here and green at concurrency 2. The rest are red at8abdf53a8too (account-eye #4244, routing-rule-* #4585, tray-cell-click and usage-fold #4790, numbers on #4932). The whole suite was started once and stopped at 316 tests after an hour at that load; it was not run to the end. Rebased on origin/main1851ead1a(app.css and the usage page changed), then run again at the pushed head: go test -run 'Budget|CSS' ./internal/gui ok, and quota-caption-contrast, group-editor-selected, quota-holds, routing-save-blank, routing-save-keeps-the-row, plan-credits and balance-fix, 154 of 154 ok in both engines. Not tried: the real app's window (the GUI suite's pages only), and the menu bar cells, which have their own colours. Reported by Jiabubu on Discord (#feedback).
This commit is contained in:
+21
-14
@@ -934,6 +934,13 @@ body.window .field.solo { grid-column: auto; }
|
||||
rows a pixel high, the gap between cards in its place on them (#860) */
|
||||
.subscription-usage.packed { grid-auto-rows: 1px; row-gap: 0; }
|
||||
.subscription-card { padding: 10px 12px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); min-width: 0; }
|
||||
/* a card's captions (resets, the period, a curve's dates) read at 4.5:1 or
|
||||
better on the card, below its figures (Jiabubu on Discord): light's
|
||||
--muted is 3.7:1 on white, so a card takes the controls' quiet text;
|
||||
dark's --muted is 4.6:1 already */
|
||||
.subscription-card, .pq-card, .quota-all { --muted: var(--ctl-fg); }
|
||||
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.subscription-card, .pq-card) { --muted: inherit; } }
|
||||
:root[data-theme="dark"] :is(.subscription-card, .pq-card) { --muted: inherit; }
|
||||
.subscription-head { display: flex; align-items: center; gap: 7px; margin-bottom: 9px; }
|
||||
.subscription-head .ic { width: 17px; height: 17px; }
|
||||
.subscription-head b { font-size: 12.5px; font-weight: 600; }
|
||||
@@ -995,7 +1002,7 @@ body.window .field.solo { grid-column: auto; }
|
||||
1024 Dev Day · GLM-5.3" in the panel, rtbeilin on X); cut short, two
|
||||
windows of one plan would read alike */
|
||||
.quota-windows.stacked .quota-name { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
|
||||
.quota-reset { display: flex; flex-wrap: wrap; column-gap: 4px; margin-top: 4px; font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }
|
||||
.quota-reset { display: flex; flex-wrap: wrap; column-gap: 4px; margin-top: 4px; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
|
||||
/* each part of the reset line goes whole onto a line of its own when it
|
||||
doesn't fit beside the others, and only one wider than the card breaks
|
||||
between its words rather than running off it (#2443: German's
|
||||
@@ -1008,24 +1015,24 @@ body.window .field.solo { grid-column: auto; }
|
||||
/* a window's whole (WindowHolds): a line of its own under the reset */
|
||||
.quota-reset .quota-holds { flex-basis: 100%; display: flex; flex-wrap: wrap; column-gap: 4px; min-width: 0; }
|
||||
.quota-reset .quota-holds > span { white-space: normal; min-width: 0; }
|
||||
.quota-reset .quota-holds-why { flex-basis: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .75; cursor: help; }
|
||||
.quota-reset .quota-holds-why { flex-basis: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: help; }
|
||||
.quota-track { height: 4px; border-radius: 2px; background: var(--pill); overflow: hidden; }
|
||||
.quota-track i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
|
||||
/* a provider's accounts together (CryptoSarom on X): a quiet inset under
|
||||
the card's head, each window's figure over a thin bar, side by side
|
||||
while they fit, the accounts as they were below it */
|
||||
.quota-all { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; padding: 8px 10px 9px; border-radius: 8px; background: color-mix(in srgb, var(--fg) 4%, transparent); font-size: 10.5px; color: var(--muted); }
|
||||
.quota-all-head { flex-basis: 100%; color: var(--faint); font-weight: 600; cursor: help; }
|
||||
.quota-all-head { flex-basis: 100%; color: var(--muted); font-weight: 600; cursor: help; }
|
||||
.quota-all-w { flex: 1 1 130px; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 6px; min-width: 0; cursor: help; }
|
||||
.quota-all-name { min-width: 0; overflow-wrap: anywhere; }
|
||||
.quota-all-n { min-width: 0; color: var(--fg-2); font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
|
||||
.quota-all-bar { flex-basis: 100%; height: 3px; margin-top: 2px; border-radius: 2px; background: var(--pill); overflow: hidden; }
|
||||
.quota-all-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
|
||||
.quota-all-bar.full i { background: var(--amber); }
|
||||
.quota-all-unknown { flex-basis: 100%; color: var(--faint); cursor: help; }
|
||||
.quota-all-unknown { flex-basis: 100%; color: var(--muted); cursor: help; }
|
||||
/* in the panel, between the vendor's head and its accounts' cards */
|
||||
.quota-all.pq-all { margin: 0; padding: 7px 12px 8px; border-radius: 10px; font-size: 11px; }
|
||||
.subscription-error { font-size: 11px; color: var(--faint); }
|
||||
.subscription-error { font-size: 11px; color: var(--muted); }
|
||||
/* the way to the provider's settings, on a plan card that needs its access key (#1821) */
|
||||
.subscription-error .quota-fix { font: inherit; color: var(--accent); padding: 0; background: none; border: 0; cursor: pointer; }
|
||||
/* WorkBuddy's credits a day (#568): the period's sum over a bar a day; a
|
||||
@@ -1037,13 +1044,13 @@ body.window .field.solo { grid-column: auto; }
|
||||
.credit-days .cd-day { flex: 1; height: 100%; display: flex; align-items: flex-end; border-radius: 2px; background: var(--pill); }
|
||||
.credit-days .cd-day.unknown { background: none; outline: 1px dashed var(--line); outline-offset: -1px; }
|
||||
.credit-days .cd-day i { display: block; width: 100%; border-radius: 2px; background: var(--accent); }
|
||||
.credit-days .cd-note { margin-top: 4px; font-size: 10px; color: var(--faint); }
|
||||
.credit-days .cd-note { margin-top: 4px; font-size: 10px; color: var(--muted); }
|
||||
/* what was left over time (#651): a line a window, an even burn dashed, now
|
||||
upright; the range (or Off) is picked once, in the allowances' head */
|
||||
.quota-head .quota-trend { margin-right: 8px; }
|
||||
.quota-curve { margin-top: 10px; }
|
||||
.quota-curve .qc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 10.5px; color: var(--muted); }
|
||||
.quota-curve .qc-range { font-size: 10px; color: var(--faint); }
|
||||
.quota-curve .qc-range { font-size: 10px; color: var(--muted); }
|
||||
.quota-curve button.qc-range { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; padding: 0; }
|
||||
.quota-curve button.qc-range:disabled { opacity: 1; cursor: default; }
|
||||
.quota-curve .qc-plot { display: block; width: 100%; height: 52px; margin-top: 5px; overflow: hidden; }
|
||||
@@ -1055,7 +1062,7 @@ body.window .field.solo { grid-column: auto; }
|
||||
.balance-curve .qc-range { color: var(--muted); }
|
||||
.quota-curve .qc-head > span:first-child { flex: none; }
|
||||
.quota-curve .qc-pace { font-size: 10px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.balance-curve .bc-pace { color: var(--faint); }
|
||||
.balance-curve .bc-pace { color: var(--muted); }
|
||||
.qc-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
|
||||
.qc-line { fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
|
||||
/* a window far shorter than the span drawn (a 5-hour one over a week) is a
|
||||
@@ -1063,7 +1070,7 @@ body.window .field.solo { grid-column: auto; }
|
||||
.qc-line.qc-short { stroke-width: 1; opacity: .45; }
|
||||
.qc-even { stroke-width: 1; stroke-dasharray: 3 3; opacity: .45; vector-effect: non-scaling-stroke; }
|
||||
.qc-now { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 1 2; vector-effect: non-scaling-stroke; }
|
||||
.quota-curve .qc-axis { display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
||||
.quota-curve .qc-axis { display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
||||
.quota-curve .qc-legend { display: flex; flex-wrap: wrap; gap: 3px 12px; margin-top: 5px; font-size: 10.5px; color: var(--muted); }
|
||||
/* a key never breaks inside: a long name ends in … rather than its % on a line of its own */
|
||||
.qc-key { display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: 100%; white-space: nowrap; }
|
||||
@@ -1147,7 +1154,7 @@ body.masked :hover > .acct-eye, body.masked .pq-card:hover .acct-eye, body.maske
|
||||
.bal-part.lead b { font-size: 15px; color: var(--fg); }
|
||||
.bal-part .quota-track, .pq-card.bal .quota-track { grid-column: 1 / -1; margin-top: 4px; }
|
||||
.quota-track.full i { background: var(--amber); }
|
||||
.quota-read { flex-basis: 100%; margin-top: 2px; font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }
|
||||
.quota-read { flex-basis: 100%; margin-top: 2px; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
|
||||
.quota-windows + .quota-read, .quota-balance + .quota-read { margin-top: 8px; }
|
||||
.quota-read.stale { color: var(--amber); }
|
||||
/* a card's own refresh, right after when it was read (or why it couldn't
|
||||
@@ -1984,7 +1991,7 @@ body.panel .profiles #save { height: 25px; } /* the field's: the line keeps its
|
||||
.pq-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 10px 12px; border-radius: 11px; background: var(--card); box-shadow: var(--card-edge); }
|
||||
.pq-who { display: flex; align-items: center; gap: 2px; min-width: 0; }
|
||||
.pq-user { flex: 0 1 auto; min-width: 0; font-size: 12.5px; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.pq-sub { font-size: 11px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
|
||||
.pq-sub { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
|
||||
.pq-sub.err { color: var(--muted); white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
|
||||
/* a line with the card's refresh: the words shorten, the refresh keeps
|
||||
its slot at their end (#3569: Chinese pushed it out of the ellipsis) */
|
||||
@@ -1999,7 +2006,7 @@ body.panel .profiles #save { height: 25px; } /* the field's: the line keeps its
|
||||
.pq-dial b { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--card); font-size: 9.5px; font-weight: 600; color: var(--fg-2); font-variant-numeric: tabular-nums; }
|
||||
.pq-ring.full .pq-dial { background: conic-gradient(var(--amber) calc(var(--p) * 1%), color-mix(in srgb, var(--amber) 18%, transparent) 0); }
|
||||
.pq-ring.full b { color: var(--fg); }
|
||||
.pq-rn { max-width: 44px; font-size: 9.5px; line-height: 1.2; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.pq-rn { max-width: 44px; font-size: 9.5px; line-height: 1.2; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.pq-rn2 { display: flex; flex-direction: column; align-items: center; }
|
||||
.pq-rn2 > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
|
||||
/* the first window's current cycle, a thin line across the card (#651) */
|
||||
@@ -2014,7 +2021,7 @@ body.panel .profiles #save { height: 25px; } /* the field's: the line keeps its
|
||||
.pq-resets { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin-top: 5px; padding-top: 7px; border-top: 1px solid var(--line-2); font-size: 11px; font-variant-numeric: tabular-nums; }
|
||||
.resets-words { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.resets-n { color: var(--fg-2); }
|
||||
.resets-until { color: var(--faint); }
|
||||
.resets-until { color: var(--muted); }
|
||||
.pq-use { margin-left: auto; flex: none; height: 20px; padding: 0 9px; border-radius: 999px; background: color-mix(in srgb, var(--fg) 7%, transparent); color: var(--fg-2); font-size: 11px; white-space: nowrap; transition: background .12s, color .12s; }
|
||||
.pq-use:hover { background: color-mix(in srgb, var(--fg) 12%, transparent); color: var(--fg); }
|
||||
/* a Codex account spending its resets by itself (#719): a standing say of
|
||||
@@ -2039,7 +2046,7 @@ body.panel .profiles #save { height: 25px; } /* the field's: the line keeps its
|
||||
.acc .acc-tools > .acc-credits { order: 1; flex-basis: 100%; display: flex; align-items: flex-start; gap: 8px; min-width: 0; margin-top: 2px; color: var(--muted); font-size: 11px; }
|
||||
.ar-say { flex: 1; min-width: 0; line-height: 1.35; }
|
||||
.ar-say b { font-weight: 500; color: var(--fg-2); }
|
||||
.ar-used { display: block; margin-top: 2px; color: var(--faint); }
|
||||
.ar-used { display: block; margin-top: 2px; color: var(--muted); }
|
||||
.pq-opts-fold { float: right; display: inline-grid; place-items: center; width: 18px; height: 16px; margin: 0 0 0 4px; padding: 0; border-radius: 4px; color: var(--faint); transition: background .12s, color .12s; }
|
||||
.pq-opts-fold:hover { background: var(--pill); color: var(--fg-2); }
|
||||
.pq-opts-fold svg { transform: rotate(180deg); transition: transform .15s ease-out; }
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// A usage card's captions read on the card (Jiabubu on Discord, #feedback):
|
||||
// "重置于 …", "本周期" and a curve's dates were --faint, 1.95:1 on a light
|
||||
// card and 2.16:1 on a dark one. Now every caption on a Usage card, and on
|
||||
// the tray panel's allowance card, is at WCAG AA (4.5:1) or better against
|
||||
// the card, and still below the card's figures. In both engines, light and
|
||||
// dark, every language, at a wide and a narrow window.
|
||||
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 H = 3600e3;
|
||||
const iso = (ms) => new Date(ms).toISOString();
|
||||
|
||||
function data(now) {
|
||||
const r5 = now + 2 * H, rw = now + 3 * 24 * H;
|
||||
const quotas = [
|
||||
{ provider: "codex", name: "Codex", icon: "openai", plan: "Plus", user: "a@x.com", readAt: iso(now), windows: [
|
||||
{ name: "5 hours", used: 40, resetsAt: iso(r5) }, { name: "Weekly", used: 30, resetsAt: iso(rw) }] },
|
||||
];
|
||||
const five = [], week = [];
|
||||
for (let m = 0; m <= 180; m += 30) five.push({ at: iso(r5 - 5 * H + m * 60e3), left: 100 - m / 3, start: iso(r5 - 5 * H), resetsAt: iso(r5) });
|
||||
for (let h = 90; h >= 0; h -= 6) week.push({ at: iso(now - h * H), left: 70 + h / 9, start: iso(rw - 168 * H), resetsAt: iso(rw) });
|
||||
return { quotas, history: [{ provider: "codex", user: "a@x.com", lines: [{ name: "5 hours", points: five }, { name: "Weekly", points: week }] }] };
|
||||
}
|
||||
|
||||
function serve(lang, theme, web) {
|
||||
const settings = { theme, lang, tray: "panel", quotaLeft: false, currency: "usd" };
|
||||
const d = data(Date.now());
|
||||
return async (r) => {
|
||||
const url = new URL(r.request().url());
|
||||
const json = (b) => r.fulfill({ json: b });
|
||||
if (url.pathname === "/boot.js") return r.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"${theme}",web:${web}};` });
|
||||
if (url.pathname === "/wails/runtime.js") return r.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json({ agents: [{ id: "codex", name: "Codex", path: "/test/codex", fields: [] }], profiles: [], settings });
|
||||
if (url.pathname === "/api/settings") return json(settings);
|
||||
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 === "/api/usage/quotas") return json(d.quotas);
|
||||
if (url.pathname === "/api/usage/quotas/history/holds") return json([]);
|
||||
if (url.pathname === "/api/usage/quotas/history") return json(d.history);
|
||||
if (url.pathname === "/api/usage") return json({ calls: 0, input: 0, output: 0, cost: 0, agents: [], accounts: [], models: [], series: [], days: [] });
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
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 r.fulfill({ body: await fs.readFile(file), contentType }); } catch { await r.fulfill({ status: 404, body: "" }); }
|
||||
};
|
||||
}
|
||||
|
||||
// each element's contrast against the first opaque background behind it
|
||||
const ratios = ([card, sels]) => {
|
||||
const rgb = (s) => { const m = s.match(/[\d.]+/g).map(Number); return { r: m[0], g: m[1], b: m[2], a: m[3] ?? 1 }; };
|
||||
const lum = ({ r, g, b }) => { const f = (c) => { c /= 255; return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4; }; return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b); };
|
||||
const bgOf = (e) => { for (let x = e; x; x = x.parentElement) { const c = rgb(getComputedStyle(x).backgroundColor); if (c.a > 0.5) return c; } return { r: 255, g: 255, b: 255 }; };
|
||||
const out = [];
|
||||
for (const sel of sels) {
|
||||
for (const e of document.querySelectorAll(card + " " + sel)) {
|
||||
if (!e.getClientRects().length || !e.textContent.trim()) continue;
|
||||
let op = 1;
|
||||
for (let x = e; x; x = x.parentElement) op *= parseFloat(getComputedStyle(x).opacity);
|
||||
const fg = rgb(getComputedStyle(e).color), bg = bgOf(e), a = fg.a * op;
|
||||
const mix = { r: fg.r * a + bg.r * (1 - a), g: fg.g * a + bg.g * (1 - a), b: fg.b * a + bg.b * (1 - a) };
|
||||
const L1 = lum(mix), L2 = lum(bg);
|
||||
out.push({ sel, text: e.textContent.trim().slice(0, 24), ratio: (Math.max(L1, L2) + 0.05) / (Math.min(L1, L2) + 0.05) });
|
||||
}
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
const captions = [".quota-reset", ".qc-range", ".qc-axis", ".qc-pace", ".quota-read", ".quota-labels"];
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
test(`${engine}: a usage card's captions read at 4.5:1 on the card, below its figures`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
for (const theme of ["light", "dark"]) {
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
for (const width of [900, 420]) {
|
||||
const where = `${theme} ${lang} ${width}`;
|
||||
const ctx = await browser.newContext({ viewport: { width, height: 700 }, reducedMotion: "reduce", colorScheme: theme });
|
||||
const errors = [];
|
||||
const page = await ctx.newPage();
|
||||
page.setDefaultTimeout(8000);
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang, theme, true));
|
||||
await page.goto("http://magpie.test/?view=usage");
|
||||
await page.locator(".subscription-card .quota-curve").first().waitFor();
|
||||
const caps = await page.evaluate(ratios, [".subscription-card", captions]);
|
||||
for (const sel of [".quota-reset", ".qc-range", ".qc-axis"]) assert.ok(caps.some((c) => c.sel === sel), `${where}: ${sel} shows`);
|
||||
for (const c of caps) assert.ok(c.ratio >= 4.5, `${where}: ${c.sel} "${c.text}" reads at ${c.ratio.toFixed(2)}:1`);
|
||||
const [fig] = await page.evaluate(ratios, [".subscription-card", [".quota-n"]]);
|
||||
assert.ok(fig, `${where}: a figure shows`);
|
||||
for (const c of caps) assert.ok(fig.ratio > c.ratio + 1.5, `${where}: the figure (${fig.ratio.toFixed(2)}:1) stands above ${c.sel} (${c.ratio.toFixed(2)}:1)`);
|
||||
assert.deepEqual(errors, [], where);
|
||||
await ctx.close();
|
||||
}
|
||||
// the tray panel's Allowances tab
|
||||
const ctx = await browser.newContext({ viewport: { width: 360, height: 640 }, reducedMotion: "reduce", colorScheme: theme });
|
||||
await ctx.addInitScript(() => { try { localStorage.setItem("magpie.panelTab", "usage"); } catch {} });
|
||||
const panel = await ctx.newPage();
|
||||
panel.setDefaultTimeout(8000);
|
||||
await panel.route("**/*", serve(lang, theme, false));
|
||||
await panel.goto("http://magpie.test/?mode=panel");
|
||||
await panel.locator(".pq-card .pq-sub").first().waitFor();
|
||||
const pcaps = await panel.evaluate(ratios, [".pq-card", [".pq-sub", ".pq-rn"]]);
|
||||
assert.ok(pcaps.length, `${theme} ${lang} panel: a caption shows`);
|
||||
for (const c of pcaps) assert.ok(c.ratio >= 4.5, `${theme} ${lang} panel: ${c.sel} "${c.text}" reads at ${c.ratio.toFixed(2)}:1`);
|
||||
await ctx.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -91,7 +91,9 @@ for (const [name, engine] of [["webkit", webkit], ["chromium", chromium]]) {
|
||||
return {
|
||||
text: l.textContent, title: l.title, window: l.closest(".quota").querySelector(".quota-labels > span").textContent,
|
||||
inReset: !!l.closest(".quota-reset"), cut: l.scrollWidth > l.clientWidth + 1, inCard: b.left >= card.left - 1 && b.right <= card.right + 1,
|
||||
muted: Number(cs.opacity) < 1 && cs.color === getComputedStyle(l.closest(".quota-reset")).color,
|
||||
// muted as the reset line is: its caption colour, not faded below it
|
||||
// (a card's captions read at 4.5:1, Jiabubu)
|
||||
muted: cs.color === getComputedStyle(l.closest(".quota-reset")).color && cs.color !== getComputedStyle(l.closest(".quota")).color,
|
||||
};
|
||||
}),
|
||||
pageScroll: document.documentElement.scrollWidth > document.documentElement.clientWidth + 1,
|
||||
|
||||
Reference in New Issue
Block a user