gui: the narrow editor's labels are over their fields, and Add is reached (#890)
group-from-model-add.test.cjs failed 2/2 at 600x420 on both engines, and had for a while: it asked that every label sit beside its field, but under 760px the editor is one column on purpose (routing.css), so the label is above its field there. It now asks for that where the editor is one column, and keeps asking for beside where it is two. The other half was the click: the error Add answers with comes in at the foot of the page, and in the one column editor it covers Add until the view is scrolled to its end. The test wheels down until the button is under the pointer, which is not yet the end of the page, and then clicked the place it had found before the error arrived. It now scrolls to the end of the page first, and finds the button again before each press. Both engines, both languages, both viewports: 8/8 pass (was 6/8), and the routing and group regressions are 34/34 on each engine (were 41 pass / 2 fail on Chromium and 40 pass / 3 fail on WebKit). Co-authored-by: wizzy-yang <wizzy-yang@users.noreply.github.com>
This commit is contained in:
@@ -85,21 +85,51 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.waitForTimeout(80);
|
||||
}
|
||||
assert.ok(at, "the wheel reaches Add, and nothing covers it");
|
||||
const clickAdd = () => page.mouse.click(at.x, at.y);
|
||||
// Add is clicked where it is, and what is under it is checked: the
|
||||
// error it answers with comes in at the foot of the page and, in a
|
||||
// one column editor (under 760px), covers Add itself until the view
|
||||
// is scrolled to its end. The reader wheels down to the end of the
|
||||
// page here, so that the press lands whatever the error does.
|
||||
const clickAdd = async () => {
|
||||
for (let i = 0; i < 80; i++) {
|
||||
const done = await page.evaluate(() => {
|
||||
const v = document.querySelector("#view-routing");
|
||||
return v.scrollTop + v.clientHeight >= v.scrollHeight - 1;
|
||||
});
|
||||
if (done) break;
|
||||
await page.mouse.wheel(0, 120);
|
||||
await page.waitForTimeout(60);
|
||||
}
|
||||
let now = await seen();
|
||||
for (let i = 0; i < 80 && !now; i++) {
|
||||
await page.mouse.wheel(0, -120);
|
||||
await page.waitForTimeout(60);
|
||||
now = await seen();
|
||||
}
|
||||
assert.ok(now, "Add is under the pointer's reach to be clicked");
|
||||
await page.mouse.click(now.x, now.y);
|
||||
};
|
||||
return { page, ed, errors, clickAdd };
|
||||
};
|
||||
|
||||
// Add posts the group of its one model
|
||||
let posts = [];
|
||||
let { page, ed, errors, clickAdd } = await open(posts, false);
|
||||
// every label beside its own field: a hidden classifier left its
|
||||
// cell behind, and Levels' label sat at the right, its choices below
|
||||
const rows = await ed.evaluate((e) => [...e.children].filter((c) => c.matches("label") && !c.hidden && c.offsetParent).map((l) => {
|
||||
// every label beside its own field, or over it where the editor is one
|
||||
// column: a hidden classifier left its cell behind, and Levels' label
|
||||
// sat at the right, its choices below. Under 760px the editor is one
|
||||
// column on purpose (routing.css), so the label is above its field
|
||||
// there — beside is only what a wide window can ask for.
|
||||
const oneColumn = width <= 760;
|
||||
const rows = await ed.evaluate((e, oneColumn) => [...e.children].filter((c) => c.matches("label") && !c.hidden && c.offsetParent).map((l) => {
|
||||
const f = l.nextElementSibling, a = l.getBoundingClientRect(), b = f.getBoundingClientRect();
|
||||
return { label: l.textContent, beside: a.right <= b.left + 1 && Math.abs(a.top - b.top) < 12 };
|
||||
}));
|
||||
const beside = a.right <= b.left + 1 && Math.abs(a.top - b.top) < 12;
|
||||
const above = a.bottom <= b.top + 1 && a.left <= b.left + 1;
|
||||
return { label: l.textContent, beside, above };
|
||||
}), oneColumn);
|
||||
assert.ok(rows.length >= 6, JSON.stringify(rows));
|
||||
assert.deepEqual(rows.filter((r) => !r.beside), [], "each label beside its field");
|
||||
assert.deepEqual(rows.filter((r) => !(oneColumn ? r.above : r.beside)), [],
|
||||
oneColumn ? "each label over its field, the editor in one column" : "each label beside its field");
|
||||
await clickAdd();
|
||||
for (let i = 0; i < 40 && !posts.some((p) => p.path === "/api/groups/save"); i++) await page.waitForTimeout(50);
|
||||
const saved = posts.find((p) => p.path === "/api/groups/save")?.body;
|
||||
|
||||
Reference in New Issue
Block a user