Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
gui tests: reach reads the control it wheels to in one call, so a row drawn again between two looks isn't taken for in sight (#2658)
yetoneb8ed806e33b6
diff --git a/internal/gui/tests/reader.cjs b/internal/gui/tests/reader.cjsindex e66db3a14..055dff9ae 100644--- a/internal/gui/tests/reader.cjs+++ b/internal/gui/tests/reader.cjs@@ -41,18 +41,27 @@ async function inView(page, locator) {// was on a control out of sight (#2370).async function reach(page, locator) {await locator.waitFor({ state: "visible" });- const id = await locator.evaluate((e) => e.closest(".view")?.id || "");+ const id = await viewOf(page, locator);if (!id) return;const v = await page.locator("#" + id).boundingBox();await page.mouse.move(v.x + v.width / 2, v.y + v.height / 2);let stalls = 0;for (let i = 0; i < 120; i++) {- const at = await locator.evaluate((e) => {- const b = e.getBoundingClientRect(), v = e.closest(".view").getBoundingClientRect();+ // found and read in one call (evaluateAll): locator.evaluate finds the+ // control in one call and reads it in the next, and a part the page+ // draws again in between (Routing's account rows, a row whose numbers+ // moved) hands it the element just replaced, out of the page, a box of+ // zeros at the window's top that reads as in sight (#2658)+ const at = await locator.evaluateAll((es) => {+ const e = es.length === 1 ? es[0] : null, view = e?.closest(".view");+ if (!view) return null;+ const b = e.getBoundingClientRect(), v = view.getBoundingClientRect();const x = b.left + b.width / 2, y = b.top + b.height / 2;const inside = b.top >= v.top && b.bottom <= v.bottom, hit = document.elementFromPoint(x, y);return { clear: inside && !!hit && (e === hit || e.contains(hit)), down: y > v.top + v.height / 2 };});+ // drawn again between two looks, or not drawn yet: look again+ if (!at) { await page.waitForTimeout(40); continue; }if (at.clear) { await page.waitForTimeout(300); return; }// landed, or the view is at its end and the wheel moves nothing: three// of those in turn and the control can't be brought clear@@ -62,6 +71,18 @@ async function reach(page, locator) {throw new Error("control did not come clear into sight: " + JSON.stringify({ view: v, target: await locator.boundingBox() }));}+// viewOf: the id of the view the control is in ("" for none), read once+// it is in the page: an element just drawn again over is out of it, and in+// no view (#2658)+async function viewOf(page, locator) {+ for (let i = 0; i < 50; i++) {+ const id = await locator.evaluateAll((es) => es.length === 1 ? es[0].closest(".view")?.id || "" : null);+ if (id != null) return id;+ await page.waitForTimeout(40);+ }+ throw new Error("control not in the 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).async function wheeled(page, id, dy) {@@ -76,11 +97,13 @@ async function wheeled(page, id, dy) {// control is looked at again (#2370).async function wheelTo(page, locator, y) {await locator.waitFor({ state: "visible" });- const id = await locator.evaluate((e) => e.closest(".view")?.id || "");+ const id = await viewOf(page, locator);const v = await page.locator("#" + id).boundingBox();await page.mouse.move(v.x + v.width / 2, v.y + v.height / 2);for (let i = 0; i < 80; i++) {- if ((await locator.evaluate((e) => e.getBoundingClientRect().top)) <= y) break;+ const top = await locator.evaluateAll((es) => es.length === 1 && es[0].closest(".view") ? es[0].getBoundingClientRect().top : null);+ if (top == null) { await page.waitForTimeout(40); continue; }+ if (top <= y) break;if (!(await wheeled(page, id, 50))) break;}await reach(page, locator);diff --git a/internal/gui/tests/routing-model-rest.test.cjs b/internal/gui/tests/routing-model-rest.test.cjsindex 8237f1a39..64f60ea0d 100644--- a/internal/gui/tests/routing-model-rest.test.cjs+++ b/internal/gui/tests/routing-model-rest.test.cjs@@ -14,6 +14,8 @@ const fs = require("node:fs/promises");const path = require("node:path");const { test } = require("node:test");const { chromium, webkit } = require("playwright");+// a reader wheels down to it, and it is the button under the pointer+const { reach } = require("./reader.cjs");const assets = path.resolve(__dirname, "../assets");const now = new Date();@@ -78,21 +80,6 @@ const posted = async (lifted) => {for (let i = 0; i < 60 && !lifted.length; i++) await new Promise((r) => setTimeout(r, 50));return lifted;};-// a reader wheels down to it, over what scrolls it, and it is the-// button under the pointer-async function reach(page, btn) {- const at = await btn.evaluate((e) => {- let p = e.parentElement;- while (p && !(p.scrollHeight > p.clientHeight + 1 && /auto|scroll/.test(getComputedStyle(p).overflowY))) p = p.parentElement;- const l = (p || document.documentElement).getBoundingClientRect();- const top = Math.max(l.top, 0), bottom = Math.min(l.bottom, innerHeight);- return { x: l.left + Math.min(l.width / 2, 100), y: (top + bottom) / 2 };- });- await page.mouse.move(at.x, at.y);- for (let i = 0; i < 30 && !(await btn.evaluate((e) => e.getBoundingClientRect().bottom < innerHeight - 80)); i++) await page.mouse.wheel(0, 200);- await page.waitForTimeout(200);- assert(await btn.evaluate((e) => { const r = e.getBoundingClientRect(); return e.contains(document.elementFromPoint(r.x + r.width / 2, r.y + r.height / 2)); }), "the button can't be reached");-}const sideways = (page) => page.evaluate(() => document.documentElement.scrollWidth > window.innerWidth + 1);for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {diff --git a/internal/gui/tests/routing-wb-restricted.test.cjs b/internal/gui/tests/routing-wb-restricted.test.cjsindex 9f7d22a91..3390dfcc1 100644--- a/internal/gui/tests/routing-wb-restricted.test.cjs+++ b/internal/gui/tests/routing-wb-restricted.test.cjs@@ -10,6 +10,7 @@ const fs = require("node:fs/promises");const path = require("node:path");const { test } = require("node:test");const { chromium, webkit } = require("playwright");+const { reach } = require("./reader.cjs");const assets = path.resolve(__dirname, "../assets");const now = new Date();@@ -115,10 +116,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",// scrolled to where a reader sees it, it is the button under the// pointer, not the footer// a reader scrolls down to it with the wheel- await page.mouse.move(200, 400);- for (let i = 0; i < 20 && !(await go.evaluate((e) => e.getBoundingClientRect().bottom < innerHeight - 80)); i++) await page.mouse.wheel(0, 200);- await page.waitForTimeout(200);- assert(await go.evaluate((e) => { const r = e.getBoundingClientRect(); return e.contains(document.elementFromPoint(r.x + r.width / 2, r.y + r.height / 2)); }), "the button can't be reached");+ await reach(page, go);await go.click();await page.waitForTimeout(300);assert.deepEqual(lifted, [{ key: rest.key }]);