Merge branch 'main' into web-lists-shell
This commit is contained in:
+246
-2
@@ -348,6 +348,167 @@ async function showList(destination) {
|
||||
await settle(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* R15: what the Runs heading's bell actually rendered — the glyph's SVG shape,
|
||||
* the badge, and the two rects the absolutely positioned badge must not move.
|
||||
*/
|
||||
async function attentionBellProbe() {
|
||||
return page.evaluate(`(() => {
|
||||
const button = document.querySelector("#attentionBell");
|
||||
const svg = button?.querySelector("svg.attention-bell-icon");
|
||||
const badge = button?.querySelector(".attention-badge");
|
||||
const paths = svg ? [...svg.querySelectorAll("path")] : [];
|
||||
const rect = (el) => {
|
||||
if (!el) return null;
|
||||
const r = el.getBoundingClientRect();
|
||||
const round = (n) => Math.round(n * 100) / 100;
|
||||
return { x: round(r.x), y: round(r.y), width: round(r.width), height: round(r.height) };
|
||||
};
|
||||
return {
|
||||
exists: !!button,
|
||||
visible: !!button && button.getClientRects().length > 0,
|
||||
label: button?.getAttribute("aria-label") ?? null,
|
||||
title: button?.getAttribute("title") ?? null,
|
||||
svg: !!svg,
|
||||
tagName: svg?.tagName ?? null,
|
||||
viewBox: svg?.getAttribute("viewBox") ?? null,
|
||||
pathCount: paths.length,
|
||||
paths: paths.map((path) => ({
|
||||
d: path.getAttribute("d"),
|
||||
fill: path.getAttribute("fill"),
|
||||
stroke: path.getAttribute("stroke"),
|
||||
computedFill: getComputedStyle(path).fill,
|
||||
computedStroke: getComputedStyle(path).stroke,
|
||||
strokeWidth: path.getAttribute("stroke-width"),
|
||||
})),
|
||||
width: svg ? getComputedStyle(svg).width : null,
|
||||
height: svg ? getComputedStyle(svg).height : null,
|
||||
text: button?.textContent ?? null,
|
||||
glyphSpans: document.querySelectorAll(".attention-bell-glyph").length,
|
||||
badge: badge
|
||||
? {
|
||||
text: badge.textContent,
|
||||
dataCount: badge.dataset.count ?? null,
|
||||
position: getComputedStyle(badge).position,
|
||||
}
|
||||
: null,
|
||||
bellRect: rect(button),
|
||||
titleRect: rect(document.getElementById("listTitle")),
|
||||
};
|
||||
})()`);
|
||||
}
|
||||
|
||||
/** R15: the layout delta caused only by hiding the badge, then restoring it. */
|
||||
async function attentionBellBadgeShift() {
|
||||
return page.evaluate(`(() => {
|
||||
const button = document.querySelector("#attentionBell");
|
||||
const badge = button?.querySelector(".attention-badge");
|
||||
const title = document.getElementById("listTitle");
|
||||
const rect = (el) => {
|
||||
const r = el.getBoundingClientRect();
|
||||
const round = (n) => Math.round(n * 100) / 100;
|
||||
return { x: round(r.x), y: round(r.y), width: round(r.width), height: round(r.height) };
|
||||
};
|
||||
if (!badge || !title) return null;
|
||||
const before = { bell: rect(button), title: rect(title) };
|
||||
badge.style.display = "none";
|
||||
const hidden = { bell: rect(button), title: rect(title) };
|
||||
badge.style.display = "";
|
||||
return { before, hidden };
|
||||
})()`);
|
||||
}
|
||||
|
||||
/** The largest edge/corner difference between two measured rects, in px. */
|
||||
function rectDelta(a, b) {
|
||||
return Math.max(
|
||||
Math.abs(a.x - b.x),
|
||||
Math.abs(a.y - b.y),
|
||||
Math.abs(a.width - b.width),
|
||||
Math.abs(a.height - b.height),
|
||||
);
|
||||
}
|
||||
|
||||
const EMOJI = /\p{Extended_Pictographic}/u;
|
||||
|
||||
/** R15: the bell's glyph must be the decorative monochrome SVG, never an emoji. */
|
||||
function assertAttentionBellGlyph(probe, count, where) {
|
||||
if (!probe.exists || !probe.visible) throw new Error(`${where}: the bell is not visible`);
|
||||
if (!probe.svg) throw new Error(`${where}: no svg.attention-bell-icon inside #attentionBell`);
|
||||
if (probe.tagName !== "svg") throw new Error(`${where}: the glyph is a ${probe.tagName}, not an svg`);
|
||||
if (probe.viewBox !== "0 0 24 24") throw new Error(`${where}: viewBox is ${probe.viewBox}`);
|
||||
if (probe.pathCount < 1) throw new Error(`${where}: the glyph has no paths`);
|
||||
if (probe.glyphSpans !== 0) throw new Error(`${where}: the old .attention-bell-glyph span is still there`);
|
||||
for (const path of probe.paths) {
|
||||
if (path.fill !== "none" || path.computedFill !== "none") {
|
||||
throw new Error(`${where}: a glyph path is filled (${path.fill}/${path.computedFill})`);
|
||||
}
|
||||
if (path.stroke !== "currentColor" || path.computedStroke === "none") {
|
||||
throw new Error(`${where}: a glyph path does not stroke currentColor (${path.stroke}/${path.computedStroke})`);
|
||||
}
|
||||
}
|
||||
if (probe.width !== "20px" || probe.height !== "20px") {
|
||||
throw new Error(`${where}: the glyph is ${probe.width}×${probe.height}, not 20×20`);
|
||||
}
|
||||
if (EMOJI.test(probe.text ?? "")) throw new Error(`${where}: the bell still draws an emoji (${JSON.stringify(probe.text)})`);
|
||||
const label = count > 0 ? `Notifications, ${count} needing attention` : "Notifications";
|
||||
if (probe.label !== label) throw new Error(`${where}: the accessible name is "${probe.label}", not "${label}"`);
|
||||
if (probe.title !== label) throw new Error(`${where}: the title is "${probe.title}", not "${label}"`);
|
||||
if (count > 0) {
|
||||
if (!probe.badge) throw new Error(`${where}: no badge at count ${count}`);
|
||||
if (probe.badge.text !== String(count) || probe.badge.dataCount !== String(count)) {
|
||||
throw new Error(`${where}: the badge reads ${JSON.stringify(probe.badge)}, not ${count}`);
|
||||
}
|
||||
if (probe.badge.position !== "absolute") {
|
||||
throw new Error(`${where}: the badge is ${probe.badge.position}, not absolute`);
|
||||
}
|
||||
if ((probe.text ?? "").trim() !== String(count)) {
|
||||
throw new Error(`${where}: the button's text is ${JSON.stringify(probe.text)}, not just the badge count`);
|
||||
}
|
||||
} else {
|
||||
if (probe.badge) throw new Error(`${where}: a badge is still drawn at zero`);
|
||||
if ((probe.text ?? "").trim() !== "") {
|
||||
throw new Error(`${where}: the zero-state button still has text ${JSON.stringify(probe.text)}`);
|
||||
}
|
||||
}
|
||||
if (!probe.bellRect || !probe.titleRect) throw new Error(`${where}: the bell or Runs title has no rect`);
|
||||
}
|
||||
|
||||
/** R15: hiding the absolute badge must not move the Runs title or the button. */
|
||||
function assertAttentionBellBadgeShift(shift, where) {
|
||||
if (!shift) throw new Error(`${where}: no badge to hide`);
|
||||
const bellDelta = rectDelta(shift.before.bell, shift.hidden.bell);
|
||||
const titleDelta = rectDelta(shift.before.title, shift.hidden.title);
|
||||
if (bellDelta > 1 || titleDelta > 1) {
|
||||
throw new Error(`${where}: hiding the badge moved the bell ${bellDelta}px / title ${titleDelta}px`);
|
||||
}
|
||||
return { bellDelta, titleDelta };
|
||||
}
|
||||
|
||||
/** R15: zero-state and post-dismissal glyphs must be the same SVG, not a rebuild. */
|
||||
function assertSameAttentionGlyph(probe, reference, where) {
|
||||
const shape = (p) => p.paths.map((path) => `${path.d}:${path.fill}:${path.stroke}:${path.strokeWidth}`).join("|");
|
||||
if (probe.pathCount !== reference.pathCount || shape(probe) !== shape(reference)) {
|
||||
throw new Error(`${where}: the glyph's paths changed (${probe.pathCount} vs ${reference.pathCount})`);
|
||||
}
|
||||
if (probe.viewBox !== reference.viewBox || probe.width !== reference.width || probe.height !== reference.height) {
|
||||
throw new Error(`${where}: the glyph's box changed`);
|
||||
}
|
||||
}
|
||||
|
||||
/** R15: leave an open run detail through Back to list so the Runs heading is visible. */
|
||||
async function returnToRunsList() {
|
||||
if (await page.evaluate(`!!document.querySelector(".pane-back button")`)) {
|
||||
// Hidden on the wide layout, but the control's own handler is the same one
|
||||
// showList uses; the narrow capture below needs the list pane active.
|
||||
await page.evaluate(`document.querySelector(".pane-back button").click()`);
|
||||
await eventually(() => page.evaluate(`location.pathname === "/runs"`), {
|
||||
what: "the Runs list after Back to list",
|
||||
});
|
||||
}
|
||||
await page.waitForSelector("#listTitle", { timeout: 15000 });
|
||||
await settle(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* An open conversation is a chat detail: one h1 naming the conversation, and the
|
||||
* row activation lands focus on it rather than leaving focus on the removed row.
|
||||
@@ -2445,8 +2606,8 @@ try {
|
||||
console.log(` day headers: ${dayHeaders.slice(0, 3).join(" | ")}`);
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// R15: the attention / "Needs you" surface. The bell lives in the top bar on
|
||||
// every view; its badge, the sheet's rows and the dismissal identities all
|
||||
// R15: the attention / "Needs you" surface. The bell lives in the Runs list
|
||||
// heading; its badge, the sheet's rows and the dismissal identities all
|
||||
// come from the pure src/attention.js model. The live server currently has
|
||||
// failed runs and no run parked in `waiting`, so the sheet is exercised with
|
||||
// real failed entries and that live-data limitation is reported below. The
|
||||
@@ -2480,6 +2641,47 @@ try {
|
||||
console.log(` bell: aria-label="${bell.label}", badge=${bell.count}`);
|
||||
shots.push(await page.screenshot(`${out}/35-attention-bell.png`));
|
||||
|
||||
step("checking the bell's monochrome SVG glyph and the badge's layout isolation");
|
||||
const countProbe = await attentionBellProbe();
|
||||
assertAttentionBellGlyph(countProbe, attentionCount, "wide bell with a count");
|
||||
const wideShift = assertAttentionBellBadgeShift(
|
||||
await attentionBellBadgeShift(),
|
||||
"wide bell with a count",
|
||||
);
|
||||
console.log(
|
||||
` glyph: <${countProbe.tagName} viewBox="${countProbe.viewBox}"> with ${countProbe.pathCount} ` +
|
||||
`unfilled currentColor paths at ${countProbe.width}×${countProbe.height}; ` +
|
||||
`badge "${countProbe.badge.text}" (${countProbe.badge.position})`,
|
||||
);
|
||||
console.log(
|
||||
` no-shift with the badge hidden: bell ${wideShift.bellDelta}px, ` +
|
||||
`Runs title ${wideShift.titleDelta}px`,
|
||||
);
|
||||
|
||||
step("checking the bell at 420x900");
|
||||
await page.resize(420, 900);
|
||||
await eventually(() => page.evaluate(`matchMedia("(min-width: 600px)").matches === false`), {
|
||||
what: "the narrow layout at 420px",
|
||||
});
|
||||
await settle(200);
|
||||
const narrowProbe = await attentionBellProbe();
|
||||
assertAttentionBellGlyph(narrowProbe, attentionCount, "narrow bell with a count");
|
||||
const narrowShift = assertAttentionBellBadgeShift(
|
||||
await attentionBellBadgeShift(),
|
||||
"narrow bell with a count",
|
||||
);
|
||||
shots.push(await page.screenshot(`${out}/35a-attention-bell-narrow-420x900.png`));
|
||||
console.log(
|
||||
` narrow: ${narrowProbe.width}×${narrowProbe.height} glyph, badge ` +
|
||||
`"${narrowProbe.badge.text}" (${narrowProbe.badge.position}); no-shift bell ` +
|
||||
`${narrowShift.bellDelta}px, Runs title ${narrowShift.titleDelta}px`,
|
||||
);
|
||||
await page.resize(1440, 900);
|
||||
await eventually(() => page.evaluate(`matchMedia("(min-width: 600px)").matches === true`), {
|
||||
what: "the wide layout back at 1440px",
|
||||
});
|
||||
await settle(200);
|
||||
|
||||
step("opening the Needs you sheet");
|
||||
await page.click("#attentionBell");
|
||||
await page.waitForSelector(".attention-sheet", { timeout: 15000 });
|
||||
@@ -2555,6 +2757,8 @@ try {
|
||||
const afterDismiss = await page.evaluate(`(() => ({
|
||||
rows: document.querySelectorAll(".attention-sheet .attention-row").length,
|
||||
badge: document.querySelector("#attentionBell .attention-badge")?.dataset.count ?? null,
|
||||
svg: !!document.querySelector("#attentionBell > svg.attention-bell-icon"),
|
||||
pathCount: document.querySelectorAll("#attentionBell > svg.attention-bell-icon path").length,
|
||||
stored: localStorage.getItem("pipelines.web.attention.v1"),
|
||||
}))()`);
|
||||
if (afterDismiss.rows !== attentionCount - 1) {
|
||||
@@ -2563,6 +2767,11 @@ try {
|
||||
if (Number(afterDismiss.badge) !== attentionCount - 1) {
|
||||
throw new Error(`the badge did not follow the dismissal: ${afterDismiss.badge}`);
|
||||
}
|
||||
if (!afterDismiss.svg || afterDismiss.pathCount !== countProbe.pathCount) {
|
||||
throw new Error(
|
||||
`the in-place badge refresh rebuilt the glyph: ${JSON.stringify(afterDismiss)}`,
|
||||
);
|
||||
}
|
||||
if (!String(afterDismiss.stored).includes(`${firstRow.runId}:${kindName(firstRow.kind)}`)) {
|
||||
throw new Error(`the dismissed identity was not persisted: ${afterDismiss.stored}`);
|
||||
}
|
||||
@@ -2668,6 +2877,41 @@ try {
|
||||
}
|
||||
console.log(" Escape closed the sheet and focus returned to #attentionBell");
|
||||
|
||||
step("capturing the zero-state bell at 1440x900 and 420x900");
|
||||
// A Failed row opened a run detail; Back to list makes the Runs heading the
|
||||
// visible evidence (its control is hidden on the wide layout but is the same
|
||||
// handler showList uses, and the narrow capture needs the list pane active).
|
||||
await returnToRunsList();
|
||||
await page.evaluate(`document.activeElement?.blur?.()`);
|
||||
await settle(150);
|
||||
const zeroProbe = await attentionBellProbe();
|
||||
assertAttentionBellGlyph(zeroProbe, 0, "wide bell at zero");
|
||||
assertSameAttentionGlyph(zeroProbe, countProbe, "wide bell at zero");
|
||||
shots.push(await page.screenshot(`${out}/38a-attention-bell-zero-1440x900.png`));
|
||||
console.log(
|
||||
` zero: no badge, aria-label="${zeroProbe.label}", blank text, ` +
|
||||
`${zeroProbe.pathCount} unchanged paths at ${zeroProbe.width}×${zeroProbe.height}`,
|
||||
);
|
||||
|
||||
await page.resize(420, 900);
|
||||
await eventually(() => page.evaluate(`matchMedia("(min-width: 600px)").matches === false`), {
|
||||
what: "the narrow layout at 420px",
|
||||
});
|
||||
await settle(200);
|
||||
const zeroNarrowProbe = await attentionBellProbe();
|
||||
assertAttentionBellGlyph(zeroNarrowProbe, 0, "narrow bell at zero");
|
||||
assertSameAttentionGlyph(zeroNarrowProbe, countProbe, "narrow bell at zero");
|
||||
shots.push(await page.screenshot(`${out}/38b-attention-bell-zero-420x900.png`));
|
||||
console.log(
|
||||
` zero narrow: no badge, aria-label="${zeroNarrowProbe.label}", ` +
|
||||
`${zeroNarrowProbe.width}×${zeroNarrowProbe.height} glyph`,
|
||||
);
|
||||
await page.resize(1440, 900);
|
||||
await eventually(() => page.evaluate(`matchMedia("(min-width: 600px)").matches === true`), {
|
||||
what: "the wide layout back at 1440px",
|
||||
});
|
||||
await settle(200);
|
||||
|
||||
step("closing the sheet with a backdrop click");
|
||||
await page.click("#attentionBell");
|
||||
await page.waitForSelector(".attention-sheet", { timeout: 15000 });
|
||||
|
||||
Reference in New Issue
Block a user