gui: a lone plugin's check-in tab is named for it, not "Plugins"

ljq906416 and justrun_way on X couldn't find WorkBuddy's daily check-in
after it moved to its plugin. The WorkBuddy plugin (0.2.0 on) checks in
itself, so magpie hides its own WorkBuddy tab under Settings › Usage's
check-in tabs and the switch sits under a tab labelled "Plugins" (插件),
which nobody looking for WorkBuddy reads. With one plugin checking in,
the tab now carries that plugin's name (WorkBuddy), as a built-in's tab
does; two or more still share "Plugins". The label is set through
data-en, so a language change keeps it.

Run (wsl-run, Linux, Chromium + WebKit, en/zh/zh-TW/ja/de):
plugin-checkin, checkin-reason, checkin-reason-once and i18n-keys:
64 pass, 0 fail. The new two-plugin test checks the shared tab's
translated name and both rows; the 440px test checks the lone tab reads
"FakeCo".
Broken by hand: with the old app.js the 440px test fails in chromium en
and zh (expected FakeCo, read "Plugins"); the two-plugin test passes
there, as it guards the shared case.
Size budgets summed by hand the way TestCoreScriptBudget does (the Go
package needs cgo, which wsl lacks): app.js 1,308,499 of 1,316,874,
core 1,529,963 of 1,533,802, no raise.
Not tried: the real app with a signed-in WorkBuddy plugin.
This commit is contained in:
yetone
2026-11-03 17:58:06 +08:00
parent 40a287b217
commit 0acba61a35
2 changed files with 29 additions and 5 deletions
+5 -2
View File
@@ -22457,8 +22457,11 @@ async function renderUpdate(r, u) {
// a Daily check-in row per plugin that checks in itself (auth.checkin)
function renderPluginCheckins(s) {
const ps = s.checkinPlugins || [];
$("#warmTab-plugins").hidden = !ps.length;
const ps = s.checkinPlugins || [], tab = $("#warmTab-plugins");
tab.hidden = !ps.length;
// one plugin checking in: its tab is its name, as a built-in's is
tab.dataset.en = ps.length === 1 ? ps[0].name || ps[0].id : "Plugins";
tab.textContent = t(tab.dataset.en);
setWarmTab(warmTab);
$("#pluginCheckinList").replaceChildren(...ps.map((p) => {
const row = el("div", "row pref");
+24 -3
View File
@@ -72,12 +72,12 @@ const quotas = () => [
{ provider: "codex", name: "Codex", icon: "openai", plan: "Plus", windows: [{ name: "5 hours", used: 20 }] },
];
function serve(lang, asked) {
function serve(lang, asked, more = []) {
const settings = { theme: "light", lang, quotaLeft: false, currency: "usd", pluginCheckins: { fakeco: false },
checkinPlugins: [{ id: "fakeco", name: "FakeCo", on: false, checkins: [
{ user: "ann", by: "plugin:fakeco", vendor: "FakeCo", day: today, outcome: "claimed", credit: 50, streak: 3 },
{ user: "bob", by: "plugin:fakeco", vendor: "FakeCo", day: today, outcome: "captcha" },
] }] };
] }, ...more] };
return async (route) => {
const url = new URL(route.request().url());
const json = (data) => route.fulfill({ json: data });
@@ -173,6 +173,26 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.deepEqual(errors, []);
});
test(`${engine} ${lang}: two plugins checking in share one Plugins tab`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const page = await (await browser.newContext({ viewport: { width: 900, height: 900 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, [], [{ id: "otherco", name: "OtherCo", on: true, checkins: [] }]));
await watchSettingsReads(page);
await page.goto("http://magpie.test/?view=settings&tab=usage");
await settingsDrawn(page);
const tab = page.locator("#warmTab-plugins");
await tab.waitFor();
assert.equal((await tab.textContent()).trim(), w.tab);
await tab.click();
for (const id of ["fakeco", "otherco"]) await page.locator(`#pluginCheckinList .row[data-provider="${id}"]`).waitFor();
assert.deepEqual(errors, []);
});
test(`${engine} ${lang}: Settings has a Plugins check-in tab at 440px`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
@@ -188,7 +208,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const tab = page.locator("#warmTab-plugins");
await tab.waitFor();
assert.equal(await tab.isHidden(), false);
assert.equal((await tab.textContent()).trim(), w.tab);
// one plugin checks in: the tab is its name (WorkBuddy's users looked for "WorkBuddy")
assert.equal((await tab.textContent()).trim(), "FakeCo");
assert.equal(await page.locator("#warmTab-qoder").isHidden(), true, "Qoder's tab with no Qoder account");
// at 440x900 the tabs are below the fold: the reader scrolls to them
await page.mouse.move(220, 400);