editor: a provider's warm-up or check-in that is on opens its Advanced (ChrisYagao on X)

ChrisYagao on X asked where his warm-up went. Nothing was lost: warm-up
moved from Settings into each provider's editor (11-09), then into that
editor's folded Advanced (11-10), so a warm-up that was on vanished from
sight with no trace of where it went.

Fix: the editor's Advanced opens on its own while that provider's
warm-up (on reset or daily times) or daily check-in is on
(provPrefsOn), unless the reader opened or closed it by hand, the same
rule as Routing's Advanced. renderWarmAtOwn moves into the lazily
loaded autoresetown.js (warmAtOwnPaint), so app.js and the core script
budget each drop by 1,529 bytes. reader.cjs's openProvPrefs waits for
the modal's animations to end before measuring (warm-at-times WebKit
900px measured mid-animation, 0.66px overhang).

Old data: no setting changes and nothing migrates; a warm-up that was
on shows again the first time its editor opens.

What was run:
- warm-advanced.test.cjs (new): red 10/10 on the old app.js
  ("codex, warm up on reset: Advanced open"), green after; chromium and
  webkit, en zh zh-TW ja de.
- At the pushed head (rebased on origin/main), on mica: warm-advanced,
  warm-at-times, warm-at-own, warm-now, quota-warm, plugin-checkin,
  editor-advanced-align, routing-advanced: 160 passed, 0 failed.
- 29 related GUI files (every openProvPrefs user, warm-*, quota-warm,
  plugin-checkin, routing-advanced, editor-advanced-align,
  codex-auto-reset*, reset-providers, search-mix, model-api-preset,
  i18n-keys, segs-press-redraw, settings-groups) alone on mica: 603
  passed, 31 failed; every red is red at origin/main 8e1534f5f too:
  codex-auto-reset-settings webkit de #4790, i18n-keys "a plugin's
  words are its own" #6877, model-api-preset chromium #5838,
  reset-providers 420px #6196, settings-groups "Spend extra usage"
  #6597, segs-press-redraw currencySegs (filed #6990).
- go test ./... -timeout 45m on mote: ok, no FAIL. After the rebase,
  go test ./internal/gui/ (budgets) on mica: ok.
- GOOS=linux go vet -tags nogui ./... ok, GOOS=windows go vet ./... ok,
  gofmt -l clean.

