gateway: a key's Limit and Models keep their room unhovered (#4072)
f835bd713 gave the Gateway page's key list the Providers keys list's
class (.accts.keys), whose rules squeeze Models, Limit and the quiet
words to no width until the row is hovered. On the Gateway page that
left Limit at 0px wide: Playwright called it "not visible", and a real
row reflowed sideways under the pointer. The list is .accts.gw-keys
only now; narrow, the masked key gives up its room first (flex 0 6,
ellipsis, 3em at least) before the key's name does.
Tests brought up to the redesign:
- gateway-older and web-page waited on #gateway .dot, gone since
f835bd713; they wait on the mark (#gateway > .gw-mark).
- gateway-key-limit's window is 560 tall, not 420: in webkit the limit
editor ended at 462px, so Playwright's own check() scrolled the box
into view and the test read that as "Cancel moved the page".
Run at this head on mote (both engines, en+zh where the files have it):
gateway-*.test.cjs (all 26), web-page, api-key-theme, click-scroll,
i18n-keys: all pass except the 560-wide reads right after a resize
that are already filed (#3523 key-limit, #3797 caller-keys, and
key-models' same check). go test ./internal/gui -run Budget: ok.
Broken by hand: with the keys class put back, gateway-key-cycle and
gateway-key-limit go red on "element is not visible".
Not tried: the real app on Windows and Linux.
This commit is contained in:
@@ -2331,8 +2331,10 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; }
|
||||
/* a gateway key: the copy right beside the masked key, the rest under
|
||||
its … (the owner: a copy out in the row's middle looked lost) */
|
||||
.gw-keys .acc > .plan + .copy { margin-left: -5px; }
|
||||
/* narrow, the masked key gives up its room before the key's name does */
|
||||
.gw-keys .acc > .plan { flex-shrink: 6; }
|
||||
/* narrow, the masked key gives up its room before the key's name does.
|
||||
Not the Providers keys list's rules (.accts.keys): Limit and Models keep
|
||||
their room there while hidden, so a hover doesn't push the row about */
|
||||
.gw-keys .acc > .plan { flex: 0 6 auto; min-width: 3em; overflow: hidden; text-overflow: ellipsis; }
|
||||
.gw-keys .gw-key-more { flex: none; color: var(--muted); }
|
||||
.gw-keys .gw-key-more:is(:hover, .open) { color: var(--fg); }
|
||||
#view-gateway .row-head, #view-usage .row-head { margin: 14px 0 6px; padding: 0 2px; }
|
||||
|
||||
@@ -207,7 +207,7 @@ function renderGatewayKeys() {
|
||||
$("#addGatewayKey").onclick = () => { gatewayKeyDraft = ""; renderGatewayKeys(); };
|
||||
// keys: a badge left unset folds away until the row is pointed at, as
|
||||
// on a provider's keys, so nothing invisible holds a place in the row
|
||||
const list = el("div", "accts keys gw-keys");
|
||||
const list = el("div", "accts gw-keys");
|
||||
if (gatewayKeys === null) {
|
||||
if (gatewayKeysErr) list.append(el("div", "none", t(gatewayKeysErr))), box.append(list);
|
||||
return;
|
||||
|
||||
@@ -24,7 +24,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
test(`${engine} ${lang}: a gateway key's limit is shown and set with Save`, 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: 1000, height: 420 }, reducedMotion: "reduce" })).newPage();
|
||||
const page = await (await browser.newContext({ viewport: { width: 1000, height: 560 }, reducedMotion: "reduce" })).newPage();
|
||||
page.setDefaultTimeout(6000);
|
||||
const events = [], errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
|
||||
@@ -62,14 +62,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
if (older) {
|
||||
assert.equal((await state.textContent()).trim(), c.state);
|
||||
assert.match(await page.locator("#gateway .sub").textContent(), c.sub);
|
||||
assert(await page.locator("#gateway .dot").evaluate((d) => !d.classList.contains("on")), "the dot isn't green");
|
||||
assert(await page.locator("#gateway > .gw-mark").evaluate((d) => !d.classList.contains("on")), "the mark's light isn't green");
|
||||
// the whole text is there to read, nothing cut off, and the page doesn't scroll sideways
|
||||
const fits = await page.locator("#gateway .sub").evaluate((s) => s.scrollWidth <= s.clientWidth + 1);
|
||||
assert(fits, "the advice is cut off");
|
||||
assert(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth), "the page scrolls sideways");
|
||||
} else {
|
||||
assert.equal((await state.textContent()).trim(), c.same);
|
||||
assert(await page.locator("#gateway .dot").evaluate((d) => d.classList.contains("on")));
|
||||
assert(await page.locator("#gateway > .gw-mark").evaluate((d) => d.classList.contains("on")));
|
||||
}
|
||||
await context.close();
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
};
|
||||
|
||||
const { page, errors, failed, seen } = await open(true);
|
||||
await page.locator("#gateway .dot").waitFor();
|
||||
await page.locator("#gateway > .gw-mark").waitFor();
|
||||
|
||||
// the request archive's switch, over the Usage page's requests
|
||||
await page.locator('[data-view="usage"]').first().click();
|
||||
@@ -147,7 +147,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
|
||||
// the app's window still takes its runtime, for close and maximise
|
||||
const app = await open(false);
|
||||
await app.page.locator("#gateway .dot").waitFor();
|
||||
await app.page.locator("#gateway > .gw-mark").waitFor();
|
||||
for (let i = 0; i < 50 && !app.seen.paths.includes("/wails/runtime.js"); i++) await app.page.waitForTimeout(40);
|
||||
assert(app.seen.paths.includes("/wails/runtime.js"), "the app's window no longer loads its runtime");
|
||||
assert.deepEqual(app.errors, []);
|
||||
|
||||
Reference in New Issue
Block a user