diff --git a/internal/gui/tests/header-centre.test.cjs b/internal/gui/tests/header-centre.test.cjs index cbe358373..cf6dba07c 100644 --- a/internal/gui/tests/header-centre.test.cjs +++ b/internal/gui/tests/header-centre.test.cjs @@ -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, }; }); diff --git a/internal/gui/tests/phone-web.test.cjs b/internal/gui/tests/phone-web.test.cjs index 664b5fb08..92f83b017 100644 --- a/internal/gui/tests/phone-web.test.cjs +++ b/internal/gui/tests/phone-web.test.cjs @@ -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`); diff --git a/internal/gui/tests/purpose-filter.test.cjs b/internal/gui/tests/purpose-filter.test.cjs index 5a414024e..26da2e655 100644 --- a/internal/gui/tests/purpose-filter.test.cjs +++ b/internal/gui/tests/purpose-filter.test.cjs @@ -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"); diff --git a/internal/gui/tests/routing-pause.test.cjs b/internal/gui/tests/routing-pause.test.cjs index e359784b9..8898a3769 100644 --- a/internal/gui/tests/routing-pause.test.cjs +++ b/internal/gui/tests/routing-pause.test.cjs @@ -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); } diff --git a/internal/gui/tests/routing-pointer-pin.test.cjs b/internal/gui/tests/routing-pointer-pin.test.cjs index 1341f3ca8..f67febfee 100644 --- a/internal/gui/tests/routing-pointer-pin.test.cjs +++ b/internal/gui/tests/routing-pointer-pin.test.cjs @@ -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; diff --git a/internal/gui/tests/routing-scroll-end.test.cjs b/internal/gui/tests/routing-scroll-end.test.cjs index 7dd2eca21..7e9d96b33 100644 --- a/internal/gui/tests/routing-scroll-end.test.cjs +++ b/internal/gui/tests/routing-scroll-end.test.cjs @@ -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(); diff --git a/internal/gui/tests/sessions-overview.test.cjs b/internal/gui/tests/sessions-overview.test.cjs index 8112ce085..8aa347d5a 100644 --- a/internal/gui/tests/sessions-overview.test.cjs +++ b/internal/gui/tests/sessions-overview.test.cjs @@ -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); } diff --git a/internal/gui/tests/usage-pack.test.cjs b/internal/gui/tests/usage-pack.test.cjs index 74a4c77cd..adfa80ebe 100644 --- a/internal/gui/tests/usage-pack.test.cjs +++ b/internal/gui/tests/usage-pack.test.cjs @@ -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)}`);