Add text size buttons to the console's top bar (v3.2.1)

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-29 20:48:03 -08:00
1 parent 8277c8b548
commit 634e4df10e
25 files changed
+188 -40

No files matched your search

+53
View File
@@ -85,6 +85,59 @@ test("the violet highlight and dark theme chosen in preferences stick across a r
assert.deepEqual(await firstPaintAttrs(s), { theme: null, accent: null }, "the first paint still carries the old looks");
});
// The top bar's text size buttons: seven steps, saved with the looks, in the first paint.
const bodySize = (s) => s.page.evaluate(() => getComputedStyle(document.body).fontSize);
const sizeLabel = (s) => s.page.locator("#btn-text-size").innerText();
const savedTextSize = (s) => s.page.evaluate(async () => ((await (await fetch("/looks")).json()).looks || {}).textSize);
test("the text size buttons step the console's type up and down between the megaphone and the die, stop at the ends, and the label returns to 100%", async (t) => {
noSavedLooks(t);
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
const order = await s.page.evaluate(() => [...document.getElementById("btn-feedback").parentElement.children].map((n) => n.id));
assert.deepEqual(order.slice(order.indexOf("btn-feedback"), order.indexOf("btn-feedback") + 3), ["btn-feedback", "text-size", "btn-activities"], "the control sits between the megaphone and the die");
assert.equal(await sizeLabel(s), "100%");
assert.equal(await root(s, "data-text-size"), null, "the default size leaves the page unmarked");
assert.equal(await bodySize(s), "15px");
await s.page.click("#btn-text-larger");
assert.equal(await sizeLabel(s), "110%");
assert.equal(await root(s, "data-text-size"), "110");
assert.equal(await s.page.locator("#btn-text-size").getAttribute("aria-label"), "Text size 110%, back to 100%", "a screen reader hears the size");
assert.equal(await bodySize(s), "16.5px");
await s.page.waitForFunction(async () => ((await (await fetch("/looks")).json()).looks || {}).textSize === 110);
// The first paint carries it, and so does a reload.
const html = await (await s.context.request.get(s.url)).text();
assert.match(html.match(/<html\b[^>]*>/i)?.[0] ?? `no html tag in: ${html.slice(0, 200)}`, /data-text-size="110"/, "the first paint carries the saved size");
await s.page.reload({ waitUntil: "domcontentloaded" });
await drawn(s.page);
assert.equal(await sizeLabel(s), "110%");
assert.equal(await bodySize(s), "16.5px");
// The label puts it back.
await s.page.click("#btn-text-size");
assert.equal(await sizeLabel(s), "100%");
assert.equal(await root(s, "data-text-size"), null);
assert.equal(await bodySize(s), "15px");
// Largest and smallest: the button at the end is spent, not wrapped.
for (let i = 0; i < 6; i++) if (await s.page.locator("#btn-text-larger").isEnabled()) await s.page.click("#btn-text-larger");
assert.equal(await sizeLabel(s), "150%");
assert.equal(await s.page.locator("#btn-text-larger").getAttribute("aria-disabled"), "true");
await s.page.click("#btn-text-size");
for (let i = 0; i < 6; i++) if ((await s.page.locator("#btn-text-smaller").getAttribute("aria-disabled")) !== "true") await s.page.click("#btn-text-smaller");
assert.equal(await sizeLabel(s), "80%");
assert.equal(await bodySize(s), "12px");
await s.page.waitForFunction(async () => ((await (await fetch("/looks")).json()).looks || {}).textSize === 80);
// Back to default in Preferences returns it too.
await s.page.click("#btn-looks");
await s.page.click("#looks-reset");
await s.page.waitForFunction(() => !document.documentElement.hasAttribute("data-text-size"));
assert.equal(await sizeLabel(s), "100%");
assert.equal(await savedTextSize(s) ?? 100, 100);
});
// The Agents & models tab: a roster of agent cards, the picked agent's form in
// a drawer over it (Models & strengths and Launch tabs), and the Add agent
// chooser, where the starter templates are an opt-in.