settings › allowances: the alerts under an Alerts heading, and no empty Menu bar cost row in magpie web
The scattered settings audit after netube99 on X found Task done alert filed among the allowances' display rows, with nothing saying why, and magpie web drawing Menu bar cost as a row with no control (it has no menu bar, and renderTrayUsage returns before filling it there). - Allowance alert, Low balance alert, Reset reminder and Task done alert are now a list of their own under an "Alerts" heading (#alertHead, #alertList), after the display rows. Gateway mode hides the heading and the list, as it hid the four rows. - #trayCostRow is app-only, as #trayUsageRow is. - "Alerts" in zh, zh-TW, ja, de. Run (mote, at this tree): - settings-places (new), bare-ids, turn-done, usage-alert, reset-reminder, mask-alert, settings-search, i18n-keys: 122 pass, 0 fail, both engines. - go test -run "Budget|I18n" ./internal/gui: ok. Broken by hand: without app-only, settings-places is red 10 of 10 on "no Menu bar cost row in magpie web"; with the heading renamed, red 10 of 10. Not tried: the real app; the row moves are markup only.
This commit is contained in:
@@ -20182,7 +20182,7 @@ function renderSettings() {
|
||||
}
|
||||
// gateway mode leaves out what is written into this computer's agents'
|
||||
// files, and the alerts its desktop would show
|
||||
for (const r of [$("#plainNamesSegs").parentElement, $("#usageAlertRow"), $("#balanceAlertRow"), $("#resetReminderRow"), $("#turnDoneRow")]) r.hidden = gatewayMode;
|
||||
for (const r of [$("#plainNamesSegs").parentElement, $("#alertHead"), $("#alertList")]) r.hidden = gatewayMode;
|
||||
// the parts' tabs, one gone whose rows are all hidden here
|
||||
setSetTab(setTab);
|
||||
}
|
||||
|
||||
@@ -1279,6 +1279,7 @@ const I18N = {
|
||||
"万 / 亿": "中文(万 / 亿)",
|
||||
"K / M / B": "英文(K / M / B)",
|
||||
"Allowance alert": "额度提醒",
|
||||
"Alerts": "提醒",
|
||||
"Low balance alert": "余额提醒",
|
||||
"A notification when a 5-hour, weekly or monthly window reaches this share used, once each time it runs": "5 小时、每周或每月额度已用掉的比例达到此值时通知,每个周期一次",
|
||||
"A notification when a balance falls to this amount, in its own currency or credits, once until it is topped up": "余额降到此数(按其货币或积分计)时通知,充值前只提醒一次",
|
||||
@@ -6061,6 +6062,7 @@ const I18N = {
|
||||
"万 / 亿": "中文(萬 / 億)",
|
||||
"K / M / B": "英文(K / M / B)",
|
||||
"Allowance alert": "額度提醒",
|
||||
"Alerts": "提醒",
|
||||
"Low balance alert": "餘額提醒",
|
||||
"A notification when a 5-hour, weekly or monthly window reaches this share used, once each time it runs": "5 小時、每週或每月額度已用掉的比例達到此值時通知,每個週期一次",
|
||||
"A notification when a balance falls to this amount, in its own currency or credits, once until it is topped up": "餘額降到此數(按其貨幣或積分計)時通知,充值前只提醒一次",
|
||||
@@ -10804,6 +10806,7 @@ const I18N = {
|
||||
"万 / 亿": "万 / 億",
|
||||
"K / M / B": "K / M / B",
|
||||
"Allowance alert": "利用枠アラート",
|
||||
"Alerts": "通知",
|
||||
"Low balance alert": "残高不足アラート",
|
||||
"A notification when a 5-hour, weekly or monthly window reaches this share used, once each time it runs": "5 時間・週・月の利用枠の使用率がこの割合に達したときに通知します(期間ごとに 1 回)",
|
||||
"A notification when a balance falls to this amount, in its own currency or credits, once until it is topped up": "残高がこの額(その残高自身の通貨またはクレジット)まで減ったときに通知します(チャージされるまで 1 回)",
|
||||
@@ -15582,6 +15585,7 @@ const I18N = {
|
||||
"万 / 亿": "Chinesisch (万 / 亿)",
|
||||
"K / M / B": "K / M / B",
|
||||
"Allowance alert": "Kontingent-Warnung",
|
||||
"Alerts": "Benachrichtigungen",
|
||||
"Low balance alert": "Warnung bei niedrigem Guthaben",
|
||||
"A notification when a 5-hour, weekly or monthly window reaches this share used, once each time it runs": "Eine Benachrichtigung, wenn ein 5-Stunden-, Wochen- oder Monatszeitfenster diesen Verbrauchsanteil erreicht, einmal pro Durchlauf",
|
||||
"A notification when a balance falls to this amount, in its own currency or credits, once until it is topped up": "Eine Benachrichtigung, wenn ein Guthaben auf diesen Betrag fällt (in eigener Währung oder Credits), einmal bis zur Aufladung",
|
||||
|
||||
@@ -285,7 +285,7 @@
|
||||
<div class="who"><div class="name" data-t>Menu bar pace</div><div class="sub" data-t>Each window's Pace number beside its figure, as on the Usage page: +12% is 12% more of the window used than an even pace would have used by now, −8% that much less</div></div>
|
||||
<div id="trayPaceSegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="trayCostRow">
|
||||
<div class="row pref app-only" id="trayCostRow">
|
||||
<div class="who"><div class="name" data-t>Menu bar cost</div><div class="sub" data-t>What magpie's requests cost, beside their tokens in the menu bar and its tooltip; off, the tokens alone</div></div>
|
||||
<div id="trayCostSegs"></div>
|
||||
</div>
|
||||
@@ -309,6 +309,10 @@
|
||||
<div class="who"><div class="name" data-t>Number units</div><div class="sub" data-t>How a large count of tokens or requests is shortened on the Usage page and the panel</div></div>
|
||||
<div id="unitsSegs"></div>
|
||||
</div>
|
||||
<div id="provPrefLinks"></div>
|
||||
</div>
|
||||
<div class="row-head" id="alertHead"><span class="label" data-t>Alerts</span></div>
|
||||
<div class="list prefs" id="alertList">
|
||||
<div class="row pref" id="usageAlertRow">
|
||||
<div class="who"><div class="name" data-t>Allowance alert</div><div class="sub" id="usageAlertSub"></div></div>
|
||||
<div id="usageAlertSegs" class="warm-at"></div>
|
||||
@@ -325,7 +329,6 @@
|
||||
<div class="who"><div class="name" data-t>Task done alert</div><div class="sub" id="turnDoneSub"></div></div>
|
||||
<div id="turnDoneSegs"></div>
|
||||
</div>
|
||||
<div id="provPrefLinks"></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="set-page" id="setPage-network" role="tabpanel" aria-labelledby="setTab-network">
|
||||
|
||||
@@ -99,7 +99,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const segs = page.locator("#bareIdsSegs .opt");
|
||||
await segs.first().waitFor();
|
||||
const row = page.locator("#bareIdsRow");
|
||||
assert.equal(await page.locator("#usageAlertRow").evaluate((r) => r.hidden), gateway, "gateway mode as faked");
|
||||
assert.equal(await page.locator("#alertList").evaluate((r) => r.hidden), gateway, "gateway mode as faked");
|
||||
assert(await row.isVisible(), "the row is drawn");
|
||||
assert.equal((await row.locator(".name").textContent()).trim(), w.name);
|
||||
assert((await row.locator(".sub").textContent()).includes(w.sub), "the sub says what it does");
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// Settings' rows where their feature is (the scattered settings audit after
|
||||
// netube99 on X): magpie web draws no empty Menu bar cost row, as it has no
|
||||
// menu bar; the alerts (allowance, balance, reset, task done) sit under
|
||||
// their own Alerts heading, not among the allowances' display. Every
|
||||
// language, Chromium and WebKit, at 1100 and 420 wide, nothing past the
|
||||
// window's edge. No backend, the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
|
||||
function server(lang, web) {
|
||||
const cur = {
|
||||
theme: "light", lang, tray: "panel", quotaLeft: false, currency: "usd", textSize: 100,
|
||||
version: "0.1.400", dir: "~/.config/magpie", gateway: "http://127.0.0.1:3425",
|
||||
proxyNow: "none", proxySource: "none", login: false, trayUsage: "", trayUsageEvery: 3,
|
||||
visionModels: [], imageGenModels: [], lanURLs: [],
|
||||
fx: { rate: 7.2, at: new Date().toISOString(), stale: false },
|
||||
};
|
||||
return async (route) => {
|
||||
const req = route.request(), url = new URL(req.url());
|
||||
const json = (data) => route.fulfill({ json: data });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:${web},textSize:100};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light", textSize: 100 }, fx: cur.fx });
|
||||
if (url.pathname === "/api/settings") return json(cur);
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/providers") return json({ providers: [] });
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
|
||||
if (url.pathname === "/api/window/fit") return route.fulfill({ status: 204 });
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
await route.fulfill({ body: await fs.readFile(file), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
const fits = (page) => page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth + 1);
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
for (const width of [1100, 420]) {
|
||||
test(`${engine} ${lang} ${width}: Settings' rows sit with their feature`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const open = async (web, view) => {
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" })).newPage();
|
||||
page.setDefaultTimeout(6000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
page.errors = [];
|
||||
page.on("pageerror", (e) => { if (engine === "webkit" && /due to access control checks/.test(e.message)) return; page.errors.push(e.message); });
|
||||
await page.route("**/*", server(lang, web));
|
||||
await page.goto("http://magpie.test/?view=" + view);
|
||||
return page;
|
||||
};
|
||||
const tr = (page, s) => page.evaluate((s) => t(s), s);
|
||||
|
||||
// the app: the alerts under their own heading, after the display's rows
|
||||
let page = await open(false, "settings&tab=usage");
|
||||
await page.locator("#currencySegs .opt").first().waitFor();
|
||||
const head = page.locator("#alertHead");
|
||||
assert(await head.isVisible(), "Alerts' heading shows");
|
||||
assert.equal((await head.textContent()).trim(), await tr(page, "Alerts"));
|
||||
for (const id of ["usageAlertRow", "balanceAlertRow", "resetReminderRow", "turnDoneRow"]) {
|
||||
assert.equal(await page.locator(`#alertList > #${id}`).count(), 1, id + " under Alerts");
|
||||
}
|
||||
assert(await page.evaluate(() => document.querySelector("#currencySegs").compareDocumentPosition(document.querySelector("#alertHead")) & Node.DOCUMENT_POSITION_FOLLOWING), "after the display's rows");
|
||||
assert(await page.locator("#trayCostRow").isVisible(), "the app has a menu bar");
|
||||
assert(await fits(page), "fits");
|
||||
assert.deepEqual(page.errors, []);
|
||||
|
||||
// magpie web: no menu bar, so no empty Menu bar cost row
|
||||
page = await open(true, "settings&tab=usage");
|
||||
await page.locator("#currencySegs .opt").first().waitFor();
|
||||
assert.equal(await page.locator("#trayCostRow").isVisible(), false, "no Menu bar cost row in magpie web");
|
||||
assert(await fits(page), "fits in magpie web");
|
||||
assert.deepEqual(page.errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user