gui: Hide accounts is one switch for every page, window and the panel (paultian)
paultian on Discord (#feedback): Routing, Usage and Providers each kept their own "Hide accounts" state, so turning it on in one page left the others showing emails. Now window.hideAccounts is one switch, one localStorage value (magpie.maskEmails), behind #rtMask, #usageMask and #pvMask alike. Flipping it in any page applies to every page at once, and a storage event carries it to other windows and the tray panel. The old magpie.maskProviders value is folded in on first load (hidden if either value was on) and then removed, so nobody who hid accounts on one page sees them shown after updating. The tooltip and the Settings line now say "on every page" instead of "on this page", in every language. Tests: provider-mask.test.cjs checks that one switch hides accounts on every page and in a second window, that the state survives a reload, and that an old maskProviders=1 comes through as hidden. account-mask's expected tooltip text is updated. Run on mote (GUI files at base 05aba5ca4; the Go asset/budget tests again at this head after rebasing ona92cc3f33): - go test -run 'Budget|I18n|Asset|Script|Strings|Lang' ./internal/gui: ok - The masking/privacy GUI files at --test-concurrency=2, chromium and webkit, every language (account-mask-alias-plan, account-eye, window-mask, usage-fold, masking-demo-unblurred, account-alias, provider-mask, account-eye-provider, account-mask, privacy-hides-accounts, account-mask-sessions, mask-emails, plugin-name-unmasked, i18n-keys, masking-records): 403 of 408 pass. The 5 reds: - provider-mask "chromium en 420" (a click timed out). Rerun with usage-fold at concurrency 1: provider-mask is all green, and that run is 146 of 150. - usage-fold, 4 subtests: "17 subscriptions and 29 accounts" in chromium and webkit, and "several accounts" in webkit en and zh. They fail the same 4 at origin/main625938a2fat concurrency 1 (6 of 10 pass). That is #3415 / #4790, not this change. - Not touched: Go code, so no go vet. Broken by hand: with the old assets, provider-mask's one-switch tests go red; with the maskProviders migration taken out, the old-value-comes-through test goes red. Not tried: the whole GUI suite (the owner's rule is to ship each verified fix right away), and the real tray panel on Windows/Linux following a switch flipped in the main window. Only the browser storage event is tested.
This commit is contained in:
@@ -556,7 +556,7 @@ covers it in both engines, every language and a narrow window.
|
||||
- In Usage → Allowances, Trends → Cycle offers each account's own recorded cycle menu beside its curve (`quotaCurve`, `quotaRecordedCycles` in [`app.js`](../../internal/gui/assets/app.js)). The longest window (usually weekly) owns the menu; shorter windows are drawn over the selected dates with their own reset breaks. `/api/usage/quotas/history?days=45` supplies all retained readings, including remote cards. Completed cycles come from observed boundaries, not seven-day arithmetic; an early reset ends the previous cycle at the vendor's new start if it fits between readings, otherwise at the first new reading. Each menu option gives its observed duration, so an early reset is not labelled as a full seven days. The selected meters, plot, legend, tooltip and dashed pace use that cycle's last readings, never today's percentages. A window without a reading in the selected interval says so instead of showing a current value. A local account's past cycle asks `/api/usage/quotas/history/holds?provider=&user=&from=&to=` once per selection (`quotaCycleHoldsOf`), which asks no vendor (#2009, NorethSea): `HistoricalWindowHolds` in [`window_holds_history.go`](../../internal/usage/window_holds_history.go) reckons each window's whole at its own last reading in that cycle, from the request log up to that reading, so the 5-hour figure is the cycle's last 5-hour window, never its short windows added up. Its tooltip names that window's start and the reading's time. It shows "Loading…" until the answer comes. A window it can't reckon says "not enough data" with the reason, as a current card does; a reply that comes after another cycle was picked is dropped, and a card's Refresh or an asked read reckons again. Historical meters show the cycle end and sampling time; current account actions, balances and policies are left out until returning to the current view. Accounts are independent, and a selection survives card refreshes in the same page. Trends → 2 days temporarily shows recent readings; Off removes the curves; the tray always shows its current cycle. See `quota-curve.test.cjs` and the [history limits and reset inference](providers-accounts.md#constraints-and-failure-behavior).
|
||||
- The Usage page's cards are packed into columns, never all stretched to a row's height (`packUsage`, #860): each card in that order goes to the leftmost column that ends highest, on 1px grid rows, so short cards stack beside a tall one. The last card in each column then reaches down to where the tallest column ends (a `min-height`, cleared before the cards are measured again), so cards side by side in one row are as tall as each other and a stack ends with the tall card beside it (ikunbots on X); content stays at each card's top. The page's order (DOM, dragging, Alt+arrows) stays `UsageOrder`. The column count is the most 260px columns that fit, or one fewer when that leaves much less empty room; it is chosen again only when the cards change or the width fits another number of columns, so a card opened or folded stays where it is, even as the scrollbar comes in. See `usage-pack.test.cjs`.
|
||||
- The Providers page has a search box over its list (#1614, `findProviders` in [`app.js`](../../internal/gui/assets/app.js)): the words typed keep the rows, on and off, whose text or data say them all: name, id, preset, addresses, every model's id and name, the account's user and plan and each login's, account names and key names. The Turned off fold stays open while searching; Escape or clearing the box shows every row and the fold as it was. A row that is on reorders by dragging its logo, Alt+↑/↓, Alt+Shift+↑/↓ (top, bottom) or its right-click menu (`openProviderMenu`: Move to top, Move up, Move down, Move to bottom). While searching, a step or a drop moves it among the rows shown (it takes the place of the row it passes, `stepProvider`, `shownToOn`) and the hidden ones keep their order; Move to top and Move to bottom go to the ends of the whole list. Every move saves the whole order through `POST /api/providers/arrange`. See `provider-find.test.cjs` and `provider-order.test.cjs`.
|
||||
- Hide accounts (`window.hideAccounts` at the end of [`app.js`](../../internal/gui/assets/app.js)) masks every account name and address in the window's text and tooltips, its menus and dialogs too, by the switch of the page in sight (`cur`, again on each `show`). Routing's and Usage's buttons, and Settings › Privacy's row, are one switch, stored in `magpie.maskEmails`, which the panel follows; the Providers page has its own (`#pvMask` beside its search box, `magpie.maskProviders`), so Routing's leaves Providers alone (a Discord user in #feedback). A `magpie.maskProviders` not stored yet starts from `magpie.maskEmails`, so one who had it on before keeps Providers hidden; while neither is chosen, both follow Mask personal data, and turning that on (`set(true, true)`) turns both on (`provider-mask.test.cjs`). While it is on, an account's name on the provider editor's row (`accountNameButton`, and the one-account line) and on its Usage card (`quotaWho`), and on the tray panel's Usage card (`panelQuotaCard`'s `.pq-who`, in sight while the card is hovered), has an eye (`hideAccounts.eye`), in sight on hover or keyboard focus. A click shows that one account, its address and the name the user gave it together (`kin`), everywhere that page draws it, tooltips included, while the others stay hidden (yogurt36 on Discord, for a screen share). The accounts shown are a set held in memory that `hits()` skips; nothing stores them. The window and the panel are pages of their own, each with its own set: one shown in the window stays hidden in the panel and the other way round, so a screenshot of either shows only what was shown there. Closing the window hides them again: the page stays loaded while the window is hidden, so `hideMain` runs `mainClosedJS` (`hideAccounts.closed`) first. Putting the panel away hides the panel's again, from its `visibilitychange` (the one that drops `panelPeek`) (`account-eye.test.cjs`, `TestClosingHidesShownAccounts`). What it hides is the accounts: their addresses, their vendors' values (`user`, `account`, Routing's `who`) and a name that stands for one, a plugin's (`accountUsers`, a card's `alias` without `named`) or a seat's. The name the user gave an account (`AccountNames`; a card's `alias` with `named`, which `withAccountNames` sets) is no account and stays in sight, beside the account it names, hidden (faketrader in #3656: several accounts couldn't be told apart). A label is scoped by its element, never by its value: in the user's own name (`.own-name`), a plan (`.plan`, the Providers row's `.acct-plan`), a model (`.model-value`) and a Usage card's title (`.subscription-head > b`) only an address is hidden, so an Antigravity account whose value is "Google" leaves "Google AI Pro" readable while an address written in a plan is still hidden; the same holds for the tooltips of plans and models (`TIPS`), not for the own name's, which says the account (`LABELS` in app.js, `account-mask-alias-plan.test.cjs`). The tray panel card's tooltip joins the account and the plan in one string, and still hides a plan's word that is an account's value.
|
||||
- Hide accounts (`window.hideAccounts` at the end of [`app.js`](../../internal/gui/assets/app.js)) masks every account name and address in the window's text and tooltips, its menus and dialogs too, by one switch for the whole window and the tray panel. Routing's, Usage's and Providers' buttons (`#rtMask`, `#usageMask`, `#pvMask` beside Providers' search box) and Settings › Privacy's row are that one switch, stored in `magpie.maskEmails`: turned on any page, every page is hidden and every button says so, and another window or the panel follows through the `storage` event (paultian in #feedback: Providers had a switch of its own, so one page was hidden while another wasn't). A `magpie.maskProviders` left by the versions that had Providers' own switch is folded in once and removed: hidden on either page then is hidden everywhere now. While it is not chosen, it follows Mask personal data, and turning that on turns it on (`provider-mask.test.cjs`). While it is on, an account's name on the provider editor's row (`accountNameButton`, and the one-account line) and on its Usage card (`quotaWho`), and on the tray panel's Usage card (`panelQuotaCard`'s `.pq-who`, in sight while the card is hovered), has an eye (`hideAccounts.eye`), in sight on hover or keyboard focus. A click shows that one account, its address and the name the user gave it together (`kin`), everywhere that page draws it, tooltips included, while the others stay hidden (yogurt36 on Discord, for a screen share). The accounts shown are a set held in memory that `hits()` skips; nothing stores them. The window and the panel are pages of their own, each with its own set: one shown in the window stays hidden in the panel and the other way round, so a screenshot of either shows only what was shown there. Closing the window hides them again: the page stays loaded while the window is hidden, so `hideMain` runs `mainClosedJS` (`hideAccounts.closed`) first. Putting the panel away hides the panel's again, from its `visibilitychange` (the one that drops `panelPeek`) (`account-eye.test.cjs`, `TestClosingHidesShownAccounts`). What it hides is the accounts: their addresses, their vendors' values (`user`, `account`, Routing's `who`) and a name that stands for one, a plugin's (`accountUsers`, a card's `alias` without `named`) or a seat's. The name the user gave an account (`AccountNames`; a card's `alias` with `named`, which `withAccountNames` sets) is no account and stays in sight, beside the account it names, hidden (faketrader in #3656: several accounts couldn't be told apart). A label is scoped by its element, never by its value: in the user's own name (`.own-name`), a plan (`.plan`, the Providers row's `.acct-plan`), a model (`.model-value`) and a Usage card's title (`.subscription-head > b`) only an address is hidden, so an Antigravity account whose value is "Google" leaves "Google AI Pro" readable while an address written in a plan is still hidden; the same holds for the tooltips of plans and models (`TIPS`), not for the own name's, which says the account (`LABELS` in app.js, `account-mask-alias-plan.test.cjs`). The tray panel card's tooltip joins the account and the plan in one string, and still hides a plan's word that is an account's value.
|
||||
- A new user's Agents page (the window's first page and the panel's Agents tab) has a *Get started* card above the agents in the welcome's place (wangye1644294 on X, `guideCard` in [`app.js`](../../internal/gui/assets/app.js)). Its three steps are: add a model source; connect an agent, where the agents magpie found that can be connected are named and each is connected in one click (`agents/connect`); and, optional, a routing group, with the most harmless starter template that can be made from the user's models (`provider.Templates`, Never stuck first) added in one click through `POST /api/groups/template`. Every tick comes from the state: the models magpie serves (`served` in `/api/state`, groups left out), an agent wired, or a group that isn't automatic. None comes from the card having been seen. The card goes once the first two steps are done. Its close button saves `settings.GuideHidden` through `POST /api/settings/guide`, so the panel, the window and a reload agree, and the Settings save keeps it. See `getting-started.test.cjs`.
|
||||
- A connected agent's row in the window opens and closes on a click anywhere on it that isn't one of its controls, as a disclosure row does on the Mac (NG_shiyu on X, `connectRow` in [`app.js`](../../internal/gui/assets/app.js)): the click is handed to the row's *Models {n}* link (`expandLink`), which stays the control the keyboard and a screen reader use and keeps `aria-expanded`. Buttons, links, inputs, anything with a role, the grip and the opened sheet (`.ag-exp`) keep their own clicks, and a click that ends a text selection does nothing. The panel's rows did this already (`agent-row-disclose.test.cjs`).
|
||||
- An agent whose own model menu is the list picked in magpie (ZCode, Claude Desktop, Cursor Private Inference, …: `listsMenu`) says that list as its ticks are, on its button and on the panel row (`menuSaid` in [`app.js`](../../internal/gui/assets/app.js)): every model ticked is *All N models*, one or two by their names, more as *Showing x / N models*, none as *No models*. It never says the first names and a +N: routing groups come first, so that read as a pick of one group and one model while every model was on (NG_shiyu on X). Other agents' start pickers still say the one model or group they start on (`agent-menu-label.test.cjs`).
|
||||
|
||||
+19
-14
@@ -21841,8 +21841,8 @@ function renderRedact(s, keep) {
|
||||
privacyModelRow(find, masking ? "" : why);
|
||||
const always = el("span", "static-pill" + (masking ? " on" : ""), masking ? t("Always on") : t("Off"));
|
||||
rowIn(find, t("Rules"), masking ? t("Keys, tokens, emails and numbers whose checksum adds up: patterns that are certain, checked on every request") : why, always).id = "maskRulesRow";
|
||||
// Routing's and Usage's Hide accounts, here too, where privacy is looked for
|
||||
if (window.hideAccounts) rowIn(share, t("Hide accounts"), t("Email addresses and account names on Usage and Routing are blurred, for a screenshot to share"),
|
||||
// the pages' Hide accounts, here too, where privacy is looked for
|
||||
if (window.hideAccounts) rowIn(share, t("Hide accounts"), t("Email addresses and account names on every page are blurred, for a screenshot to share"),
|
||||
onOff(window.hideAccounts.on(), (on) => { window.hideAccounts.set(on); renderSettings(); }));
|
||||
rowIn(share, t("Count me as a user"), t("Once a day, a random id for this computer with magpie's version and system"),
|
||||
onOff(!s.noStats, (on) => savePrefs({ ...keep, noStats: !on })));
|
||||
@@ -24284,17 +24284,22 @@ window.noteAccounts = noteAccounts;
|
||||
// address only, not "Google" of "Google AI Pro" (#3656); TIPS, tooltips
|
||||
const LABELS = ".own-name, .plan, .acct-plan, .model-value, .subscription-head > b", TIPS = ".plan, .acct-plan, .model-value";
|
||||
// A switch's chosen is the choice made here; till then accounts hide
|
||||
// while Privacy masks personal data (inaction). The whole window
|
||||
// follows the switch of the page in sight: Routing's and Usage's, or
|
||||
// Providers' own (#feedback). The tray panel follows the first.
|
||||
const sw = [["magpie.maskEmails", ["#rtMask", "#usageMask"]], ["magpie.maskProviders", ["#pvMask"]]].map(([k, bs]) => {
|
||||
let c = null;
|
||||
try { c = localStorage.getItem(k); } catch {}
|
||||
// while Privacy masks personal data (inaction). One switch for the whole
|
||||
// window and the tray panel: Routing's, Usage's and Providers' buttons
|
||||
// are the same switch, turned on any page and shown on all (paultian,
|
||||
// #feedback: Providers' was its own, masked while Routing's was not).
|
||||
const sw = [["magpie.maskEmails", ["#rtMask", "#usageMask", "#pvMask"]]].map(([k, bs]) => {
|
||||
let c = null, p = null;
|
||||
try { c = localStorage.getItem(k); p = localStorage.getItem("magpie.maskProviders"); } catch {}
|
||||
// Providers' own switch, from the versions that had one: hidden on
|
||||
// either page then is hidden on every page now
|
||||
if (p !== null) {
|
||||
c = c === "1" || p === "1" ? "1" : "0";
|
||||
try { localStorage.setItem(k, c); localStorage.removeItem("magpie.maskProviders"); } catch {}
|
||||
}
|
||||
return { k, c, on: c === "1", btns: mode === "panel" ? [] : bs.map((b) => $(b)).filter(Boolean) };
|
||||
});
|
||||
// one who chose before Providers had its own keeps that choice there
|
||||
if (sw[1].c === null && sw[0].c !== null) { Object.assign(sw[1], { c: sw[0].c, on: sw[0].on }); try { localStorage.setItem(sw[1].k, sw[1].c); } catch {} }
|
||||
const cur = () => sw[+(mode !== "panel" && view === "providers")];
|
||||
const cur = () => sw[0];
|
||||
let masked = false;
|
||||
const page = (() => {
|
||||
const view = document.body;
|
||||
@@ -24377,7 +24382,7 @@ window.noteAccounts = noteAccounts;
|
||||
label.textContent = t(label.dataset.en);
|
||||
// and how to have them back, for one who never turned it on (#653)
|
||||
btn.dataset.enTitle = on ? "Accounts are masked for a screenshot — click to show them"
|
||||
: "Mask the accounts on this page — email addresses and account names — for a screenshot to share";
|
||||
: "Mask the accounts on every page — email addresses and account names — for a screenshot to share";
|
||||
btn.title = t(btn.dataset.enTitle);
|
||||
}
|
||||
page(cur().on);
|
||||
@@ -24428,9 +24433,9 @@ window.noteAccounts = noteAccounts;
|
||||
closed: () => { if (shown.size) { shown.clear(); redraw(); } },
|
||||
on: () => sw[0].on,
|
||||
// all: personal data masked from now, so every page's switch too
|
||||
set: (on, all) => { for (const s of all ? sw : [sw[0]]) setMasked(s, on); },
|
||||
set: (on) => { for (const s of sw) setMasked(s, on); },
|
||||
follow: (personal) => { for (const s of sw) if (s.c === null && personal !== s.on) setMasked(s, personal, true); },
|
||||
// another page in sight: its own switch
|
||||
// another page in sight: masked as the one switch says
|
||||
page: () => { if (cur().on !== masked) page(cur().on); },
|
||||
};
|
||||
// turned in the window: the tray panel (or another window) follows
|
||||
|
||||
@@ -1339,7 +1339,7 @@ const I18N = {
|
||||
"Private, local and documentation addresses stay. Off by default: logs and configs are full of them": "内网、本机和文档示例地址不动。默认关闭:日志和配置里到处都是",
|
||||
"Cloud storage buckets": "云存储桶",
|
||||
"The bucket in s3://, gs://, oss://, cos:// and storage URLs; the path in it stays": "s3://、gs://、oss://、cos:// 和存储链接里的桶名;桶内路径不动",
|
||||
"Email addresses and account names on Usage and Routing are blurred, for a screenshot to share": "用量和路由页上的邮箱和账号名会被模糊处理,方便截图分享",
|
||||
"Email addresses and account names on every page are blurred, for a screenshot to share": "所有页面上的邮箱和账号名都会被模糊处理,方便截图分享",
|
||||
"Masked words": "脱敏词",
|
||||
"Masked words in any case": "脱敏词不区分大小写",
|
||||
"A word also matches in other capitals: Nightjar masks NIGHTJAR and nightjar too": "大小写不同也算同一个词:Nightjar 也会遮住 NIGHTJAR 和 nightjar",
|
||||
@@ -3665,7 +3665,7 @@ const I18N = {
|
||||
"A conversation stays with the account or key that answered it for the whole session, while it can answer.": "会话始终留在回答过它的账号或 Key 上,只要它仍能回答。",
|
||||
"A conversation stays put within a turn, while the agent sends tool results back; when you speak again, routing decides afresh.": "一轮之内(Agent 回传工具结果时)不换;你再次发言时,路由重新决定。",
|
||||
"Every request is routed afresh, whoever answered its conversation before.": "每个请求都重新路由,不论之前由谁回答。",
|
||||
"Mask the accounts on this page — email addresses and account names — for a screenshot to share": "给本页的账号(邮箱地址和账号名)打码,方便截图分享",
|
||||
"Mask the accounts on every page — email addresses and account names — for a screenshot to share": "给所有页面的账号(邮箱地址和账号名)打码,方便截图分享",
|
||||
"Least used": "最少使用",
|
||||
"requests": "请求",
|
||||
"request": "请求",
|
||||
@@ -5786,7 +5786,7 @@ const I18N = {
|
||||
"Private, local and documentation addresses stay. Off by default: logs and configs are full of them": "內網、本機和文件範例位址不動。預設關閉:日誌和設定裡到處都是",
|
||||
"Cloud storage buckets": "雲端儲存桶",
|
||||
"The bucket in s3://, gs://, oss://, cos:// and storage URLs; the path in it stays": "s3://、gs://、oss://、cos:// 和儲存連結裡的桶名;桶內路徑不動",
|
||||
"Email addresses and account names on Usage and Routing are blurred, for a screenshot to share": "用量和路由頁上的郵箱和帳號名會被模糊處理,方便截圖分享",
|
||||
"Email addresses and account names on every page are blurred, for a screenshot to share": "所有頁面上的郵箱和帳號名都會被模糊處理,方便截圖分享",
|
||||
"Masked words": "脫敏詞",
|
||||
"Masked words in any case": "脫敏詞不分大小寫",
|
||||
"A word also matches in other capitals: Nightjar masks NIGHTJAR and nightjar too": "大小寫不同也算同一個詞:Nightjar 也會遮住 NIGHTJAR 和 nightjar",
|
||||
@@ -8087,7 +8087,7 @@ const I18N = {
|
||||
"A conversation stays with the account or key that answered it for the whole session, while it can answer.": "會話始終留在回答過它的帳號或 Key 上,只要它仍能回答。",
|
||||
"A conversation stays put within a turn, while the agent sends tool results back; when you speak again, routing decides afresh.": "一輪之內(Agent 回傳工具結果時)不換;你再次發言時,路由重新決定。",
|
||||
"Every request is routed afresh, whoever answered its conversation before.": "每個請求都重新路由,不論之前由誰回答。",
|
||||
"Mask the accounts on this page — email addresses and account names — for a screenshot to share": "給本頁的帳號(郵箱位址和帳號名)打碼,方便截圖分享",
|
||||
"Mask the accounts on every page — email addresses and account names — for a screenshot to share": "給所有頁面的帳號(郵箱位址和帳號名)打碼,方便截圖分享",
|
||||
"Least used": "最少使用",
|
||||
"requests": "請求",
|
||||
"request": "請求",
|
||||
@@ -10202,7 +10202,7 @@ const I18N = {
|
||||
"Private, local and documentation addresses stay. Off by default: logs and configs are full of them": "プライベート、ローカル、ドキュメント用のアドレスはそのまま。既定はオフ:ログや設定によく出てきます",
|
||||
"Cloud storage buckets": "クラウドストレージのバケット",
|
||||
"The bucket in s3://, gs://, oss://, cos:// and storage URLs; the path in it stays": "s3://、gs://、oss://、cos:// やストレージ URL のバケット名。中のパスはそのまま",
|
||||
"Email addresses and account names on Usage and Routing are blurred, for a screenshot to share": "使用量とルーティングのページのメールアドレスとアカウント名をぼかします(スクリーンショットの共有用)",
|
||||
"Email addresses and account names on every page are blurred, for a screenshot to share": "すべてのページのメールアドレスとアカウント名をぼかします(スクリーンショットの共有用)",
|
||||
"Masked words": "マスクする語",
|
||||
"Masked words in any case": "マスクする語の大文字・小文字を区別しない",
|
||||
"A word also matches in other capitals: Nightjar masks NIGHTJAR and nightjar too": "大文字・小文字が違っても同じ語として扱います:Nightjar で NIGHTJAR や nightjar もマスクされます",
|
||||
@@ -12524,7 +12524,7 @@ const I18N = {
|
||||
"A conversation stays with the account or key that answered it for the whole session, while it can answer.": "会話はセッション全体を通じて、応答できる限り、応答したアカウントやキーにとどまります。",
|
||||
"A conversation stays put within a turn, while the agent sends tool results back; when you speak again, routing decides afresh.": "ターン内(エージェントがツール結果を返している間)は移りません。次に発言したときに、ルーティングが改めて決めます。",
|
||||
"Every request is routed afresh, whoever answered its conversation before.": "各リクエストは、以前に誰が会話に応答したかにかかわらず、改めてルーティングされます。",
|
||||
"Mask the accounts on this page — email addresses and account names — for a screenshot to share": "スクリーンショットを共有できるよう、このページのアカウント(メールアドレスとアカウント名)を伏せます",
|
||||
"Mask the accounts on every page — email addresses and account names — for a screenshot to share": "スクリーンショットを共有できるよう、すべてのページのアカウント(メールアドレスとアカウント名)を伏せます",
|
||||
"Least used": "使用量が最少",
|
||||
"requests": "リクエスト",
|
||||
"request": "リクエスト",
|
||||
@@ -14649,7 +14649,7 @@ const I18N = {
|
||||
"Private, local and documentation addresses stay. Off by default: logs and configs are full of them": "Private, lokale und Dokumentationsadressen bleiben. Standardmäßig aus: Logs und Konfigurationen sind voll davon",
|
||||
"Cloud storage buckets": "Cloud-Speicher-Buckets",
|
||||
"The bucket in s3://, gs://, oss://, cos:// and storage URLs; the path in it stays": "Der Bucket in s3://, gs://, oss://, cos:// und Speicher-URLs; der Pfad darin bleibt",
|
||||
"Email addresses and account names on Usage and Routing are blurred, for a screenshot to share": "E-Mail-Adressen und Kontonamen auf „Nutzung“ und „Routing“ werden unscharf dargestellt, für einen Screenshot zum Teilen",
|
||||
"Email addresses and account names on every page are blurred, for a screenshot to share": "E-Mail-Adressen und Kontonamen werden auf allen Seiten unscharf dargestellt, für einen Screenshot zum Teilen",
|
||||
"Masked words": "Maskierte Wörter",
|
||||
"Masked words in any case": "Maskierte Wörter ohne Groß-/Kleinschreibung",
|
||||
"A word also matches in other capitals: Nightjar masks NIGHTJAR and nightjar too": "Ein Wort passt auch in anderer Schreibung: Nightjar maskiert auch NIGHTJAR und nightjar",
|
||||
@@ -16971,7 +16971,7 @@ const I18N = {
|
||||
"A conversation stays with the account or key that answered it for the whole session, while it can answer.": "Eine Unterhaltung bleibt die ganze Sitzung beim Konto oder Schlüssel, das sie beantwortet hat, solange es antworten kann.",
|
||||
"A conversation stays put within a turn, while the agent sends tool results back; when you speak again, routing decides afresh.": "Eine Unterhaltung bleibt innerhalb einer Runde, während der Agent Tool-Ergebnisse zurückschickt; wenn Sie wieder schreiben, entscheidet die Weiterleitung neu.",
|
||||
"Every request is routed afresh, whoever answered its conversation before.": "Jede Anfrage wird neu weitergeleitet, egal wer die Unterhaltung zuvor beantwortet hat.",
|
||||
"Mask the accounts on this page — email addresses and account names — for a screenshot to share": "Konten auf dieser Seite maskieren – E-Mail-Adressen und Kontonamen –, um einen Screenshot zu teilen",
|
||||
"Mask the accounts on every page — email addresses and account names — for a screenshot to share": "Konten auf allen Seiten maskieren – E-Mail-Adressen und Kontonamen –, um einen Screenshot zu teilen",
|
||||
"Least used": "Am wenigsten genutzt",
|
||||
"requests": "Anfragen",
|
||||
"request": "Anfrage",
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
<div class="who" role="status" aria-live="polite"><b id="providerDiscoveryCount"></b><span id="providerDiscoverySources"></span></div>
|
||||
<div class="actions"><button class="text primary" id="reviewProviderDiscovery">Review and import…</button><button class="text" id="dismissProviderDiscovery" data-t data-tt="Hide these configurations until they change">Ignore</button></div>
|
||||
</aside>
|
||||
<div class="pv-head" id="pvHead" hidden><input class="sess-filter pv-q" id="pvQ" type="search" spellcheck="false" autocomplete="off" placeholder="Find a provider" aria-label="Find a provider" data-tp><button class="text rt-mask" id="pvMask" aria-pressed="false" data-tt="Mask the accounts on this page — email addresses and account names — for a screenshot to share"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9.9 4.2A10.4 10.4 0 0 1 12 4c6.5 0 10 8 10 8a17.6 17.6 0 0 1-2.2 3.2M6.6 6.6C3.9 8.4 2 12 2 12s3.5 8 10 8a9.7 9.7 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2M2 2l20 20"/></svg><span data-t>Hide accounts</span></button></div>
|
||||
<div class="pv-head" id="pvHead" hidden><input class="sess-filter pv-q" id="pvQ" type="search" spellcheck="false" autocomplete="off" placeholder="Find a provider" aria-label="Find a provider" data-tp><button class="text rt-mask" id="pvMask" aria-pressed="false" data-tt="Mask the accounts on every page — email addresses and account names — for a screenshot to share"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9.9 4.2A10.4 10.4 0 0 1 12 4c6.5 0 10 8 10 8a17.6 17.6 0 0 1-2.2 3.2M6.6 6.6C3.9 8.4 2 12 2 12s3.5 8 10 8a9.7 9.7 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2M2 2l20 20"/></svg><span data-t>Hide accounts</span></button></div>
|
||||
<p class="set-none pv-none" id="pvNone" role="status" hidden></p>
|
||||
<div class="list" id="providers"></div>
|
||||
<div class="row-head off-head" id="offHead" hidden><button class="fold" id="foldOff" aria-expanded="false" aria-controls="offProviders"><span class="label" data-t>Turned off</span><span class="note" id="offCount"></span></button></div>
|
||||
|
||||
@@ -23,7 +23,7 @@ magpie.plugin("routing", (ctx) => {
|
||||
<div class="row-head"><span class="label" data-t>Routing</span><span class="rt-livedot" aria-hidden="true"></span><span class="note" data-t>live, as the gateway decides</span><span class="grow"></span>
|
||||
<button class="text rt-gogroups" id="rtGoGroups" type="button" data-tt="Go to the routing groups, below the requests"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3v9.5M4 8.5l4 4 4-4"/></svg><span data-t>Routing groups</span></button>
|
||||
<button class="text rt-newgroup" id="rtNewGroup" type="button" data-feature="groups" data-tt="Make a routing group of any models you like — agents pick it as one model"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M8 3.5v9M3.5 8h9"/></svg><span data-t>New group</span></button>
|
||||
<button class="text rt-mask" id="rtMask" aria-pressed="false" data-tt="Mask the accounts on this page — email addresses and account names — for a screenshot to share"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9.9 4.2A10.4 10.4 0 0 1 12 4c6.5 0 10 8 10 8a17.6 17.6 0 0 1-2.2 3.2M6.6 6.6C3.9 8.4 2 12 2 12s3.5 8 10 8a9.7 9.7 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2M2 2l20 20"/></svg><span data-t>Hide accounts</span></button></div>
|
||||
<button class="text rt-mask" id="rtMask" aria-pressed="false" data-tt="Mask the accounts on every page — email addresses and account names — for a screenshot to share"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9.9 4.2A10.4 10.4 0 0 1 12 4c6.5 0 10 8 10 8a17.6 17.6 0 0 1-2.2 3.2M6.6 6.6C3.9 8.4 2 12 2 12s3.5 8 10 8a9.7 9.7 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2M2 2l20 20"/></svg><span data-t>Hide accounts</span></button></div>
|
||||
<section class="rt" id="rt"></section>
|
||||
<div class="rt-more" id="rtMore"></div>
|
||||
`,
|
||||
|
||||
@@ -34,7 +34,7 @@ magpie.plugin("usage", (ctx) => {
|
||||
<span class="label" data-t>Allowances</span>
|
||||
<span class="grow"></span>
|
||||
<button class="sess-pick quota-trend" id="quotaTrend" type="button" hidden></button>
|
||||
<button class="text rt-mask" id="usageMask" aria-pressed="false" data-tt="Mask the accounts on this page — email addresses and account names — for a screenshot to share"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9.9 4.2A10.4 10.4 0 0 1 12 4c6.5 0 10 8 10 8a17.6 17.6 0 0 1-2.2 3.2M6.6 6.6C3.9 8.4 2 12 2 12s3.5 8 10 8a9.7 9.7 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2M2 2l20 20"/></svg><span data-t>Hide accounts</span></button>
|
||||
<button class="text rt-mask" id="usageMask" aria-pressed="false" data-tt="Mask the accounts on every page — email addresses and account names — for a screenshot to share"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9.9 4.2A10.4 10.4 0 0 1 12 4c6.5 0 10 8 10 8a17.6 17.6 0 0 1-2.2 3.2M6.6 6.6C3.9 8.4 2 12 2 12s3.5 8 10 8a9.7 9.7 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2M2 2l20 20"/></svg><span data-t>Hide accounts</span></button>
|
||||
<div class="segs" id="quotaMode" hidden></div>
|
||||
</div>
|
||||
<section class="subscription-usage" id="subscriptionUsage"></section>
|
||||
|
||||
@@ -50,7 +50,7 @@ function serve(lang, panel) {
|
||||
|
||||
const words = {
|
||||
en: { hide: "Hide accounts", hidden: "Accounts hidden", tip: /^Mask the accounts/, back: /click to show them/ },
|
||||
zh: { hide: "账号打码", hidden: "账号已打码", tip: /^给本页的账号/, back: /点击显示/ },
|
||||
zh: { hide: "账号打码", hidden: "账号已打码", tip: /^给所有页面的账号/, back: /点击显示/ },
|
||||
};
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// The Providers page has a Hide accounts switch of its own, and each page
|
||||
// follows its own (a Discord user in #feedback: Routing's switch hid the
|
||||
// Providers page too, which had no switch to turn it back). One who had
|
||||
// Hide accounts on before keeps Providers hidden: its switch starts from
|
||||
// the choice made then. Every language, wide and narrow; no backend.
|
||||
// Hide accounts is one switch for every page (paultian in #feedback: the
|
||||
// Providers page had a switch of its own, so Providers could be hidden
|
||||
// while Routing wasn't). Routing's, Usage's and Providers' buttons are the
|
||||
// same switch: turned on any page, every page is hidden and every button
|
||||
// says so, live in another window and the tray panel too. What an earlier
|
||||
// version stored for either page is folded into it: hidden on either then
|
||||
// is hidden everywhere now. Every language, wide and narrow; no backend.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -13,21 +15,24 @@ const { chromium, webkit } = require("playwright");
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const MAIL = "dev.one@example.com";
|
||||
|
||||
function serve(lang) {
|
||||
function serve(lang, panel) {
|
||||
const base = { icon: "generic", chat: "", responses: "", anthropic: "", catalog: "", agents: [], fallback: [], headers: {}, keyList: [], proxy: "" };
|
||||
const providers = { providers: [
|
||||
{ ...base, id: "codex", name: "Codex", icon: "codex-color", models: [{ id: "gpt-6", name: "GPT-6", on: true }], account: { agent: "codex", agentName: "Codex", user: MAIL, plan: "PLUS", logins: [{ agent: "codex", user: MAIL, plan: "PLUS", active: true, on: true }] } },
|
||||
], presets: [], excluded: [], gateway: { running: true, window: true } };
|
||||
const settings = { lang, theme: "light" };
|
||||
const quotas = [{ provider: "codex", name: "Codex", icon: "openai", plan: "Plus", user: MAIL, windows: [{ name: "5 hours", used: 20 }] }];
|
||||
const settings = { lang, theme: "light", tray: "panel", quotaLeft: false, currency: "usd" };
|
||||
return async (route) => {
|
||||
const url = new URL(route.request().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:true};` });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:${!panel}};` });
|
||||
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 });
|
||||
if (url.pathname === "/api/settings") return json(settings);
|
||||
if (url.pathname === "/api/providers") return json(providers);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [] });
|
||||
if (url.pathname === "/api/usage/quotas") return json(quotas);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
|
||||
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)];
|
||||
@@ -35,104 +40,134 @@ function serve(lang) {
|
||||
};
|
||||
}
|
||||
|
||||
const KEYS = ["Hide accounts", "Accounts hidden", "Mask the accounts on this page — email addresses and account names — for a screenshot to share", "Accounts are masked for a screenshot — click to show them"];
|
||||
const KEYS = ["Hide accounts", "Accounts hidden", "Mask the accounts on every page — email addresses and account names — for a screenshot to share", "Accounts are masked for a screenshot — click to show them", "Email addresses and account names on every page are blurred, for a screenshot to share"];
|
||||
const BTNS = { routing: "#rtMask", usage: "#usageMask", providers: "#pvMask" };
|
||||
|
||||
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 [1000, 420]) {
|
||||
// stored: what an earlier version left in magpie.maskEmails
|
||||
const open = async (t, stored) => {
|
||||
// stored: what an earlier version left, [maskEmails, maskProviders]
|
||||
const launch = async (t, stored = [null, null]) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const context = await browser.newContext({ viewport: { width, height: 800 }, reducedMotion: "reduce" });
|
||||
await context.addInitScript((v) => { try { if (!sessionStorage.getItem("seeded")) { if (v !== null) localStorage.setItem("magpie.maskEmails", v); sessionStorage.setItem("seeded", "1"); } } catch {} }, stored);
|
||||
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("**/*", serve(lang));
|
||||
return page;
|
||||
await context.addInitScript((v) => { try { if (!localStorage.getItem("seeded")) { if (v[0] !== null) localStorage.setItem("magpie.maskEmails", v[0]); if (v[1] !== null) localStorage.setItem("magpie.maskProviders", v[1]); localStorage.setItem("seeded", "1"); } } catch {} }, stored);
|
||||
const errors = [];
|
||||
const open = async (url) => {
|
||||
const page = await context.newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang, url.includes("mode=panel")));
|
||||
await page.goto(url);
|
||||
return page;
|
||||
};
|
||||
return { open, errors };
|
||||
};
|
||||
const provText = (page) => page.evaluate(() => document.querySelector("#providers").innerText);
|
||||
const listed = (page) => page.waitForFunction(() => document.querySelector("#providers")?.innerText.includes("Codex"));
|
||||
// every page's button says the one state, in its words and its tooltip
|
||||
const says = async (page, on, where) => {
|
||||
for (const [view, sel] of Object.entries(BTNS)) {
|
||||
const b = page.locator(sel);
|
||||
if (!(await b.count())) continue;
|
||||
assert.equal(await b.getAttribute("aria-pressed"), String(on), `${view}'s button ${where}`);
|
||||
assert.equal(await b.locator("[data-t]").textContent(), await page.evaluate((k) => t(k), KEYS[on ? 1 : 0]), `${view}'s words ${where}`);
|
||||
assert.equal(await b.getAttribute("title"), await page.evaluate((k) => t(k), KEYS[on ? 3 : 2]), `${view}'s tooltip ${where}`);
|
||||
}
|
||||
};
|
||||
|
||||
test(`${engine} ${lang} ${width}: Providers' Hide accounts is its own`, async (t) => {
|
||||
const page = await open(t, null);
|
||||
await page.goto("http://magpie.test/?view=routing");
|
||||
test(`${engine} ${lang} ${width}: Hide accounts is one switch on every page`, async (t) => {
|
||||
const { open, errors } = await launch(t);
|
||||
const page = await open("http://magpie.test/?view=routing");
|
||||
await page.locator("#rtMask").waitFor();
|
||||
await page.evaluate((m) => { const d = document.createElement("div"); d.id = "sample"; d.textContent = "Codex as " + m; document.querySelector("#view-routing").append(d); }, MAIL);
|
||||
// a second window on the same storage, on Providers, and the panel
|
||||
const other = await open("http://magpie.test/?view=providers");
|
||||
await listed(other);
|
||||
const panel = await open("http://magpie.test/?mode=panel");
|
||||
await panel.evaluate(() => setPanelTab("usage"));
|
||||
await panel.waitForFunction((m) => document.querySelector("#panelQuota")?.innerText.includes(m), MAIL);
|
||||
|
||||
// Routing's switch hides Routing's accounts
|
||||
// turned on Routing: Routing hidden, every button on
|
||||
await page.locator("#rtMask").click();
|
||||
await page.waitForFunction(() => document.querySelector("#sample .pii"));
|
||||
await says(page, true, "after Routing's was turned on");
|
||||
|
||||
// and leaves the Providers page alone, whose own switch is off
|
||||
// and Providers hidden too, its own button saying so
|
||||
await page.evaluate(() => show("providers"));
|
||||
await listed(page);
|
||||
const pv = page.locator("#pvMask");
|
||||
await pv.waitFor();
|
||||
assert.ok((await provText(page)).includes(MAIL), "Providers shows the account while its own switch is off");
|
||||
assert.equal(await page.locator("#view-providers .pii").count(), 0);
|
||||
assert.equal(await pv.getAttribute("aria-pressed"), "false");
|
||||
assert.equal(await pv.locator("[data-t]").textContent(), await page.evaluate((k) => t(k), KEYS[0]));
|
||||
assert.equal(await pv.getAttribute("title"), await page.evaluate((k) => t(k), KEYS[2]));
|
||||
await page.waitForFunction(() => document.querySelector("#view-providers .pii"));
|
||||
assert.ok(!(await provText(page)).includes(MAIL), "Providers shows the account while Routing's switch is on");
|
||||
await says(page, true, "on Providers");
|
||||
|
||||
// and Usage
|
||||
await page.evaluate(() => show("usage"));
|
||||
await page.locator("#usageMask").waitFor();
|
||||
await page.waitForFunction((m) => { const u = document.querySelector("#view-usage .subscription-account .user"); return u && u.querySelector(".pii") && !u.textContent.includes(m); }, MAIL);
|
||||
await says(page, true, "on Usage");
|
||||
|
||||
// live in the other window and the panel
|
||||
await other.waitForFunction(() => document.querySelector("#view-providers .pii"));
|
||||
assert.ok(!(await provText(other)).includes(MAIL));
|
||||
await says(other, true, "in another window");
|
||||
await panel.waitForFunction((m) => !document.querySelector("#panelQuota").innerText.includes(m), MAIL);
|
||||
|
||||
// turned off from Providers, in the other window: every page back
|
||||
await other.locator("#pvMask").click();
|
||||
await other.waitForFunction(() => !document.querySelector(".pii"));
|
||||
assert.ok((await provText(other)).includes(MAIL));
|
||||
await says(other, false, "after Providers' was turned off");
|
||||
await page.waitForFunction(() => !document.querySelector(".pii"));
|
||||
await says(page, false, "in the first window, after the other turned it off");
|
||||
await page.evaluate(() => show("routing"));
|
||||
assert.equal(await page.locator("#sample").textContent(), "Codex as " + MAIL);
|
||||
await panel.waitForFunction((m) => document.querySelector("#panelQuota").innerText.includes(m), MAIL);
|
||||
|
||||
// turned on from Usage: Providers hidden again, after a reload too
|
||||
await page.evaluate(() => show("usage"));
|
||||
await page.locator("#usageMask").click();
|
||||
await page.waitForFunction(() => document.querySelector("#view-usage .pii"));
|
||||
await page.reload();
|
||||
await page.evaluate(() => show("providers"));
|
||||
await listed(page);
|
||||
await page.waitForFunction(() => document.querySelector("#view-providers .pii"));
|
||||
await says(page, true, "after a reload");
|
||||
assert.equal(await page.evaluate(() => localStorage.getItem("magpie.maskEmails")), "1");
|
||||
assert.equal(await page.evaluate(() => localStorage.getItem("magpie.maskProviders")), null);
|
||||
|
||||
// placed as Routing's: in the page's head row, at its right end
|
||||
const box = await pv.boundingBox(), q = await page.locator("#pvQ").boundingBox();
|
||||
const box = await page.locator("#pvMask").boundingBox(), q = await page.locator("#pvQ").boundingBox();
|
||||
assert.ok(Math.abs((box.y + box.height / 2) - (q.y + q.height / 2)) < 4, `beside the search box: ${JSON.stringify([box, q])}`);
|
||||
assert.ok(box.x >= q.x + q.width - 1, `at the right end: ${JSON.stringify([box, q])}`);
|
||||
assert.ok(box.x + box.width <= width, "inside the window");
|
||||
|
||||
// turned on here: Providers hidden, the choice kept
|
||||
await pv.click();
|
||||
await page.waitForFunction(() => document.querySelector("#view-providers .pii"));
|
||||
assert.ok(!(await provText(page)).includes(MAIL));
|
||||
assert.equal(await pv.getAttribute("aria-pressed"), "true");
|
||||
assert.equal(await pv.locator("[data-t]").textContent(), await page.evaluate((k) => t(k), KEYS[1]));
|
||||
assert.equal(await page.evaluate(() => localStorage.getItem("magpie.maskProviders")), "1");
|
||||
|
||||
// Routing's turned off: Routing back, Providers still hidden
|
||||
await page.evaluate(() => show("routing"));
|
||||
await page.locator("#rtMask").click();
|
||||
await page.waitForFunction(() => !document.querySelector("#sample .pii"));
|
||||
assert.equal(await page.locator("#sample").textContent(), "Codex as " + MAIL);
|
||||
await page.evaluate(() => show("providers"));
|
||||
assert.ok(await page.locator("#view-providers .pii").count() > 0, "Routing's switch turned Providers' off");
|
||||
assert.ok(!(await provText(page)).includes(MAIL));
|
||||
|
||||
// and after a reload
|
||||
await page.reload();
|
||||
await listed(page);
|
||||
await page.waitForFunction(() => document.querySelector("#view-providers .pii"));
|
||||
assert.equal(await page.locator("#pvMask").getAttribute("aria-pressed"), "true");
|
||||
assert.equal(await page.evaluate(() => localStorage.getItem("magpie.maskEmails")), "0");
|
||||
|
||||
assert.equal(await page.locator("select").count(), 0, "no native select");
|
||||
assert.equal(await pv.evaluate((b) => getComputedStyle(b).borderLeftWidth), "0px");
|
||||
assert.ok(!/gradient/.test(await pv.evaluate((b) => getComputedStyle(b).backgroundImage)), "no gradient");
|
||||
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth), 0, `no sideways scroll at ${width}px`);
|
||||
const missing = await page.evaluate(([keys, lang]) => lang === "en" ? [] : keys.filter((k) => !I18N[lang]?.[k]), [KEYS, lang]);
|
||||
assert.deepEqual(missing, [], `every string has its ${lang}`);
|
||||
assert.deepEqual(page.errors, []);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
// one who had Hide accounts on keeps Providers hidden; one who had it
|
||||
// off keeps it off, even with Mask personal data on later
|
||||
for (const stored of ["1", "0"]) {
|
||||
test(`${engine} ${lang} ${width}: Hide accounts ${stored === "1" ? "on" : "off"} before the update stays so on Providers`, async (t) => {
|
||||
const page = await open(t, stored);
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
// what an earlier version stored for Routing (maskEmails) and for
|
||||
// Providers (maskProviders): hidden on either is hidden everywhere
|
||||
for (const [stored, on] of [[[null, "1"], true], [["0", "1"], true], [["1", "0"], true], [["1", null], true], [["0", "0"], false], [["0", null], false]]) {
|
||||
test(`${engine} ${lang} ${width}: stored ${JSON.stringify(stored)} before the update is ${on ? "hidden" : "shown"} on every page`, async (t) => {
|
||||
const { open, errors } = await launch(t, stored);
|
||||
const page = await open("http://magpie.test/?view=providers");
|
||||
await listed(page);
|
||||
await page.locator("#pvMask").waitFor();
|
||||
if (stored === "1") await page.waitForFunction(() => document.querySelector("#view-providers .pii"));
|
||||
assert.equal(await page.locator("#view-providers .pii").count() > 0, stored === "1");
|
||||
assert.equal((await provText(page)).includes(MAIL), stored === "0");
|
||||
assert.equal(await page.locator("#pvMask").getAttribute("aria-pressed"), String(stored === "1"));
|
||||
assert.equal(await page.evaluate(() => localStorage.getItem("magpie.maskProviders")), stored);
|
||||
await page.evaluate(() => hideAccounts.follow(true));
|
||||
assert.equal(await page.locator("#pvMask").getAttribute("aria-pressed"), String(stored === "1"), "a default never turns the user's choice");
|
||||
assert.deepEqual(page.errors, []);
|
||||
if (on) await page.waitForFunction(() => document.querySelector("#view-providers .pii"));
|
||||
assert.equal(await page.locator("#view-providers .pii").count() > 0, on);
|
||||
assert.equal((await provText(page)).includes(MAIL), !on);
|
||||
await says(page, on, "on Providers");
|
||||
await page.evaluate(() => show("routing"));
|
||||
await says(page, on, "on Routing");
|
||||
assert.equal(await page.evaluate(() => localStorage.getItem("magpie.maskEmails")), on ? "1" : "0");
|
||||
assert.equal(await page.evaluate(() => localStorage.getItem("magpie.maskProviders")), null);
|
||||
await page.evaluate((v) => hideAccounts.follow(v), !on);
|
||||
await says(page, on, "after Mask personal data changed: a default never turns the user's choice");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user