nb5p on Discord: on the Gateway page's model list the image chip at a
row's end stood shorter than the reasoning chip ("低–ultra") and the
context chip ("272K"). The text chips are inline-flex with a 16px line;
the image chip holds only the 11px glyph (display:block), so it was 11px
tall. It now takes the text chips' 16px as its height.
modelInfo() is the one renderer of these chips. Its two callers, the
Gateway's model list and the routing group editor's member rows, share
the selector the fix is on. The provider editor shows images as a
checkbox and the Agents page and pickers show no such chip.
gateway-model-chip-height.test.cjs measures every chip of every row in
en and zh, light and dark, at 900px and 420px, in Chromium and WebKit:
same height, same centre line.
gateway-model-chip-height.test.cjs is red on the old CSS (the image
chip 11px against 16px) and green with it.
Run on mote (macOS) at origin/main 699ddf152 with this commit and its
two neighbours (nb5p chip, dzxx0496 renewal, dzxx0496 Until used up).
Pushed on b2145eac1, whose five commits since change app.css and app.js
only for a key row's chips; at the pushed tree gofmt, the gui, routes
and gateway vets (Linux nogui, Windows), TestCoreScriptBudget (core
1,532,891), the Drain Go tests and 11 GUI files (gateway-model-chip-
height, routing-drain, routing-renews-stay, routing-behind-why,
routing-group-strategy, routing-save, builtins, i18n-keys, gui-de,
gui-zh-tw, key-row-chips-fit) were run again: 190 of 190 ok.
- gofmt -l clean; GOOS=linux go vet -tags nogui ./..., GOOS=windows go
vet ./... and go vet ok.
- go test internal/routes, internal/gateway, internal/provider,
internal/cli, internal/tui, plugins/rotation: ok; internal/gui's
TestCoreScriptBudget ok (core 1,532,816 of 1,533,105).
- GUI: routing-*, builtins, gateway-model*, model-chip*, i18n-keys,
gui-* and codex-credits-last in both engines: 2211 tests, 68 red,
none new: model-chip-steady 20 (#4388), gui-ja's {agent} string
(#4580), and 11 routing-* files under load (#4585, #3789, #3799).
The same 11 files run alone at cdfdb62c6 were 32 of 116 red, and 26
with the stack, the same tests but rule-remove, whose red languages
vary run to run (9 cases, then 5). model-chip-steady was 20 of 20 red
at cdfdb62c6 alone.
Earlier, at f811bf291 with the stack: go test -timeout 45m ./... had 82
packages ok, internal/gui red only on
TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners/macOS_26_SDK (#3949). The whole GUI suite had 301
of 16930 red in 52 files. Those 52 files rerun had 272 red with the
stack and 276 at f811bf291 alone, the same tests.
83 lines
4.8 KiB
JavaScript
83 lines
4.8 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
|
// nb5p on Discord: on the Gateway page's model list, the image chip at a
|
|
// row's end stood shorter than its reasoning chip ("低–ultra") and its
|
|
// context chip ("272K"): it holds a glyph, not a line of text, so it took
|
|
// the glyph's 11px where the text chips take their 16px line. Every chip
|
|
// of a row is as tall as the others and centred on the same line, in light
|
|
// and dark, in English and Chinese, at the window's width and a narrow one.
|
|
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 assets = path.resolve(__dirname, "../assets");
|
|
const providers = {
|
|
providers: [
|
|
{ id: "acme", name: "Acme", icon: "generic", agents: [], models: [
|
|
{ id: "gpt-5.5", name: "GPT-5.5", on: true, efforts: ["low", "medium", "high", "xhigh"], images: true, context: 272000 },
|
|
{ id: "flash", name: "Flash", on: true, efforts: ["low", "high"], images: true, context: 500000 },
|
|
{ id: "text-only", name: "Text Only", on: true, images: false, context: 128000 },
|
|
] },
|
|
],
|
|
gateway: { running: true, window: true, mine: true, url: "http://127.0.0.1:3999", models: 3, calls: [], groups: [] },
|
|
};
|
|
|
|
function serveAs(lang, theme) {
|
|
const state = { agents: [], profiles: [], settings: { lang, theme } };
|
|
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:${JSON.stringify(lang)},theme:${JSON.stringify(theme)},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(state);
|
|
if (url.pathname === "/api/providers") return json(providers);
|
|
if (url.pathname === "/api/groups") return json({ groups: [] });
|
|
if (url.pathname === "/api/gateway/trace") {
|
|
if (url.searchParams.get("wait")) await new Promise((r) => setTimeout(r, 20e3));
|
|
return json({ mine: true, now: new Date().toISOString(), seq: 1, totals: { requests: 0, rerouted: 0, errors: 0 }, routes: [] });
|
|
}
|
|
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)];
|
|
await route.fulfill({ body: await fs.readFile(file), contentType });
|
|
};
|
|
}
|
|
|
|
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
|
test(engine + ": a model row's chips are all one height, the image chip too", async (t) => {
|
|
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
|
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
|
t.after(() => browser.close());
|
|
for (const lang of ["en", "zh"]) for (const theme of ["light", "dark"]) for (const width of [900, 420]) {
|
|
const context = await browser.newContext({ viewport: { width, height: 700 }, reducedMotion: "reduce", colorScheme: theme });
|
|
const page = await context.newPage();
|
|
page.setDefaultTimeout(5000);
|
|
page.setDefaultNavigationTimeout(60000);
|
|
const errors = [];
|
|
page.on("pageerror", (e) => errors.push(e.message));
|
|
await page.route("**/*", serveAs(lang, theme));
|
|
await page.goto("http://magpie.test/?view=gateway");
|
|
await page.locator("#gwModels .row.model .minfo .mi-img").first().waitFor();
|
|
const rows = await page.locator("#gwModels .row.model .minfo").evaluateAll((boxes) => boxes.map((box) =>
|
|
[...box.querySelectorAll(".badge")].filter((b) => b.offsetParent).map((b) => {
|
|
const r = b.getBoundingClientRect();
|
|
return { cls: b.className, h: r.height, mid: r.top + r.height / 2 };
|
|
})));
|
|
const where = `${lang} ${theme} ${width}px`;
|
|
let imgs = 0;
|
|
for (const chips of rows) {
|
|
const text = chips.find((c) => !c.cls.includes("mi-img"));
|
|
for (const c of chips) {
|
|
if (c.cls.includes("mi-img")) imgs++;
|
|
assert(Math.abs(c.h - text.h) < 0.5, `${where}: ${c.cls} is ${c.h}px tall, ${text.cls} ${text.h}px`);
|
|
assert(Math.abs(c.mid - text.mid) < 0.5, `${where}: ${c.cls} centred at ${c.mid}, ${text.cls} at ${text.mid}`);
|
|
}
|
|
}
|
|
assert(imgs >= 2, `${where}: the image chips were measured (${imgs})`);
|
|
assert.deepEqual(errors, [], where);
|
|
await context.close();
|
|
}
|
|
});
|
|
}
|