netube99 on X: one feature's settings are spread over pages that don't
say where the rest are. Plugins › Built-in had six rows (Key limits,
Groups, Rotation, Warm-ups, Middleware, Tools) with no page and no link,
so a user who turned one on was left to find where it shows. And the
Gateway page's one setting, Recent calls at a time, was a form under its
row in Plugins › Built-in, two pages from the calls it is about.
- pluginrt.Manifest gets Opens: the window page a built-in without a page
of its own is used on. budget → gateway (keys' limits), groups →
groups, rotation and warmups → providers (a provider's editor),
middleware and tools → plugins. builtinJSON sends it; featGo links to
that page by its sidebar name, as for a page plugin.
- A plugin with a page draws its settings there, not under its row
(renderBuiltins). The Gateway page draws its schema under Recent calls
(renderGatewayOwn), saves through /api/plugins/builtin as before, and
ends with a row "Port, allowed addresses and model ids" that opens
Settings › Network and sharing at the gateway's rows (4 languages).
Tests:
- TestBuiltinSaysWhereItsSettingsAre holds SetAt, Page and Opens per
built-in.
- builtins.test.cjs: no form in Built-in, and each Opens row's link says
its page's sidebar name. Its row reached by the wheel now counts the
window's bottom too, and frees a switch under the view's floating To
the bottom button by wheeling toward the window's middle: the rows grew
with their links, and WebKit de 420 left Usage's switch under it.
- gateway-own-settings.test.cjs (new): the setting under the calls,
translated, 20, picking 50 posts {id: gateway, config: {callsPage: 50}},
the row opens Settings › Network at #portList flashed; every language,
Chromium and WebKit, 1100 and 420, nothing past the window.
- builtin-places.test.cjs: Library's row now leads to Library.
Run at this tree (on origin/main e3f1efdaa), on mote:
- gofmt -l: nothing. go vet ./internal/gui ./internal/pluginrt
./plugins/..., GOOS=linux go vet -tags nogui, GOOS=windows go vet: ok.
- go test -run 'TestBuiltin|TestCoreScriptBudget|Translat' ./internal/gui
./internal/pluginrt ./plugins/...: ok.
- node --test builtins builtin-places websearch-places gateway-own-settings
gateway-keys-off i18n-en-no-cjk: 272 pass, 0 fail (both engines).
- i18n-keys: "a plugin's words are its own" red, the same on a clean
origin/main e3f1efdaa (#5332, #5327, #5482, #5426); fixed next.
Broken by hand: without budget's Opens, TestBuiltinSaysWhereItsSettingsAre
fails (want "gateway"); without the renderGatewayOwn call,
gateway-own-settings is 0 of 10 in Chromium.
Not tried: the real app; the whole GUI suite (next, behind suite.lock).
75 lines
4.3 KiB
JavaScript
75 lines
4.3 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||
// The Gateway page's own setting, Recent calls at a time, was set in
|
||
// Plugins › Built-in, two pages from the calls it is about, and the page
|
||
// didn't say where its port and allow list are (the scattered settings
|
||
// audit after netube99 on X). It is now under the calls, drawn from the
|
||
// plugin's schema and saved as picked, with a row that opens Settings ›
|
||
// Network and sharing at the gateway's rows. Every language, Chromium and
|
||
// WebKit, at 1100 and 420 wide, nothing past the window's edge.
|
||
const assert = require("node:assert/strict");
|
||
const { test } = require("node:test");
|
||
const { chromium, webkit } = require("playwright");
|
||
const { fixture } = require("./fixtures/caller-keys.cjs");
|
||
const { strings } = require("./strings.cjs");
|
||
|
||
const { I18N } = strings();
|
||
const tr = (lang, s) => (lang === "en" ? s : I18N[lang]?.[s] ?? s);
|
||
|
||
const SCHEMA = {
|
||
type: "object",
|
||
properties: { callsPage: { type: "integer", title: "Recent calls at a time", description: "How many of the gateway's recent calls the page shows, and how many more each Show more adds", enum: [10, 20, 50, 100], default: 20 } },
|
||
"x-order": ["callsPage"],
|
||
};
|
||
|
||
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 [1100, 420]) {
|
||
test(`${engine} ${lang} ${width}: the Gateway page has its own settings and leads to Settings`, 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: 760 }, reducedMotion: "reduce" })).newPage();
|
||
page.setDefaultTimeout(6000);
|
||
page.setDefaultNavigationTimeout(60000);
|
||
const errors = [];
|
||
page.on("pageerror", (e) => errors.push(e.message));
|
||
const config = { callsPage: 20 }, posts = [];
|
||
const gateway = () => ({ id: "gateway", name: "Gateway page", sub: "", on: true, chosen: true, source: "preset", state: "active", inUse: 0,
|
||
setAt: "network #portList", page: "gateway", schema: SCHEMA, config: { ...config } });
|
||
const base = fixture(lang, "light", []);
|
||
await page.route("**/*", async (route) => {
|
||
const req = route.request(), url = new URL(req.url());
|
||
if (url.pathname === "/api/plugins/builtin" && req.method() === "POST") {
|
||
const b = req.postDataJSON();
|
||
posts.push(b);
|
||
Object.assign(config, b.config);
|
||
return route.fulfill({ json: [gateway()] });
|
||
}
|
||
if (url.pathname === "/api/settings") {
|
||
return route.fulfill({ json: { lang, theme: "light", lan: false, lanURLs: [], port: 3999, fx: { rate: 7.2, at: new Date().toISOString() }, builtins: [gateway()] } });
|
||
}
|
||
return base(route);
|
||
});
|
||
await page.goto("http://magpie.test/?view=gateway");
|
||
const own = page.locator("#gwOwn");
|
||
const set = own.locator('[data-setting="callsPage"]');
|
||
await set.waitFor();
|
||
assert.equal((await set.locator(".name").textContent()).trim(), tr(lang, "Recent calls at a time"));
|
||
// under the calls it is about
|
||
assert.ok(await page.evaluate(() => document.querySelector("#activity").compareDocumentPosition(document.querySelector("#gwOwn")) & Node.DOCUMENT_POSITION_FOLLOWING));
|
||
assert.equal((await set.locator(".proto.pick").textContent()).trim(), "20");
|
||
await set.locator(".proto.pick").click();
|
||
await page.locator(".proto-menu .pm-item", { hasText: "50" }).click();
|
||
await page.waitForFunction(() => document.querySelector('#gwOwn [data-setting="callsPage"] .proto.pick')?.textContent.trim() === "50");
|
||
assert.deepEqual(posts, [{ id: "gateway", config: { callsPage: 50 } }]);
|
||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth + 1), "fits");
|
||
|
||
const go = own.locator("button.text").last();
|
||
assert.equal((await go.textContent()).trim(), tr(lang, "Settings") + " › " + tr(lang, "Network and sharing"));
|
||
await go.click();
|
||
await page.locator("#view-settings #portList .row.flash").waitFor();
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
}
|
||
}
|
||
}
|