Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Suites wait for what they check, not for a while
Yashwanth Kamireddic49f5c365a3e
diff --git a/.uiverify/notes-keys.mjs b/.uiverify/notes-keys.mjsindex 315e161..513b766 100644--- a/.uiverify/notes-keys.mjs+++ b/.uiverify/notes-keys.mjs@@ -20,9 +20,11 @@ async function open(setup = () => {}) {page.on("pageerror", (e) => ok(false, "", `page error: ${e.message}`));await page.goto(BASE, { waitUntil: "networkidle" });await page.locator(".nav-item", { hasText: "Notes" }).click();- await page.waitForTimeout(500);+ await page.locator(".note-row").first().waitFor();return { ctx, page };}+/** Until `fn` holds in the page (polled each frame), or 8 s; the check after it says what is there. */+const until = (page, fn, arg) => page.waitForFunction(fn, arg, { timeout: 8000, polling: "raf" }).then(() => true, () => false);const current = (page) => page.evaluate(() => document.querySelector('.note-row[aria-selected="true"] .note-row-name')?.textContent ?? null);const focusIn = (page, sel) => page.evaluate((s) => Boolean(document.activeElement?.closest(s)), sel);@@ -30,15 +32,15 @@ const focusIn = (page, sel) => page.evaluate((s) => Boolean(document.activeElemeconst { ctx, page } = await open();// The list as shown: the pinned note, then Curtains, then the last.await page.locator(".note-row", { hasText: "Curtains" }).click();- await page.waitForTimeout(200);+ await until(page, () => document.querySelector('.note-row[aria-selected="true"] .note-row-name')?.textContent?.includes("Curtains"));await page.keyboard.press("ArrowDown");- await page.waitForTimeout(250);+ await until(page, () => !document.querySelector('.note-row[aria-selected="true"] .note-row-name')?.textContent?.includes("Curtains"));const down = await current(page);ok(down?.startsWith("These sources"), "↓ moves to the next note", `↓ landed on ${down}`);ok(await focusIn(page, ".note-rows"), "and the list keeps the focus", "focus left the list");await page.keyboard.press("ArrowUp");await page.keyboard.press("ArrowUp");- await page.waitForTimeout(250);+ await until(page, () => !!document.querySelector('.note-row[aria-selected="true"] .note-row-name')?.textContent?.includes("UNIT 1"));const up = await current(page);ok(up?.includes("UNIT 1"), "↑ moves back up, pinned notes first", `↑↑ landed on ${up}`);await page.keyboard.press("ArrowUp");@@ -47,46 +49,46 @@ const focusIn = (page, sel) => page.evaluate((s) => Boolean(document.activeEleme// Ctrl+F in a folder: that folder's search; Esc back to the list.await page.locator(".notes-folder", { hasText: /^Notes/ }).click();- await page.waitForTimeout(300);+ await until(page, () => [...document.querySelectorAll(".note-row")].some((r) => r.textContent.includes("Curtains")));await page.locator(".note-row", { hasText: "Curtains" }).click();- await page.waitForTimeout(200);+ await until(page, () => document.querySelector('.note-row[aria-selected="true"] .note-row-name')?.textContent?.includes("Curtains"));await page.keyboard.press("Control+f");ok(await focusIn(page, ".notes-search"), "Ctrl+F goes to the search field", "Ctrl+F went nowhere");ok(await page.getByLabel("Search notes").getAttribute("placeholder") === "Search Notes", "and searches this folder",`placeholder ${await page.getByLabel("Search notes").getAttribute("placeholder")}`);await page.keyboard.type("curt");- await page.waitForTimeout(400);+ await until(page, () => document.querySelector('.notes-scope .segment[aria-pressed="true"]')?.textContent === "Notes" && document.querySelectorAll(".note-row").length === 1);ok(await page.locator('.notes-scope .segment[aria-pressed="true"]').textContent() === "Notes","the scope shows the folder", "scope not shown");ok(await page.locator(".note-row").count() === 1, "results are the folder's matches", `${await page.locator(".note-row").count()} rows`);await page.keyboard.press("Escape");- await page.waitForTimeout(300);+ await until(page, () => document.querySelector('[aria-label="Search notes"]')?.value === "" && !!document.activeElement?.closest(".note-rows"));ok(await page.getByLabel("Search notes").inputValue() === "" && await focusIn(page, ".note-rows"),"Esc clears the search and returns to the list", "Esc left the search as it was");await page.keyboard.press("Control+Shift+F");await page.keyboard.type("curt");- await page.waitForTimeout(400);+ await until(page, () => document.querySelector('.notes-scope .segment[aria-pressed="true"]')?.textContent === "All iCloud");ok(await page.locator('.notes-scope .segment[aria-pressed="true"]').textContent() === "All iCloud","Ctrl+Shift+F searches every folder", "Ctrl+Shift+F kept the folder scope");await page.keyboard.press("Escape");- await page.waitForTimeout(200);+ await until(page, () => document.querySelector('[aria-label="Search notes"]')?.value === "");// Ctrl+Backspace asks first; No keeps the note.await page.locator(".note-row", { hasText: "Curtains" }).click();- await page.waitForTimeout(200);+ await until(page, () => document.querySelector('.note-row[aria-selected="true"] .note-row-name')?.textContent?.includes("Curtains"));await page.keyboard.press("Control+Backspace");- await page.waitForTimeout(300);+ await until(page, () => !!document.querySelector(".confirm h2"));const asked = await page.locator(".confirm h2").textContent().catch(() => null);ok(asked === "Delete “Curtains”?", "Ctrl+Backspace asks before deleting", `asked ${asked}`);await page.keyboard.press("Escape");- await page.waitForTimeout(300);+ await until(page, () => !document.querySelector(".confirm"));ok(await page.evaluate(() => (window.__noteDeletes ?? []).length) === 0 && await page.locator(".note-row", { hasText: "Curtains" }).count() === 1,"and keeping it keeps it", "the note went anyway");await page.locator(".note-row", { hasText: "Curtains" }).click();await page.keyboard.press("Control+Backspace");- await page.waitForTimeout(300);+ await until(page, () => !!document.querySelector(".confirm .confirm-answer"));await page.locator(".confirm .confirm-answer").click();- await page.waitForTimeout(400);+ await until(page, () => (window.__noteDeletes ?? []).length > 0);ok(JSON.stringify(await page.evaluate(() => window.__noteDeletes)) === '["n1"]', "Delete deletes it", "nothing was deleted");// No paperclip while the backend's switch is off.@@ -100,18 +102,27 @@ const focusIn = (page, sel) => page.evaluate((s) => Boolean(document.activeEleme// Ctrl+N from anywhere: a new note, cursor in it.await page.locator(".note-row", { hasText: "Curtains" }).click();await page.keyboard.press("Control+n");- await page.waitForTimeout(400);+ await until(page, () => !!document.activeElement?.closest(".note-rich"));ok(await focusIn(page, ".note-rich"), "Ctrl+N starts a new note with the cursor in it", "Ctrl+N did nothing");await page.keyboard.type("Plan\nbuy milk");await page.keyboard.press("Control+Shift+L");- await page.waitForTimeout(100);+ await until(page, () => !!document.querySelector('.note-rich .nf-p[data-style="103"]')?.textContent?.includes("buy milk"));ok(await page.locator('.note-rich .nf-p[data-style="103"]', { hasText: "buy milk" }).count() === 1,"Ctrl+Shift+L makes the line a checklist item", "no checklist");+ // The line chosen whole before it is marked — and the editor told of it: Shift+Home is the+ // browser's, and the editor takes the new selection from its selectionchange, a moment on.+ // A key before that marks the caret, not the line.+ await page.evaluate(() => { window.__selChanged = false; document.addEventListener("selectionchange", () => { window.__selChanged = true; }, { once: true }); });await page.keyboard.press("Shift+Home");+ await until(page, () => String(getSelection()) === "buy milk" && window.__selChanged);+ await page.evaluate(() => new Promise((r) => requestAnimationFrame(() => r())));await page.keyboard.press("Control+b");await page.keyboard.press("Control+i");await page.keyboard.press("Control+u");- await page.waitForTimeout(100);+ await until(page, () => {+ const p = [...document.querySelectorAll(".note-rich .nf-p")].find((x) => x.textContent === "buy milk");+ return ["strong", "em", "u"].every((t) => p?.querySelector(t)?.textContent === "buy milk");+ });const marks = await page.evaluate(() => {const p = [...document.querySelectorAll(".note-rich .nf-p")].find((x) => x.textContent === "buy milk");return ["strong", "em", "u"].filter((t) => p?.querySelector(t)?.textContent === "buy milk");@@ -129,13 +140,13 @@ const focusIn = (page, sel) => page.evaluate((s) => Boolean(document.activeEleme// The backend's switch on: the paperclip appears, and adds at the cursor.const { ctx, page } = await open(() => { window.__attachOn = true; window.__pick = "/home/test/Pictures/beach.jpg"; });await page.locator(".note-row", { hasText: "Curtains" }).click();- await page.waitForTimeout(400);+ await until(page, () => !!document.querySelector('[aria-label="Add a picture or file"]'));const clip = page.getByRole("button", { name: "Add a picture or file" });ok(await clip.count() === 1, "with the switch on, the paperclip shows", "no paperclip with the switch on");await page.locator(".note-rich .nf-p", { hasText: "Fan" }).click();await page.keyboard.press("End");await clip.click();- await page.waitForTimeout(600);+ await until(page, () => (window.__attaches ?? []).length > 0);const sent = await page.evaluate(() => window.__attaches ?? []);const base = sent[0]?.base ?? "";ok(sent.length === 1 && sent[0].guid === "n1" && sent[0].path === "/home/test/Pictures/beach.jpg"diff --git a/.uiverify/photos-shortcuts.mjs b/.uiverify/photos-shortcuts.mjsindex 73644f7..82d6e49 100644--- a/.uiverify/photos-shortcuts.mjs+++ b/.uiverify/photos-shortcuts.mjs@@ -34,15 +34,20 @@ await page.addInitScript(() => addEventListener("DOMContentLoaded", () =>await page.goto(BASE, { waitUntil: "networkidle" });await openScreen(page, "Photos");await page.locator(".px-tile").first().waitFor();-await page.waitForTimeout(400);let failures = 0;+/** Until `fn` (run in the page, given `arg`) holds, or 8 s: the checks after it then say what is there. */+const until = async (fn, arg) => {+ for (const end = Date.now() + 8000; Date.now() < end; ) if (await page.evaluate(fn, arg)) return true;+ return false;+};+await until(() => document.querySelector('.px-tile[data-index="0"] img')?.complete);const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };const shown = () => page.evaluate(() => document.querySelector(".px-viewer")?.getAttribute("aria-label") ?? null);const box = (s) => page.locator(s).first().evaluate((e) => { const r = e.getBoundingClientRect(); return { x: r.x, y: r.y, w: r.width, h: r.height, r: r.right, b: r.bottom }; });// ---- the viewer ----await page.locator('.px-tile[data-index="0"]').dblclick();-await page.waitForTimeout(400);+await until(() => document.querySelector(".px-viewer")?.getAttribute("aria-label") === "IMG_0.JPG");ok((await shown()) === "IMG_0.JPG", "a double-click opens the photo");ok((await page.evaluate(() => document.getAnimations().filter((a) => a.playState === "running").length)) === 0,"and it is open at once — nothing animates");@@ -51,10 +56,10 @@ ok((await shown()) === "IMG_1.JPG", "→ goes to the next photo");// Space on a Live Photo plays its moving part.await page.keyboard.press(" ");-await page.waitForTimeout(100);+await until(() => document.querySelectorAll(".px-live").length === 1);ok((await page.locator(".px-live").count()) === 1 && (await shown()) === "IMG_1.JPG", "Space plays a Live Photo's moving part");await page.keyboard.press(" ");-await page.waitForTimeout(100);+await until(() => document.querySelectorAll(".px-live").length === 0);ok((await page.locator(".px-live").count()) === 0, "and Space again stops it");await page.keyboard.press("ArrowRight");@@ -63,33 +68,46 @@ await page.keyboard.press("ArrowRight");ok((await shown()) === "IMG_2.JPG", "← and → step either way");await page.keyboard.press("f");-await page.waitForTimeout(150);+await until(() => window.__flags?.at(-1)?.flag === "favorite" && !!document.querySelector('.px-viewer-bar [aria-label="Unfavorite"]'));ok((await page.evaluate(() => window.__flags?.at(-1))).flag === "favorite" &&(await page.locator('.px-viewer-bar [aria-label="Unfavorite"]').count()) === 1, "F favorites it, and the heart fills at once");// I: Info beside the photo, never over it, and never over the next arrow.await page.keyboard.press("i");-await page.waitForTimeout(200);+// Info open, and the photo moved aside for it (its box settled over two frames).+await until(async () => {+ const info = document.querySelector(".px-info"), pic = document.querySelector(".px-shown");+ if (!info || !pic) return false;+ const a = pic.getBoundingClientRect().right;+ await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));+ return pic.getBoundingClientRect().right === a;+});ok((await page.locator(".px-info").count()) === 1, "I shows Info");const info = await box(".px-info"), pic = await box(".px-shown"), next = await box(".px-nav.is-next");ok(pic.r <= info.x && next.r <= info.x, `the photo and its next arrow make room for Info (photo ends ${Math.round(pic.r)}, arrow ${Math.round(next.r)}, Info starts ${Math.round(info.x)})`);await page.keyboard.press("i");-await page.waitForTimeout(100);+await until(() => !document.querySelector(".px-info"));ok((await page.locator(".px-info").count()) === 0, "and I again hides it");// Ctrl+Backspace: asked first, then gone, and the viewer goes on to the next photo.await page.keyboard.press("Control+Backspace");-await page.waitForTimeout(300);+await until(() => window.__flags?.at(-1)?.flag === "deleted" && document.querySelector(".px-viewer")?.getAttribute("aria-label") === "IMG_3.JPG");ok((await page.evaluate(() => window.__asked?.at(-1))) === "Delete this photo?" &&(await page.evaluate(() => window.__flags?.at(-1))).flag === "deleted", "Ctrl+Backspace deletes it, asked first");ok((await shown()) === "IMG_3.JPG", "and the viewer goes on to the next");// Through to a photo further on, then Escape: that photo is the one chosen, in view, focused.for (let i = 0; i < 40; i++) await page.keyboard.press("ArrowRight");-await page.waitForTimeout(200);+// Settled on a photo: the same one shown over a few frames.+await until(async () => {+ const at = () => document.querySelector(".px-viewer")?.getAttribute("aria-label");+ const a = at();+ for (let i = 0; i < 6; i++) await new Promise((r) => requestAnimationFrame(r));+ return a === at();+});const far = await shown();await page.keyboard.press("Escape");-await page.waitForTimeout(400);+await until(() => !document.querySelector(".px-viewer") && document.activeElement?.matches('.px-tile[aria-selected="true"]'));ok((await page.locator(".px-viewer").count()) === 0, "Escape closes it");const back = await page.evaluate((name) => {const t = document.querySelector('.px-tile[aria-selected="true"]');@@ -101,53 +119,73 @@ ok(back.name && back.focused && back.inView, `the photo last shown (${far}) is c// Space on a still takes it back to the library, as Photos.await page.keyboard.press(" ");-await page.waitForTimeout(300);+await until((far) => document.querySelector(".px-viewer")?.getAttribute("aria-label") === far, far);ok((await shown()) === far, "Space opens the chosen photo");await page.keyboard.press(" ");-await page.waitForTimeout(300);+await until(() => !document.querySelector(".px-viewer"));ok((await page.locator(".px-viewer").count()) === 0, "and Space on a still closes it again");// ---- the library ----+/** The grid fewer across than `n` (or as many, `same`), the chosen photo drawn in it and still over a few frames. */+const zoomedTo = (n, same = false) => until(async ([n, same]) => {+ const across = () => { const g = document.querySelector(".px-grid"); return g ? getComputedStyle(g).gridTemplateColumns.split(" ").length : 0; };+ const want = () => (same ? across() === n : across() > 0 && across() < n);+ const top = () => document.querySelector('.px-tile[aria-selected="true"]')?.getBoundingClientRect().top;+ if (!want()) return false;+ const a = top();+ for (let i = 0; i < 4; i++) await new Promise((r) => requestAnimationFrame(r));+ return a !== undefined && a === top() && want();+}, [n, same]);const across = () => page.locator(".px-grid").first().evaluate((g) => getComputedStyle(g).gridTemplateColumns.split(" ").length);const where = () => page.evaluate(() => {const t = document.querySelector('.px-tile[aria-selected="true"]');- return Math.round(t.getBoundingClientRect().top - document.querySelector(".px-scroll").getBoundingClientRect().top);+ return t ? Math.round(t.getBoundingClientRect().top - document.querySelector(".px-scroll").getBoundingClientRect().top) : NaN;});const was = await where(), n0 = await across();await page.keyboard.press("Control+=");-await page.waitForTimeout(400);+await zoomedTo(n0);const n1 = await across(), now = await where();ok(n1 < n0, `Ctrl + makes the photos bigger (${n0} → ${n1} across)`);ok(Math.abs(now - was) < 40, `and the chosen photo stays where it was on the screen (${was} → ${now}px)`);const titles = await page.locator(".px-month-title").allInnerTexts();ok(titles.length > 0 && titles.every((t) => !/^\w+ \d{4}$/.test(t)) && /day/.test(titles[0]), `five across, the library is grouped by day (${titles.slice(0, 2).join(" | ")})`);await page.keyboard.press("Control+-");-await page.waitForTimeout(400);+await zoomedTo(n0, true);ok((await across()) === n0 && /^\w+ \d{4}$/.test((await page.locator(".px-month-title").first().innerText())), "Ctrl − back, by month again");// The month picker still lists months, once each, by day as well as by month.await page.keyboard.press("Control+=");-await page.waitForTimeout(300);+await zoomedTo(n0);await page.getByRole("button", { name: "Go to a Month" }).click();-await page.waitForTimeout(300);+await until(() => document.querySelectorAll(".px-jump-month span").length >= 3);const listed = await page.locator(".px-jump-month span").allInnerTexts();ok(listed.length >= 3 && new Set(listed).size === listed.length, `by day, the month picker lists each month once (${listed.join(", ")})`);await page.keyboard.press("Escape");await page.keyboard.press("Control+-");-await page.waitForTimeout(300);+await zoomedTo(n0, true);// A sweep from the space beside the first month's heading down over two rows.await page.locator(".px-scroll").evaluate((e) => (e.scrollTop = 0));-await page.waitForTimeout(300);+await until(async () => {+ const at = () => document.querySelector('.px-tile[data-index="9"]')?.getBoundingClientRect().top;+ const a = at();+ for (let i = 0; i < 4; i++) await new Promise((r) => requestAnimationFrame(r));+ return a !== undefined && a === at() && document.querySelector(".px-scroll").scrollTop === 0;+});const title = await box(".px-month-title");const t9 = await box('.px-tile[data-index="9"]');await page.mouse.move(title.r - 8, title.y + 6);await page.mouse.down();await page.mouse.move(t9.x + t9.w / 2, t9.y + t9.h / 2, { steps: 6 });-await page.waitForTimeout(150);+await until(() => document.querySelector(".px-sweep")?.hidden === false);const during = await page.locator(".px-sweep").evaluate((e) => !e.hidden);await page.mouse.up();-await page.waitForTimeout(150);+await until(async () => {+ const chosen = () => document.querySelectorAll('.px-tile[aria-selected="true"]').length;+ const n = chosen();+ for (let i = 0; i < 4; i++) await new Promise((r) => requestAnimationFrame(r));+ return document.querySelector(".px-sweep")?.hidden === true && n > 0 && n === chosen();+});const picked = await page.locator('.px-tile[aria-selected="true"]').evaluateAll((ts) => ts.map((t) => +t.dataset.index).sort((a, b) => a - b));// From the last column down to the middle of photo 9 (second row): those columns of both rows.const n = await across();diff --git a/.uiverify/screens-return.mjs b/.uiverify/screens-return.mjsindex a11fe6e..1fa8b01 100644--- a/.uiverify/screens-return.mjs+++ b/.uiverify/screens-return.mjs@@ -41,7 +41,11 @@ const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failuconst playing = (sel) => page.evaluate((s) => [...document.querySelectorAll(s)].flatMap((e) => e.getAnimations({ subtree: true })).filter((a) => a.playState === "running").length, sel);await openScreen(page, "Contacts");-await page.waitForTimeout(800);+// Every face drawn: as many pictures loaded as there are faces.+await page.waitForFunction(() => {+ const f = [...document.querySelectorAll(".face-photo")];+ return f.length > 0 && f.every((i) => !(i instanceof HTMLImageElement) || (i.complete && i.naturalWidth > 0));+}, null, { timeout: 8000 }).catch(() => {});const faces = await page.locator(".face-photo").count();ok(faces > 0, `contacts show their pictures (${faces})`);ok((await playing(".face-photo")) === 0, "drawn without a fade");@@ -54,15 +58,19 @@ ok((await playing(".face-photo")) === 0, "back to Contacts: no face fades in aga// frame — lib/fade — so it is measured as the fill's opacity rising, not as an animation).await openScreen(page, "Reminders");await page.locator(".rx-list", { hasText: "Daily" }).click();-await page.waitForTimeout(400);await page.evaluate(() => { window.__doneDelay = 4000; });const tick = page.locator(".rx-row", { has: page.getByLabel("Rename Pick up the parcel") }).locator(".rx-tick");+await tick.waitFor();+// This row's own fill, each frame from the press until it is whole (or two seconds): another+// row ticked before stays whole throughout and is not this one.const rising = page.evaluate(() => new Promise((done) => {const seen = [];+ const t0 = performance.now();const sample = () => {- const fill = document.querySelector(".rx-row.is-settling .rx-tick-fill, .rx-tick[aria-checked='true'] .rx-tick-fill");+ const row = [...document.querySelectorAll(".rx-row")].find((r) => r.querySelector('[aria-label="Rename Pick up the parcel"]'));+ const fill = row?.querySelector(".rx-tick-fill");if (fill) seen.push(Number(getComputedStyle(fill).opacity));- if (seen.length < 12) requestAnimationFrame(sample); else done(seen);+ if (performance.now() - t0 < 2000 && !(seen.some((o) => o < 0.5) && seen.at(-1) >= 0.9)) requestAnimationFrame(sample); else done(seen);};requestAnimationFrame(sample);}));@@ -70,7 +78,7 @@ await tick.click();const seen = await rising;// Faded in: from faint to (nearly) whole over a few frames, never whole at once.const low = seen.findIndex((o) => o < 0.5);-ok(low >= 0 && seen.slice(low).some((o) => o >= 0.9), `a tick pressed fades in [${seen.map((o) => o.toFixed(2)).join(" ")}]`);+ok(low >= 0 && seen.slice(low).some((o) => o > 0 && o < 0.9) && seen.slice(low).some((o) => o >= 0.9), `a tick pressed fades in [${seen.map((o) => o.toFixed(2)).join(" ")}]`);await page.waitForTimeout(400);await openScreen(page, "Notes");await page.waitForTimeout(200);diff --git a/.uiverify/search-keys.mjs b/.uiverify/search-keys.mjsindex c71d016..bc80ce1 100644--- a/.uiverify/search-keys.mjs+++ b/.uiverify/search-keys.mjs@@ -11,6 +11,8 @@ import { SERVICES, installStub } from "./stub.mjs";const BASE = process.env.BASE ?? "http://localhost:4173";const b = await engine.launch();let failures = 0;+/** Until `fn` holds in the page (polled each frame), or 8 s; the check after it says what is there. */+const until = (page, fn, arg) => page.waitForFunction(fn, arg, { timeout: 8000, polling: "raf" }).then(() => true, () => false);const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };for (const scheme of ["light", "dark"]) {const ctx = await b.newContext({ viewport: { width: 1280, height: 800 }, colorScheme: scheme });@@ -35,7 +37,8 @@ for (const scheme of ["light", "dark"]) {// The keys move the selection, and it stays in view.await page.keyboard.type("marlowe");- await page.waitForTimeout(250);+ await until(page, () => document.querySelectorAll('[role="listbox"][aria-label="Found"] [role="option"]').length >= 5+ && /Marlowe/.test(document.querySelector('[role="listbox"][aria-label="Found"] [aria-selected="true"]')?.textContent ?? ""));ok((await options.count()) >= 5, `${scheme}: results at once`);ok(/Marlowe/.test(await selected()), `${scheme}: the first is selected`);ok((await panel.locator('[aria-selected="true"] mark').first().innerText()).toLowerCase() === "marlowe", `${scheme}: the typed word is marked`);@@ -49,7 +52,7 @@ for (const scheme of ["light", "dark"]) {// Escape: Show All first, then the results, then the field.await panel.getByRole("option", { name: /^Show all 600 in Contacts/ }).click();- await page.waitForTimeout(200);+ await until(page, () => document.querySelectorAll('[role="listbox"][aria-label="Found"] [role="option"]').length > 10);const drawnRows = await options.count();ok(drawnRows > 10 && drawnRows < 80, `${scheme}: 600 found, only those in view drawn (${drawnRows} rows)`);await page.keyboard.press("Escape");@@ -61,7 +64,7 @@ for (const scheme of ["light", "dark"]) {// An answer overtaken is never drawn; what was found stays while the next comes.await field.fill("curtains");- await page.waitForTimeout(200);+ await until(page, () => /Curtains/.test(document.querySelector('[role="listbox"][aria-label="Found"]')?.textContent ?? ""));ok(/Curtains/.test(await panel.innerText()), `${scheme}: Curtains found`);await page.evaluate(() => { window.__searchDelay = (q) => (q === "zoya" ? 0 : q === "zoy" ? 250 : q.startsWith("z") ? 700 : 0); });await page.keyboard.press("Control+a");@@ -70,9 +73,11 @@ for (const scheme of ["light", "dark"]) {ok(/Curtains/.test(await panel.innerText()) && (await options.count()) > 0, `${scheme}: while the next answer comes, the last stays on screen`);await page.keyboard.type("y");await page.keyboard.type("a");- await page.waitForTimeout(150);+ await until(page, () => /Zoya/.test(document.querySelector('[role="listbox"][aria-label="Found"]')?.textContent ?? ""));ok(/Zoya/.test(await panel.innerText()), `${scheme}: the newest answer is drawn`);- await page.waitForTimeout(800);+ // Every older answer landed (the stub counts those on their way), and two frames drawn after.+ await until(page, () => window.__searchesOut === 0);+ await page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))));const after = await panel.innerText();ok(/Zoya/.test(after) && !/Curtains/.test(after), `${scheme}: answers to older questions arriving after it are dropped`);const seqs = await page.evaluate(() => window.__searches.slice(-3).map((s) => s.seq));@@ -81,14 +86,13 @@ for (const scheme of ["light", "dark"]) {// Return opens the selected one in its own app.await page.keyboard.press("Enter");- await page.waitForTimeout(300);+ await until(page, () => !(document.querySelector('[role="listbox"][aria-label="Found"]')?.getClientRects().length) && /Contacts/.test(document.querySelector('.nav-item[aria-current="true"]')?.textContent ?? ""));ok(!(await panel.isVisible()) && (await page.locator('.nav-item[aria-current="true"]').innerText()).includes("Contacts"), `${scheme}: Return opens it in Contacts`);// 600 in one section: read a page at a time to the very end, scrolled without a long frame.await field.fill("marlowe");- await page.waitForTimeout(250);await panel.getByRole("option", { name: /^Show all 600 in Contacts/ }).click();- await page.waitForTimeout(150);+ await until(page, () => document.querySelectorAll('#gsearch-results [role="option"]').length > 10);const run = await page.evaluate(async () => {const list = document.querySelector("#gsearch-results");const out = [];diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjsindex c474ab3..12a4e50 100644--- a/.uiverify/stub.mjs+++ b/.uiverify/stub.mjs@@ -535,7 +535,16 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note(window.__pins ??= []).push([args?.guid, args?.pinned]);return null;}- case "note_create": return "Note/new";+ case "note_create": {+ // Kept, as the library keeps a note made here (it is listed from then on): left out,+ // the next read of the list lost it, and the screen went back to the note before.+ const body = args?.body ?? "";+ const title = body.split("\n").find((l) => l.trim()) ?? "";+ if (!noteList.some((x) => x.guid === "Note/new"))+ noteList.unshift({ guid: "Note/new", folderGuid: args?.folderGuid ?? "f1", title, snippet: "", body,+ locked: false, editable: true, pinned: false, createdAt: null, modifiedAt: Math.floor(Date.now() / 1000), etag: null });+ return "Note/new";+ }case "notes_in":// A suite's own notes (`window.__notesExtra`), their formatting in `__savedRuns`.for (const n of window.__notesExtra ?? []) if (!noteList.some((x) => x.guid === n.guid)) noteList.unshift({ ...n });@@ -1038,7 +1047,10 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note(window.__searches ??= []).push({ query: args.query, seq: args.seq, only: args.only ?? null, skip });const delay = typeof window.__searchDelay === "function" ? window.__searchDelay(args.query) : window.__searchDelay ?? 0;const answer = { seq: args.seq ?? 0, groups };- return delay ? new Promise((r) => setTimeout(() => r(answer), delay)) : answer;+ // Answers still on their way, so a suite can wait for the last of them to land.+ if (!delay) return answer;+ window.__searchesOut = (window.__searchesOut ?? 0) + 1;+ return new Promise((r) => setTimeout(() => { window.__searchesOut--; r(answer); }, delay));}case "drive_kept": return window.__driveFolder?.on ? [...(window.__kept ??= [])] : null;case "drive_keep":