gui tests: searcher-pick waits for the reloaded Settings to be drawn (#1745)
After the reload, the test took the first searcher row it found and
scrolled to it. Settings draws the row when the page opens and again
when load() has the state, so on a busy machine the row was replaced
under scrollIntoViewIfNeeded: "Element is not attached to the DOM"
(webkit zh alone on WSL at 01de489de, webkit en in a whole run).
Now the test waits for settingsDrawn, as it does on first open (#1659).
The fake server can hold the state and settings reads (st.slowRead, 400ms
here), so the page's first drawing and load()'s are apart every run, and
the test checks the row it scrolled to is the one that stays.
Run:
- Broken by hand (settingsDrawn after the reload removed), with the
injected read delay, on WSL: 2 of 4 red with the reported error,
"locator.scrollIntoViewIfNeeded: Element is not attached to the DOM"
(chromium en, webkit zh).
- Fixed, on mote: node --test searcher-pick.test.cjs, both engines,
22 pass, 0 fail.
- Fixed, on WSL: the picked-in-Settings cases in WebKit, 2 of 2 ok.
Not tried: the whole GUI suite (test-only change to one file).
This commit is contained in:
@@ -85,6 +85,8 @@ function serve(lang, posted, st) {
|
||||
const json = (data, status = 200) => r.fulfill({ status, json: data });
|
||||
if (url.pathname === "/boot.js") return r.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = ${JSON.stringify({ lang, theme: st.theme || "light", web: true })};` });
|
||||
if (url.pathname === "/wails/runtime.js") return r.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
// reads slower than the first drawing of the page, as on a busy machine
|
||||
if (st.slowRead && (url.pathname === "/api/state" || url.pathname === "/api/settings") && r.request().method() === "GET") await new Promise((ok) => setTimeout(ok, st.slowRead));
|
||||
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: settings() });
|
||||
if (url.pathname === "/api/settings") {
|
||||
if (r.request().method() === "POST") {
|
||||
@@ -317,9 +319,17 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(posted.at(-1).searcher, "off");
|
||||
await page.evaluate(() => savePrefs({ ...prefsKeep(prefs), noStats: true }));
|
||||
assert.equal(posted.at(-1).searcher, "off");
|
||||
// The row is drawn when the page opens and again when the state and
|
||||
// the settings come; the one scrolled to is the one that stays (#1745).
|
||||
st.slowRead = 400;
|
||||
await page.reload();
|
||||
await settingsDrawn(page);
|
||||
await row.waitFor();
|
||||
await row.scrollIntoViewIfNeeded();
|
||||
await row.evaluate((r) => { r.dataset.scrolled = "1"; });
|
||||
await settingsDrawn(page);
|
||||
assert.equal(await page.evaluate(() => document.querySelector("#searchList .row.searcher-row")?.dataset.scrolled), "1", "the row scrolled to was drawn again after it");
|
||||
st.slowRead = 0;
|
||||
assert.equal(await row.locator("button.searcher-pick").innerText(), w.off);
|
||||
assert.equal(await row.locator(".searcher-own, .searcher-unused, .searcher-relays, .searcher-left-out").count(), 0);
|
||||
assert.equal(await page.locator("#searchFirstRow").count(), 0);
|
||||
|
||||
Reference in New Issue
Block a user