Not tried: the whole GUI suite ran once only, by accident, at an
earlier head before the reader.cjs fix, under load on mica (24,676
passed, 3,151 failed); those reds can't be attributed and are not a
record for this head. Not tried in the real app with ChrisYagao's
settings.
This commit is contained in:
yetone
2026-11-17 23:27:42 +08:00
parent 5bfa57e3d3
commit 28f27e07b7
6 changed files with 159 additions and 59 deletions
+2 -1
View File
@@ -449,7 +449,8 @@ and `TestHistoricalWindowHoldsUsesEachWindowsOwnReading`.
- The account Codex or Claude Code is signed in to can be paused (`SetLoginOn` off, #263) only while another of its accounts is on. The gateway then sends it nothing: Codex's own-model turns go through routing, which passes over it (`OwnPaused`), and a native compaction (`/responses/compact`) goes to the first account on that isn't resting, signed as that account (`compactOn` in [codex_backend.go](../../internal/gateway/codex_backend.go)). The last other account off, the paused one is used again. A switched-off Codex provider is not a pause: Codex's own-model requests still relay on its sign-in as they came.
- A switched-off provider (`Off`, #163) stays saved. The gateway says it is off instead of saying the model is unknown.
- A subscription switched off (`Off`) or whose account was removed from magpie (`Hidden`) is left alone in the background (`leftAlone` in [`left_alone.go`](../../internal/provider/left_alone.go); Riko on Discord, whose Claude switched off still ran `claude auth status --json` every minute). No CLI is asked who is signed in (`claudeIdentity`, `cliIdentity.get` for Cursor and Devin): what it said last, in memory or `cli-identity.json`, is served, so the account stays listed to switch on again. Nor is its allowance read (`fetchSubscriptionUsage`, `loginUsageAt`), a saved ChatGPT sign-in renewed (`RenewLogins`), the agent's account switched (`NextLogin`), a window warmed (`keepWarm`), its model list fetched (`newDue`), a daily check-in made by the loop (`checkinNow` with `soon` false; a press still checks in), a plugin's idle sign-in renewed (`KeepPluginsSignedIn`, #5080), or a Codex reset about to run out read and spent (`SpendExpiringCodexResets`, #2226; `TestExpiringResetLeftAlone`). A Cursor switched off that was never asked who is signed in isn't listed until it is switched on. `TestLeftAloneRunsNoCLI` runs those paths with fake `claude`, `cursor-agent` and `devin` CLIs on PATH and checks none ran. Plugins' model lists (`KeepPluginsListed`, and every listing after a sign-in or a plugin changes) are asked of the plugin host all at once, and a plugin provider switched off in magpie is named in the call (`plugin.ListingOff`, `pluginsOff` in [`plugins.go`](../../internal/provider/plugins.go)): `host.js` runs no models hook for it, nor the sign-in renewal before one, and tells its list as fallen back, so the list told last is kept (ChangQiu on Discord: `TestOffPluginProviderAskedNoModels`, `TestPluginsOffNamesThePluginsOwnIDs`). Refreshing every list (the window's Refresh, `POST /api/sync`, and `magpie sync`) goes through `RefreshLists`, which asks no provider switched off, and a key added to one isn't given its own list (`PrefillNewKeys`), nor is a provider switched off asked for its list when it is saved or a key is switched on in its editor (`TestRefreshListsAsksNoProviderSwitchedOff`, `TestPrefillAsksNoProviderSwitchedOff`).
- *Warm up now*, the last row of Settings › Usage's Codex and Claude Code warm-up tabs (`renderWarmNow` in `app.js`, `POST /api/warm-now`), sends one account the request the scheduled warm-up sends, whatever the warm-up settings say ([`warm_now.go`](../../internal/provider/warm_now.go)): `warmCodexLogin` for a ChatGPT account, then `StaleAllowance`; for a Claude account Claude Code's own run, `warmClaudeLogin` over the gateway's `warmClaude` (`WarmClaudeVia`), in the saved account's directory, then `claudeWarmedNow`, which has the account read again on its next look while its last reading keeps its own time, so the old windows never show as just read (`TestClaudeWarmedReadAgain`). With several accounts the press opens the app's menu of them. An account whose sign-in lapsed is sent nothing and says so, and the vendor's refusal comes back as the row's line, in red. The scheduled warm-up's file (`codex-warmup.json`) isn't written: its next look reads the window as started. `TestWarmNowSendsTheScheduledWarmUp` checks the body and headers equal the scheduled warm-up's; `warm-now.test.cjs` covers the GUI.
- A subscription's warm-up and daily check-in are fields under its provider editor's Advanced (`provPrefsField` in `app.js`; Settings' search finds them too). Advanced opens on its own while that provider's warm-up (on reset or at times of day) or check-in is on (`provPrefsOn`), unless the reader opened or closed it by hand, so a user who set one finds it (ChrisYagao on X; `warm-advanced.test.cjs`).
- *Warm up now*, the last row of Codex's and Claude Code's warm-up in their provider editors (`renderWarmNow` in `app.js`, `POST /api/warm-now`), sends one account the request the scheduled warm-up sends, whatever the warm-up settings say ([`warm_now.go`](../../internal/provider/warm_now.go)): `warmCodexLogin` for a ChatGPT account, then `StaleAllowance`; for a Claude account Claude Code's own run, `warmClaudeLogin` over the gateway's `warmClaude` (`WarmClaudeVia`), in the saved account's directory, then `claudeWarmedNow`, which has the account read again on its next look while its last reading keeps its own time, so the old windows never show as just read (`TestClaudeWarmedReadAgain`). With several accounts the press opens the app's menu of them. An account whose sign-in lapsed is sent nothing and says so, and the vendor's refusal comes back as the row's line, in red. The scheduled warm-up's file (`codex-warmup.json`) isn't written: its next look reads the window as started. `TestWarmNowSendsTheScheduledWarmUp` checks the body and headers equal the scheduled warm-up's; `warm-now.test.cjs` covers the GUI.
- *All accounts*, the first item of Warm up now's menu with several accounts (CoderMaurice on X, `POST /api/warm-all`, `WarmAll` in [`warm_now.go`](../../internal/provider/warm_now.go)), sends Warm up now to every account in use (the one the agent is on, or one turned on beside it) whose windows aren't all running, as the cached readings tell them (`windowsRunning`: one never read is warmed), three at a time. An account turned off or paused, and one already in its windows, is sent nothing; one whose sign-in lapsed is sent nothing and failed. The row's line says each account's result: the ones warmed, the ones already in a window, and each refusal with its reason, in red; one turned off goes unsaid. A gateway rest isn't read here (the provider package can't see it): an account rested for a used-up window is in that window, so it is left alone as running. `TestWarmAllWarmsEachIdleAccountInUse`; `warm-now.test.cjs` covers the GUI.
- The scheduled warm-up warms each window a Claude account is expected to have (`withExpected`), the 5-hour and the week, also one its reading left out: Anthropic leaves a window out until the request that starts it. A window left out while a shorter one is running is one the account doesn't have, since any use starts every window it has (a Claude Enterprise account with only the 5-hour, koohoko5924 on Discord, whose week was warmed over and over and its state read Idle): the warmer marks it `Absent` in `codex-warmup.json` and sends it nothing, and `usageRead` doesn't count it as due (`windowAbsent`, `shorterRunning` in [`codex_warmup.go`](../../internal/provider/codex_warmup.go)). A week once seen running, or left out of a reading that is only part of the plan's, is still warmed; one never read before is not. `TestClaudeWarmLeavesAWeekTheAccountHasnt`, `TestClaudeWarmStartsAWeekThatReset`, `TestUsageReadLeavesAWeekTheAccountHasnt`.
- A Copilot subscription offers the union of its On accounts' models too (`copilotPoolModels` in [`copilot_pool.go`](../../internal/provider/copilot_pool.go), merged by `poolModels` as Codex's ChatGPT accounts are): each GitHub account's plan lists its own (`/models`), kept under `accountModels` for `Account.Lists`. The first account's list is fetched as before (`FetchNew`, `KeepAccountsListed`, Refresh); each fetch of it also asks the other accounts on: one with no list at once, of the rest the one asked longest ago once its list is a day old (`copilotFetchSaved`). A model Copilot refused an account (`copilotRefuses`) goes to the others that list it, and stays in the provider's list while another account on lists it (`copilotOthersList`). Only a failed ask is remembered (`copilotSavedAsked`), so a list gone is asked for again at once. applemacssma on X; `TestCopilotAccountsWithOtherModels`, `TestCopilotRefusedModelGoesToTheAccountServedIt`.
+12 -55
View File
@@ -9701,7 +9701,9 @@ function drawEditor(p, presetID) {
if (p.drawIds?.length) ed.append(...renderDrawers(p));
if (p.filmIds?.length) ed.append(...renderVideomakers(p));
// the subscription's own warm-up, check-in and resets first
if (subOf(a.agent)) advIn.append(...provPrefsField(a.agent));
// and Advanced opened when one is on, as for Routing: the user who set
// a warm-up finds it where it went (ChrisYagao on X: "我的预热去哪里了")
if (subOf(a.agent)) advIn.append(...provPrefsField(a.agent, () => !(advanced && advanced.of === of) && provPrefsOn(a.agent) && (adv.open = true)));
// a subscription's window too: Codex's backend says 272K for models
// that take 872K (#120)
const cx = input(draft.contexts || "", t("e.g. 128k · or gpt-6=1m, comma separated"));
@@ -19805,10 +19807,14 @@ function remountProvPrefs() {
homeProvPrefRows();
provPrefMount = null;
}
// provPrefsOn: the agent's warm-up or daily check-in is on
const provPrefsOn = (a, s = prefs) => !!(a == "codex" ? s.codexWarmup || warmTimes(s.codexWarmAts, s.codexWarmAt).length
: a == "claude" ? s.claudeWarmup || warmTimes(s.claudeWarmAts, s.claudeWarmAt).length
: s.checkinPlugins?.find((p) => p.id == a)?.on ?? s[PLUGIN_CHECKIN_INHERITS[a]]);
// provPrefsField: a subscription's warm-up, check-in and resets as the
// editor's own fields, under Advanced (the owner, 11-09: a block of cards
// under Routing took most of the editor)
function provPrefsField(agent) {
function provPrefsField(agent, opened) {
// a gateway keeps them: they run on its own accounts (#1065)
if (!PROV_PREFS[agent] && !(prefs?.checkinPlugins || []).some((x) => x.id === agent) && prefs) return [];
const keys = [...(PROV_PREFS[agent] || []), "ci-plugin"];
@@ -19820,8 +19826,8 @@ function provPrefsField(agent) {
slot.hidden = true;
return slot;
});
if (prefs) mountProvPrefs(slots, agent);
else loadSettings().then(() => slots[0].isConnected && mountProvPrefs(slots, agent), () => {});
if (prefs) mountProvPrefs(slots, agent), opened?.();
else loadSettings().then(() => slots[0].isConnected && (mountProvPrefs(slots, agent), opened?.()), () => {});
return slots.flatMap((x) => x.fieldRow);
}
// a provider's settings found by Settings' search, drawn by provlinks.js
@@ -20172,8 +20178,7 @@ function renderSettings() {
(v) => savePrefs({ ...keep, codexWarmAts: v, codexWarmAt: v[0] || "" }));
renderWarmAt($("#claudeWarmAtSegs"), $("#claudeWarmAtSub"), warmTimes(s.claudeWarmAts, s.claudeWarmAt), s.claudeWarmup, t("Sent through Claude Code."),
(v) => savePrefs({ ...keep, claudeWarmAts: v, claudeWarmAt: v[0] || "" }));
renderWarmAtOwn(s);
renderAutoResetOwn(s);
renderAutoResetOwn(s); // and each account's own warm-up time
renderWarmNow("codex", s.codexUsers, "#warmNowRow");
renderWarmNow("claude", s.claudeUsers, "#claudeWarmNowRow");
// each built-in vendor's daily check-in, shown while one of its
@@ -21151,60 +21156,12 @@ function renderWarmAt(box, sub, ats, onReset, via, save) {
box.append(segs([["off", t("Off")], ["on", t("On")]], ats.length ? "on" : "off", (v) => save(v === "on" ? (ats.length ? ats : ["06:00"]) : [])));
}
// Settings › Usage's Codex auto-use rows, drawn by autoresetown.js
// Codex's auto-use rows and each account's own warm-up time, drawn by autoresetown.js
function renderAutoResetOwn(s) {
if (window.autoResetOwnPaint) return autoResetOwnPaint(s);
import("./autoresetown.js").then(() => autoResetOwnPaint(s), statusErr);
}
// renderWarmAtOwn: each ChatGPT account's own daily time (#957,
// codexWarmAtOf), shown with two accounts or one with its own
function renderWarmAtOwn(s) {
const list = $("#codexWarmList");
list.querySelectorAll(".warm-own").forEach((r) => r.remove());
const own = s.codexWarmAtOf || {};
const users = [...(s.codexUsers || [])];
for (const u of Object.keys(own)) if (!users.some((x) => x.toLowerCase() === u)) users.push(u);
if (users.length < 2 && !Object.keys(own).length) return;
const save = async (user, at) => {
try {
prefs = await writingPrefs(api("settings/codex-warm-at", { user, at }));
if (state) state.settings = prefs;
renderSettings();
} catch (e) {
statusTErr(e);
renderSettings();
}
};
for (const user of users) {
const at = own[user.toLowerCase()];
const mode = at === undefined ? "same" : at === "off" ? "off" : "own";
const r = el("div", "row pref warm-own");
r.dataset.user = user;
const who = el("div", "who");
const name = el("div", "name", user);
name.title = user;
const sub = el("div", "sub", mode === "own" ? t("Its own time each day")
: mode === "off" ? t("Not started at a time of day")
: s.codexWarmAt ? t("Same as above, {at}", { at: warmTimes(s.codexWarmAts, s.codexWarmAt).join(", ") }) : t("Same as above, off"));
sub.title = t("Give accounts different times and one window starts as another runs out.");
who.append(name, sub);
const box = el("div", "warm-at");
if (mode === "own") {
const i = input(at, "06:00", "time");
i.className = "at";
i.setAttribute("aria-label", t("{who}'s time of day", { who: user }));
blurOnEnter(i);
i.onchange = () => { if (i.value && i.value !== at) save(user, i.value); };
box.append(i);
}
box.append(segs([["same", t("Same")], ["own", t("Own")], ["off", t("Off")]], mode, (v) =>
save(user, v === "same" ? "" : v === "off" ? "off" : s.codexWarmAt || "06:00")));
r.append(who, box);
$("#warmNowRow").before(r); // Warm up now stays last
}
}
// renderWarmNow is Warm up now: the scheduled warm-up's request to one account at once
const warmNowSaid = {};
function renderWarmNow(agent, users, rowId) {
+51 -1
View File
@@ -1,7 +1,8 @@
// Codex's auto-use rows, in its provider's editor (PROV_PREFS): each ChatGPT account's switches
// and, under them, how early a reset about to expire is used. app.js
// imports this when renderSettings draws them (renderAutoResetOwn), so it weighs
// nothing on the core.
// nothing on the core. Each ChatGPT account's own warm-up time is drawn here too
// (warmAtOwnPaint), moved out of app.js for its budget.
// renderAutoResetOwn lists each ChatGPT account under
// "Codex: auto-use resets", with its switch, the same say as on the
@@ -10,6 +11,7 @@
// window's Settings. The row shows while a Codex
// account is signed in, or one is still on.
window.autoResetOwnPaint = function (s) {
warmAtOwnPaint(s);
const head = $("#codexAutoResetRow");
const list = head.parentElement;
list.querySelectorAll(".ar-own").forEach((r) => r.remove());
@@ -149,3 +151,51 @@ function resetLeadOwn(b, cur, set) {
b.replaceWith(i);
i.focus(NO_SCROLL);
}
// warmAtOwnPaint: each ChatGPT account's own daily time (#957,
// codexWarmAtOf), shown with two accounts or one with its own
function warmAtOwnPaint(s) {
const list = $("#codexWarmList");
list.querySelectorAll(".warm-own").forEach((r) => r.remove());
const own = s.codexWarmAtOf || {};
const users = [...(s.codexUsers || [])];
for (const u of Object.keys(own)) if (!users.some((x) => x.toLowerCase() === u)) users.push(u);
if (users.length < 2 && !Object.keys(own).length) return;
const save = async (user, at) => {
try {
prefs = await writingPrefs(api("settings/codex-warm-at", { user, at }));
if (state) state.settings = prefs;
renderSettings();
} catch (e) {
statusTErr(e);
renderSettings();
}
};
for (const user of users) {
const at = own[user.toLowerCase()];
const mode = at === undefined ? "same" : at === "off" ? "off" : "own";
const r = el("div", "row pref warm-own");
r.dataset.user = user;
const who = el("div", "who");
const name = el("div", "name", user);
name.title = user;
const sub = el("div", "sub", mode === "own" ? t("Its own time each day")
: mode === "off" ? t("Not started at a time of day")
: s.codexWarmAt ? t("Same as above, {at}", { at: warmTimes(s.codexWarmAts, s.codexWarmAt).join(", ") }) : t("Same as above, off"));
sub.title = t("Give accounts different times and one window starts as another runs out.");
who.append(name, sub);
const box = el("div", "warm-at");
if (mode === "own") {
const i = input(at, "06:00", "time");
i.className = "at";
i.setAttribute("aria-label", t("{who}'s time of day", { who: user }));
blurOnEnter(i);
i.onchange = () => { if (i.value && i.value !== at) save(user, i.value); };
box.append(i);
}
box.append(segs([["same", t("Same")], ["own", t("Own")], ["off", t("Off")]], mode, (v) =>
save(user, v === "same" ? "" : v === "off" ? "off" : s.codexWarmAt || "06:00")));
r.append(who, box);
$("#warmNowRow").before(r); // Warm up now stays last
}
}
File diff suppressed because one or more lines are too long
+5
View File
@@ -244,6 +244,11 @@ async function openProvPrefs(page, id) {
await adv.waitFor({ timeout: 60000 });
if (!(await adv.evaluate((d) => d.open))) await adv.locator(":scope > summary").click();
await page.locator(".editor .prov-prefs .row").filter({ visible: true }).first().waitFor({ timeout: 60000 });
// and the editor at rest: with a warm-up or check-in on, Advanced opens
// on its own, so no click waits out the modal's opening and a row read
// now is read mid-scale (warm-at-times, WebKit 900px, 0.66px over)
await page.waitForFunction(() => !document.querySelector("#modal").getAnimations({ subtree: true })
.some((a) => a.playState === "running" && a.effect?.getComputedTiming().endTime !== Infinity), null, { timeout: 60000 });
}
// inEditor brings a control in a provider's editor into sight. The editor
// is in the modal, whose body isn't a view, so the app lets the scroll
+87
View File
@@ -0,0 +1,87 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// "我的预热去哪里了??" (ChrisYagao on X): a subscription's warm-up and
// daily check-in moved from Settings into its provider's editor (11-09) and
// then under the editor's Advanced, folded (11-10), so a user who had one
// on opened the editor and saw nothing of it. Advanced now opens on its own
// when the provider's warm-up (on reset or at times of day) or its daily
// check-in is on, as it does for Routing; with them off it stays folded,
// and a fold the reader closed by hand stays closed. Codex, Claude Code and
// a plugin that checks in; en, zh, zh-TW, ja, de; both engines; 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 { provPrefsProviders } = require("./reader.cjs");
const assets = path.resolve(__dirname, "../assets");
const names = { codex: "Codex", claude: "Claude Code", "trae-cn": "Trae CN" };
function serve(lang, settings) {
const s = { theme: "light", lang, currency: "usd", codexWarmup: "", claudeWarmup: "", codexUsers: ["ann@example.test"], claudeUsers: ["ann@example.test"],
checkinPlugins: [{ id: "trae-cn", name: "Trae CN", on: false }], ...settings };
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 === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: s });
if (url.pathname === "/api/settings") return json(s);
if (url.pathname === "/api/providers") return json(provPrefsProviders(Object.keys(names), names));
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)];
try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); }
};
}
// provider, what is set, whether Advanced opens and the list that shows
const CASES = [
["codex", "nothing", {}, false, "#codexWarmList"],
["codex", "warm up on reset", { codexWarmup: "week" }, true, "#codexWarmList"],
["codex", "daily warm-up", { codexWarmAts: ["06:00"], codexWarmAt: "06:00" }, true, "#codexWarmList"],
["claude", "nothing", {}, false, "#claudeWarmList"],
["claude", "warm up on reset", { claudeWarmup: "all" }, true, "#claudeWarmList"],
["claude", "daily warm-up", { claudeWarmAts: ["07:30"], claudeWarmAt: "07:30" }, true, "#claudeWarmList"],
["claude", "Codex's warm-up only", { codexWarmup: "week" }, false, "#claudeWarmList"],
["trae-cn", "nothing", {}, false, ".ci-plugin"],
["trae-cn", "daily check-in", { checkinPlugins: [{ id: "trae-cn", name: "Trae CN", on: true }] }, true, ".ci-plugin"],
];
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
test(`${engine} ${lang}: a provider's warm-up or check-in that is on opens its editor's Advanced (ChrisYagao)`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
for (const [id, set, settings, opens, list] of CASES) {
const at = `${id}, ${set}`;
const page = await (await browser.newContext({ viewport: { width: 900, height: 760 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [];
page.on("pageerror", (e) => { if (engine === "webkit" && /due to access control checks/.test(e.message)) return; errors.push(e.message); }); // #1350
await page.route("**/*", serve(lang, settings));
await page.goto(`http://magpie.test/?view=providers&edit=${encodeURIComponent(id)}`);
const adv = page.locator(".editor details.advanced");
await adv.waitFor({ timeout: 60000 });
// the lists are mounted once Settings are read
await page.waitForFunction((list) => !!document.querySelector(`.editor .prov-prefs ${list}`), list);
assert.equal(await adv.evaluate((d) => d.open), opens, `${at}: Advanced open`);
assert.equal(await page.locator(`.editor .prov-prefs ${list}`).first().isVisible(), opens, `${at}: its list shown`);
if (opens) {
// closed by hand, a redraw of Settings leaves it closed
await adv.locator(":scope > summary").click();
await page.waitForFunction(() => !document.querySelector(".editor details.advanced").open);
await page.evaluate(() => renderSettings());
await page.waitForTimeout(100);
assert.equal(await adv.evaluate((d) => d.open), false, `${at}: closed by hand stays closed`);
}
assert.deepEqual(errors, [], at);
await page.context().close();
}
});
}
}