Public: anyone can read this; the crew can change it.

Full suite red: test/palette-tell.test.ts #12673

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

torque/forge:torque/12652-full-suite-red-test-palette-tell-test-ts → main 1 commit fork

  • Merged. torque/12652-full-suite-red-test-palette-tell-test-ts was merged into main as 9f81212.

Review

Sign in to review this change.
1 file changed +8 −6
test/palette-tell.test.ts +8 −6
@@ -29,23 +29,25 @@ if (chromium === undefined)
2929 /** Open the palette, type `text`, and report the rows; with `pick`, choose the tell row. */
3030 const drive = (text: string, pick: boolean): string => `(async () => { try {
3131 const wait = (ms) => new Promise((r) => setTimeout(r, ms));
32 // Poll for the thing itself instead of sleeping a fixed time: the common case is a few ms.
33 const until = async (fn, ms) => { for (let t = 0; t < ms; t += 5) { const v = fn(); if (v) return v; await wait(5); } return fn(); };
3234 const opener = document.querySelector("[data-palette]");
3335 if (!opener) return JSON.stringify({ error: "no palette button on " + location.href + ": " + document.title });
3436 opener.click();
35 await wait(100);
36 const dlg = document.getElementById("palette");
37 const dlg = await until(() => { const d = document.getElementById("palette"); return d && d.open ? d : null; }, 1000) || document.getElementById("palette");
3738 const input = dlg.querySelector(".palette-input");
3839 input.value = ${JSON.stringify(text)};
3940 input.dispatchEvent(new Event("input"));
40 await wait(100);
41 const rows = [...dlg.querySelectorAll(".palette-item")];
41 const rowsNow = () => [...dlg.querySelectorAll(".palette-item")];
42 // A tell row, when there is to be one, is drawn after the first rows: wait for it, briefly.
43 await until(() => { const r = rowsNow(); const l = r[r.length - 1]; return l && l.hasAttribute("data-tell"); }, ${pick} || ${JSON.stringify(text)}.length >= 3 ? 300 : 40);
44 const rows = rowsNow();
4245 const last = rows[rows.length - 1];
4346 const tellRow = last && last.hasAttribute("data-tell") ? last.textContent : null;
4447 let toast = null;
4548 if (${pick} && last) {
4649 last.click();
47 await wait(800);
48 const t = document.querySelector(".toast[data-palette-tell]");
50 const t = await until(() => document.querySelector(".toast[data-palette-tell]"), 3000);
4951 toast = t ? { text: t.querySelector(".toast-body").textContent, link: t.querySelector("a")?.getAttribute("href") ?? null } : null;
5052 }
5153 return JSON.stringify({ tellRow, rows: rows.length, open: dlg.open, toast });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs