gui tests: the sidebar's room

18e82adc6 shows the sidebar from 1024pt, so the window's pages are 212pt
narrower and start at x=212. Eight files assumed the old room:

- header-centre measures the tabs' gap from the layout button.
- phone-web's desktop browser at 1000pt, under the sidebar's width.
- routing-pause and routing-pointer-pin wheel over the view, not the
  sidebar at x<212.
- routing-scroll-end takes its columns from .rt-more's own width
  (routing.js byWidth); usage-pack opens at 1512 to keep 1300 of room.
- purpose-filter closes the menu by a scroll that ends at the view's
  top, and measures once the rows and scroll are at rest.
- sessions-overview scrolls the shape card no further than a third down,
  and waits a frame after a resize: WebKit starts the reduced-motion
  transition of the sidebar's padding and settles it in the next frame.

Run: all eight, plus sidebar, side-toggle, session-identity and
usage-ledger, pass in Chromium and WebKit; each failed with 18e82adc6
and passed on d4eae3618 with it reverted.
This commit is contained in:
yetone
2026-10-12 01:58:58 +08:00
parent 2927023b99
commit 054bdb8bbe
8 changed files with 38 additions and 8 deletions
+3 -1
View File
@@ -41,9 +41,11 @@ const settled = (page) => page.evaluate(() => new Promise((r) => requestAnimatio
const header = (page) => page.evaluate(() => {
const top = document.querySelector(".top"), r = top.getBoundingClientRect();
const n = document.querySelector("#nav").getBoundingClientRect(), a = document.querySelector(".actions").getBoundingClientRect();
// the layout's button, shown, is what the tabs sit after
const lead = document.querySelector("#sideToggle"), from = lead.offsetParent ? lead.getBoundingClientRect().right : r.left;
return {
cls: top.className, update: !document.querySelector("#update").hidden,
off: n.left + n.width / 2 - innerWidth / 2, left: n.left - r.left, right: a.left - n.right,
off: n.left + n.width / 2 - innerWidth / 2, left: n.left - from, right: a.left - n.right,
};
});
+2 -1
View File
@@ -149,7 +149,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
test(`${engine}: a desktop browser and the window keep one row`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
for (const [web, width] of [[true, 1100], [false, 560]]) {
// a desktop browser narrower than the sidebar's width: its tabs in the header
for (const [web, width] of [[true, 1000], [false, 560]]) {
const page = await open(browser, { viewport: { width, height: 700 } }, web, "agents");
const [top, nav] = [await box(page, ".top"), await box(page, "#nav")];
assert.ok(nav.y + nav.height <= top.y + top.height + 1, `${web ? "web" : "window"} at ${width}: the tabs in the header's row`);
+11 -1
View File
@@ -278,8 +278,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await click(page, page.locator("#rtPurpose"));
const view = await page.locator("#view-routing").boundingBox();
await page.mouse.move(view.x + 10, view.y + 80);
await page.mouse.wheel(0, -200);
// a scroll closes it: down first if the view is at its top, and to the top again
if (!(await page.locator("#view-routing").evaluate((e) => e.scrollTop))) await page.mouse.wheel(0, 200);
await page.mouse.wheel(0, -2000);
await menu.waitFor({ state: "detached" });
await page.waitForFunction(() => document.querySelector("#view-routing").scrollTop === 0);
await click(page, page.locator("#rtPurpose"));
await title.click();
await unmarked.click();
@@ -291,6 +294,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await title.click();
await unmarked.click();
const all = await page.evaluate(() => t("All purposes"));
// the rows the two ticks asked for drawn, and the view at rest: the
// view is narrower beside the sidebar, and scrolls while they come in
for (let last = "", same = 0; same < 3; await page.waitForTimeout(100)) {
const now = await page.locator("#view-routing").evaluate((e) => [e.querySelectorAll(".rt-req").length, e.scrollTop, e.scrollHeight].join());
same = now === last ? same + 1 : 0;
last = now;
}
const beforeAll = await page.locator("#view-routing").evaluate((e) => e.scrollTop);
await menu.locator(".pm-item").filter({ has: page.locator(".pm-name", { hasText: all }) }).focus();
await page.keyboard.press("Enter");
+3 -1
View File
@@ -95,7 +95,9 @@ async function press(page, x) {
const d = await x.evaluate((e) => { const v = document.querySelector("#view-routing");
return Math.round(e.getBoundingClientRect().top - v.getBoundingClientRect().top - v.clientHeight / 2); });
if (Math.abs(d) > 100) {
await page.mouse.move(10, 300);
// over the view, not the sidebar beside it
const v = await page.locator("#view-routing").boundingBox();
await page.mouse.move(v.x + 10, 300);
await page.mouse.wheel(0, d);
await page.waitForTimeout(400);
}
@@ -70,7 +70,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.waitForTimeout(1500);
// the reader wheels down to the groups, then puts the pointer on the
// manual group's card
await page.mouse.move(8, h / 2);
// over the view, not the sidebar beside it
const v = await page.locator("#view-routing").boundingBox();
await page.mouse.move(v.x + 8, h / 2);
for (let i = 0; i < 80; i++) {
const top = await page.evaluate(() => document.querySelector(".rt-group").getBoundingClientRect().top);
if (top < 300) break;
@@ -73,7 +73,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const narrow = width <= 600;
assert.equal(await tracks(page, ".rt-stage"), narrow ? 2 : 3, "the stage's columns");
assert.equal(await tracks(page, ".rt-reqs"), width < 800 ? 2 : 4, "the requests' columns");
assert.equal(await tracks(page, ".rt-cols"), width >= 1200 ? 2 : 1, "the requests and the accounts, side by side or one under the other");
// by the room the page has, the sidebar's aside (routing.js byWidth)
const room = await page.locator(".rt-more").first().evaluate((e) => e.getBoundingClientRect().width);
assert.equal(await tracks(page, ".rt-cols"), room >= 1150 ? 2 : 1, "the requests and the accounts, side by side or one under the other");
// down to the end, by the wheel
const box = await view.boundingBox();
+11 -1
View File
@@ -173,7 +173,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.ok(hs[2] > hs[1] && hs[1] > hs[3] && hs[3] > hs[0], String(hs));
// wheeled to, as a person would: WebKit paints a scroll set from script late
await page.mouse.move(500, 400);
for (let i = 0; i < 20 && (await shape.boundingBox()).y > 300; i++) await page.mouse.wheel(0, 200);
// no further than to a third down the view: a step past it can take the
// card out over the view's top, and the click then scrolls it back first
for (let i = 0; i < 20; i++) {
const y = (await shape.boundingBox()).y;
if (y <= 300) break;
await page.mouse.wheel(0, Math.min(200, y - 250));
await page.waitForTimeout(60);
}
await page.waitForTimeout(300);
const y = (await shape.boundingBox()).y;
await shape.locator(".segs .opt").nth(2).click();
@@ -326,6 +333,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await t.test("nothing overflows, wide or narrow", async () => {
for (const width of [1100, 560]) {
await page.setViewportSize({ width, height: 760 });
// a frame on: the sidebar's room let go is a transition, if a
// reduced-motion one, that WebKit starts and settles in a frame
await page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))));
const over = await page.evaluate(() => [...document.querySelectorAll("#sessionsPane *")].filter((e) => e.offsetParent && e.getBoundingClientRect().right > document.documentElement.clientWidth + 1).map((e) => e.className));
assert.deepEqual(over, [], "width " + width);
}
+2 -1
View File
@@ -133,7 +133,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
}
// cards of a height: one row, in their order; a narrow window one column
const row = await open("even", { quotas: even(now) }, 1300);
// as wide as 1300 beside the sidebar
const row = await open("even", { quotas: even(now) }, 1512);
let cards = await boxes(row);
assert.deepEqual(cards.map((c) => c.key), ["kimi", "zai", "minimax", "moonshot"]);
assert.ok(cards.every((c) => c.y === cards[0].y), `one row: ${JSON.stringify(cards)}`);