Files
magpie/internal/gui/tests/about-report.test.cjs
T
yetone 4519eea711 gui: Settings › About has Report a problem, which copies the details and opens the feedback post (River_WLan on X)
A user who hit a problem had to work out what to tell us. Settings ›
About now has a Report a problem row with an Open button: it copies a
short block to the clipboard (magpie version, OS name and version,
architecture, and whether this is the app or the browser page), says it
was copied, and opens the feedback post
https://x.com/magpie_router/status/2119861020978188499 so the user can
paste it in a reply. GET /api/feedback builds the block and the URL.

The block holds no account names, keys, paths, host or user names, and
nothing is put in a URL: the opened address has no query or fragment.
The TUI has no Community links, so it gets nothing here. The core script
budget is raised by 458 bytes for the row and its translations
(1,263,851 to 1,264,309 with the provider commit under it).

Run, on mica: new TestFeedbackBlockHoldsNoPrivateFacts (version, OS,
arch, surface; no home dir, host or USER; URL with no ? or #; macOS
version present; unknown surface becomes app) and about-report.test.cjs
(clipboard gets the block, /api/open gets the post URL with no
diagnostics), chromium and webkit, en zh zh-TW ja de, widths 1100 and
420, 40 of 40 with about-website; vet on darwin, windows and linux nogui
clean. Broken by hand: a "Home:" line added to the block turns the Go
test red. A loaded run of the About files plus gui-de/ja/zh-tw and the
i18n files had 40 reds in usage and picker files; the reachable ones
were run alone on origin/main 5e933e153 (see the provider commit under
this one: usage-hidden-way-back #6295 and usage-agents-hide #3414 are
red there; the rest pass alone).

Not tried: the Linux app (WebKitGTK) and Windows; the clipboard write in
the Wails webview rather than a browser.
2026-11-12 19:31:11 +08:00

52 lines
2.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const assert = require("node:assert/strict");
const { test } = require("node:test");
const { chromium, webkit } = require("playwright");
const { fixture } = require("./fixtures/caller-keys.cjs");
const { openPart } = require("./reader.cjs");
// Settings › About's Report a problem copies the version, the system and
// the architecture, says so, then opens the feedback post on X. What it
// copied is never in the link (River_WLan on X).
const words = {
en: ["Report a problem", "Details copied. Paste them in your reply"],
zh: ["反馈问题", "信息已复制,请粘贴到你的回复里"],
"zh-TW": ["回報問題", "資訊已複製,請貼到你的回覆裡"],
ja: ["問題を報告", "情報をコピーしました。返信に貼り付けてください"],
de: ["Problem melden", "Angaben kopiert. Fügen Sie sie in Ihre Antwort ein"],
};
const block = "magpie 0.1.9\nOS: macOS 26.2\nArch: arm64\nOpened in: app";
const post = "https://x.com/magpie_router/status/2119861020978188499";
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of Object.keys(words)) {
for (const width of [1100, 420]) {
test(`${engine} ${lang} ${width}: About reports a problem`, 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, height: 800 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(6000);
page.setDefaultNavigationTimeout(60000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
const events = [];
await page.route("**/*", fixture(lang, "light", events));
await page.route("**/api/feedback*", (r) => r.fulfill({ json: { text: block, url: post } }));
await page.route("**/api/open", (r) => { events.push({ action: "open", body: r.request().postDataJSON() }); return r.fulfill({ status: 204 }); });
await page.goto("http://magpie.test/");
await page.locator("#prefs").click();
await openPart(page, "about");
const row = page.locator("#about .row", { has: page.locator(".who", { hasText: words[lang][0] }) });
await row.waitFor();
await row.locator("button.text").click();
await page.locator("#status", { hasText: words[lang][1] }).waitFor();
assert.equal(events.find((e) => e.action === "clipboard").body.text, block);
const opened = events.find((e) => e.action === "open");
assert.equal(opened.body.url, post);
assert.equal(opened.body.url.includes(encodeURIComponent("magpie 0.1.9")), false);
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true, "About wider than the window");
assert.deepEqual(errors, []);
});
}
}
}