Hand every page test a page that has gone quiet, and retry the @ list until it names the project

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-05 19:44:35 -08:00
1 parent 958c0f4ccc
commit a0ac6eb655
2 files changed
+41 -3

No files matched your search

+29
View File
@@ -116,9 +116,38 @@ export async function openSession(browser, { t, workflow, payload: first, projec
s.page.on("pageerror", (e) => s.errors.push(e.message));
await s.page.goto(s.url, { waitUntil: "domcontentloaded" });
await drawn(s.page);
// Redraws that follow the first one (the workspace frame, a scan, the update check) land a
// moment later, and on a busy runner a test that has already scrolled, typed or opened
// something loses it to them. Hand the test a page that has gone quiet. A fake clock freezes
// the page's own timers, so those sessions are left as they are.
if (!clock) await quiet(s.page);
return s;
}
// Waits until the document has not changed for `quietMs`, or `maxMs` at most (a page that never
// goes quiet must not block a test). Counts mutations in the page and polls the count from
// here, so it needs no timer in the page.
export async function quiet(page, { quietMs = 300, maxMs = 4000 } = {}) {
await page
.evaluate(() => {
if (window.__quiet) return;
window.__quiet = { n: 0 };
new MutationObserver(() => window.__quiet.n++).observe(document.body, { subtree: true, childList: true, attributes: true, characterData: true });
})
.catch(() => {});
const end = Date.now() + maxMs;
let last = -1;
let since = Date.now();
while (Date.now() < end) {
const n = await page.evaluate(() => (window.__quiet ? window.__quiet.n : -1)).catch(() => -1);
if (n !== last) {
last = n;
since = Date.now();
} else if (Date.now() - since >= quietMs) return;
await new Promise((r) => setTimeout(r, 50));
}
}
// The page has adopted a state frame: app.js has replaced the boot pane the
// markup ships with.
export async function drawn(page) {
+12 -3
View File
@@ -904,14 +904,23 @@ test("a workflow page uses its modules: the full footer, the session meter, @ su
// The @ list is the workspace frame, which can land after the page draws;
// the footer has one label per width tier once it has.
await s.page.waitForFunction(() => (document.getElementById("footer-where").dataset.key || "").includes("\n"));
// A redraw can replace the box while it is typed in, and the typing is lost with it (seen on
// slow runners): clear the box and type again until the list shows, up to four times.
// A redraw can replace the box while it is typed in: the typing is lost, or the list closes
// with the box it belonged to (both seen on slow runners). Clear the box and type again until
// the list is up and names the project, up to four times, then assert it for real.
const pop = s.page.locator("#mention-pop");
const listed = async () => {
try {
await pop.waitFor({ timeout: 3000 });
return new RegExp(name).test(await pop.innerText({ timeout: 1500 }));
} catch {
return false;
}
};
for (let attempt = 0; attempt < 4; attempt++) {
const ed = itemCard(s.page, "q1").locator(".md-host .cm-content").first();
await ed.click();
await ed.pressSequentially("See @");
if (await pop.waitFor({ timeout: 3000 }).then(() => true, () => false)) break;
if (await listed()) break;
await fillBox(itemCard(s.page, "q1").locator(".md-host"), "");
}
await pop.waitFor();