The owner asked for the licence notices in the release package (moejs alpha.11 compiles Intl's data in, which carries its own notices). THIRD_PARTY_NOTICES is embedded in the binary (main.go, //go:embed) and handed to internal/notices; `magpie licenses` prints it, GET /api/notices serves it, and Settings › About has an Open-source licenses row that opens it in a dialog, in every language. `make app` copies the file into the .app's Resources too. The core's scripts are 1,527,245 bytes, their budget raised to it with no room added; app.js stays under its own. Run at this head (rebased on origin/main): - win-run (Windows 11): go vet -tags nogui . ./internal/notices ./internal/cli; go test TestNoticesFollowMoejs (.), ./internal/cli, TestCoreScriptBudget (./internal/gui): ok. - wsl-run (Ubuntu 24.04): go vet -tags nogui ./..., go build -tags nogui: ok. Run at the pre-rebase head 14e2d13fb, on mote (macOS): - gofmt; make app's copy byte-identical to the file; `magpie licenses` output equal to the file; GOOS=linux/windows vet and build; go test . ./internal/cli: ok. ./internal/gui: only TestMainWindowCorners red, the same on origin/main (#3949). - about-notices.test.cjs: chromium and webkit, en zh zh-TW ja de, 1100 and 420px: all ok. Broken by hand: TestNoticesFollowMoejs red with the embedded file cut. Not run: the GUI suite at this head. The rebase met main's cancelAsk helper where showNotices sat, and the dialog's Done now uses it (the same stopPropagation + closeConfirmAsk). The whole GUI suite at 14e2d13fb was cut off when mote went down at load ~50: the files it reached outside About had reds, most of them 180s browser-launch timeouts, the rest passing in other languages or the other engine; they are run again once mote is back, and any that stay red are filed.
51 lines
2.8 KiB
JavaScript
51 lines
2.8 KiB
JavaScript
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");
|
||
|
||
// Every build carries moejs's third-party notices (THIRD_PARTY_NOTICES,
|
||
// embedded in the binary); Settings › About's Open-source licenses shows
|
||
// them whole, scrolled inside the dialog, in every language and at the tray
|
||
// panel's width.
|
||
const words = {
|
||
en: "Open-source licenses", zh: "开源许可", "zh-TW": "開源授權", ja: "オープンソースライセンス", de: "Open-Source-Lizenzen",
|
||
};
|
||
const text = "magpie third-party notices\n" + "x".repeat(300) + "\n" + "line\n".repeat(400) + "4. V8 (ported code)\n";
|
||
|
||
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 shows the third-party notices`, 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);
|
||
const errors = [];
|
||
page.on("pageerror", (e) => errors.push(e.message));
|
||
await page.route("**/*", fixture(lang, "light", []));
|
||
await page.route("**/api/notices", (r) => r.fulfill({ json: { text } }));
|
||
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] }) });
|
||
await row.locator("button.text").click();
|
||
const pre = page.locator("#modal .notices-text");
|
||
await pre.waitFor();
|
||
assert.equal(await pre.textContent(), text);
|
||
assert.equal(await page.locator("#modal .ehead b").textContent(), words[lang]);
|
||
// the long text scrolls in the dialog, which stays inside the window
|
||
const fits = await page.evaluate(() => {
|
||
const d = document.querySelector("#modal").firstElementChild.getBoundingClientRect();
|
||
const body = document.querySelector("#modal .ebody");
|
||
return { inside: d.right <= innerWidth && d.bottom <= innerHeight, scrolls: body.scrollHeight > body.clientHeight, wide: document.documentElement.scrollWidth <= innerWidth };
|
||
});
|
||
assert.deepEqual(fits, { inside: true, scrolls: true, wide: true });
|
||
await page.locator("#modal .bar button.primary").click();
|
||
await page.locator("#modal").waitFor({ state: "hidden" });
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
}
|
||
}
|
||
}
|