gui tests: reach wheels the page over a point no inner box takes, and the routing editor is pressed once its motion has stopped (#3408, #3409)
Three Routing GUI files were red on main, bisected on mote fromb0b076421: - routing-model-rest, 20 of 20 red sinceca9b5048e(#3764). Its steps box now scrolls in 200px, and reader.cjs's reach sent every wheel at the view's centre, which sat on that box: the box scrolled, the view never moved, and reach gave up ("control did not come clear into sight", target y=1048 in a view of 826). Sinced74ef5e04an inner box at its end keeps the wheel too, so the pointer over any overflowing list stalls reach for good. wheeled now moves the pointer, before each wheel, to a point of the view with no box of its own that scrolls under it (d74ef5e04did this by hand for routing-scroll-end alone). - routing-intent-entry (#3408) and routing-manual (#3409), red since91b0be836: a group opening into its editor moves its height and parts for ~700ms, and the tests measured where to wheel and press while it moved. reader.cjs has a settled(page) now: two frames, then no running finite animation; both files wait on it before they measure. routing-pause and routing-rule-effort had the same cause (7b007e986). Run on mote (Playwright 1.62, Chromium and WebKit), one file at a time: - at the pushed head (rebased ondfb73a04e): routing-model-rest, routing-intent-entry, routing-manual, routing-scroll-end, inner-scroll-contain, click-scroll: 116/116. - old code: routing-model-rest 20/20 red at f25871cdd; intent-entry and manual red in the bisect from91b0be836on. - broken by hand: the first settled waited on the animations only, with no two frames first; routing-manual stayed red in WebKit ("element is not stable", then outside the viewport): WebKit lists an animation a click started a frame later. - every GUI file that uses reach or wheelTo (89 files, before the rebase and before settled): 1580/1615. The 35 reds are in six files, and the same six are red on untouchedf25871cddrun one at a time (118/150 there): mobile-web (#3952, it needs a .git that mote-run's copy hasn't, commented there), usage-ledger (#3104), routing-manual (#3409, fixed here), routing-rule-remove (#3094, #3096), routing-rules-line (#3593), segs-press-redraw (#3922). rule-remove and rules-line don't load reader.cjs. - a run of the three files under load ~94 had two browsers not launch in 180s; routing-model-rest alone again: 20/20. Not run: the whole GUI suite at the pushed head.
This commit is contained in:
@@ -87,9 +87,25 @@ async function viewOf(page, locator) {
|
||||
}
|
||||
|
||||
// wheeled sends one wheel over the view and waits for its scroll to land;
|
||||
// false when the view didn't move in a second (it is at its end).
|
||||
// false when the view didn't move in a second (it is at its end). The
|
||||
// wheel is sent over a point of the view with no box of its own that
|
||||
// scrolls under it: one under the pointer takes the wheel first, as
|
||||
// Routing's steps did once they scrolled in 200px (ca9b5048e), and the
|
||||
// view never moved.
|
||||
async function wheeled(page, id, dy) {
|
||||
const was = await page.locator("#" + id).evaluate((v) => v.scrollTop);
|
||||
const { was, x, y } = await page.locator("#" + id).evaluate((v) => {
|
||||
const r = v.getBoundingClientRect();
|
||||
const scrolls = (e) => e.scrollHeight > e.clientHeight && /auto|scroll/.test(getComputedStyle(e).overflowY);
|
||||
for (let fy = 0.5; fy < 1; fy += 0.1) for (const fx of [0.5, 0.15, 0.85, 0.02]) for (const s of [1, -1]) {
|
||||
const x = r.left + r.width * fx, y = r.top + r.height * (s > 0 ? fy : 1 - fy);
|
||||
let e = document.elementFromPoint(x, y);
|
||||
if (!e || !v.contains(e)) continue;
|
||||
while (e !== v && !scrolls(e)) e = e.parentElement;
|
||||
if (e === v) return { was: v.scrollTop, x, y };
|
||||
}
|
||||
return { was: v.scrollTop, x: r.left + r.width / 2, y: r.top + r.height / 2 };
|
||||
});
|
||||
await page.mouse.move(x, y);
|
||||
await page.mouse.wheel(0, dy);
|
||||
return page.waitForFunction(([id, was]) => document.getElementById(id).scrollTop !== was, [id, was], { timeout: 1000 }).then(() => true, () => false);
|
||||
}
|
||||
@@ -176,4 +192,14 @@ async function openAgentSettings(page, id = "codex") {
|
||||
await page.waitForFunction(() => __settingsReads.asked > 0 && __settingsReads.asked === __settingsReads.drawn);
|
||||
}
|
||||
|
||||
module.exports = { inView, reach, wheelTo, click, openPart, watchSettingsReads, settingsDrawn, agentRow, openAgentSettings };
|
||||
// settled waits for the page's motion to end: a routing group opening
|
||||
// into its editor moves its height and parts for ~700ms (91b0be836), and
|
||||
// where a control will be is read once that has stopped. Two frames pass
|
||||
// first: WebKit lists an animation a click started only a frame later, so
|
||||
// a look right after the click found none and went on.
|
||||
async function settled(page) {
|
||||
await page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))));
|
||||
await page.waitForFunction(() => !document.getAnimations().some((a) => a.playState === "running" && Number.isFinite(a.effect?.getComputedTiming().endTime)));
|
||||
}
|
||||
|
||||
module.exports = { settled, inView, reach, wheelTo, click, openPart, watchSettingsReads, settingsDrawn, agentRow, openAgentSettings };
|
||||
|
||||
@@ -13,6 +13,7 @@ const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
const { settled } = require("./reader.cjs");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const models = [
|
||||
@@ -64,6 +65,8 @@ function serve(lang, posts) {
|
||||
// wheel down to a control, as the reader would (the page keeps still for
|
||||
// any other scroll), then click it with the mouse
|
||||
async function press(page, loc, height) {
|
||||
// where loc will be is read once the editor has stopped moving
|
||||
await settled(page);
|
||||
await page.mouse.move(Math.min(550, (page.viewportSize().width / 2) | 0), 300);
|
||||
for (let i = 0; i < 12 && (await loc.boundingBox()).y > height - 160; i++) {
|
||||
await page.mouse.wheel(0, 300);
|
||||
@@ -102,6 +105,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await ed.locator(".rt-classifier").isVisible(), false);
|
||||
|
||||
// a rule, its intent box focused, Jev picked; nothing scrolled
|
||||
await settled(page);
|
||||
await page.mouse.move(Math.min(550, width / 2), 300);
|
||||
for (let i = 0; i < 12 && (await byIntent.boundingBox()).y > height - 160; i++) {
|
||||
await page.mouse.wheel(0, 300);
|
||||
|
||||
@@ -11,6 +11,7 @@ const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
const { settled } = require("./reader.cjs");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const models = [
|
||||
@@ -129,6 +130,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
// the reader wheels the editor's routing into the middle (code that
|
||||
// scrolls is put back: only the reader moves the view)
|
||||
const wheelTo = async (x) => {
|
||||
// the distance is read once the editor has stopped moving
|
||||
await settled(page);
|
||||
const d = await x.evaluate((e) => { const v = document.querySelector("#view-routing");
|
||||
return Math.round(e.getBoundingClientRect().top - v.getBoundingClientRect().top - v.clientHeight / 2); });
|
||||
await page.mouse.move(550, 400);
|
||||
|
||||
Reference in New Issue
Block a user