// Roster alignment, measured in the page. Called as (phase, phone) and // returns the failures as text ("" when aligned). Phases: "compact" (a // report whose decision card follows it) and "full" (that card set aside). // The Chromium and WebKit tests both evaluate this file. (phase, phone) => { const bad = [], q = (s, r = document) => r.querySelector(s), all = (s, r = document) => [...r.querySelectorAll(s)]; const box = e => e.getBoundingClientRect(), near = (a, b, t = 1) => Math.abs(a - b) <= t; const report = q("[equipo-roster-report]"), flat = report.closest("[equipo-roster-card]"); const inner = e => { const b = box(e), s = getComputedStyle(e); return { left: b.left + parseFloat(s.paddingLeft), right: b.right - parseFloat(s.paddingRight) }; }; const fs = getComputedStyle(flat); if (parseFloat(fs.borderTopWidth) || parseFloat(fs.borderLeftWidth) || fs.backgroundColor !== "rgba(0, 0, 0, 0)" || fs.boxShadow !== "none") bad.push("a report is still a card"); if (parseFloat(getComputedStyle(flat, "::before").width) > 2) bad.push("the report rail is not a hairline"); const gaps = all("[equipo-roster-byline]").map(b => box(b.nextElementSibling).top - Math.max(box(b).bottom, box(q("[equipo-roster-avatar]", b)).bottom)); if (gaps.some(g => !near(g, 8))) bad.push("byline to content gap is not 8px: " + gaps.map(Math.round)); const ask = q("[equipo-roster-card][data-ask]"); if (ask && phone) { const mark = q("[equipo-roster-avatar]", ask.previousElementSibling), edge = box(mark.matches("[equipo-coordinator-mark]") ? q("svg", mark) : mark).left; if (!near(edge, box(ask).left)) bad.push(`byline mark at ${edge}, card at ${box(ask).left}`); } const pads = all("[equipo-roster-card][data-ask]").map(c => getComputedStyle(c)).map(s => [s.paddingTop, s.paddingRight, s.paddingBottom, s.paddingLeft].join(" ")); if (new Set(pads).size > 1 || pads.some(p => new Set(p.split(" ")).size > 1)) bad.push("raised cards use uneven padding: " + pads.join(" | ")); const pill = q("[data-question-thread] [equipo-mini-pill]"), main = q("#composer [equipo-pill]"); if (pill) { const p = box(pill), s = box(q("button", pill)), x = q("[equipo-set-aside] button", pill.closest("[equipo-roster-card]")); if (!near((s.top + s.bottom) / 2, (p.top + p.bottom) / 2)) bad.push(`send sits ${(s.top + s.bottom - p.top - p.bottom) / 2}px off the pill's centre`); if (!near(p.bottom - s.bottom, p.right - s.right)) bad.push("send is not inset evenly in the pill"); if (main && !near(p.height, box(main).height)) bad.push(`card pill is ${p.height}px, the composer's ${box(main).height}px`); const range = document.createRange(); range.selectNodeContents(q("[data-first] [equipo-thread-text]", pill.closest("[equipo-roster-card]"))); const line = range.getClientRects()[0], xb = box(x); if (!near((xb.top + xb.bottom) / 2, (line.top + line.bottom) / 2, 2)) bad.push(`set aside is ${(xb.top + xb.bottom - line.top - line.bottom) / 2}px off the first line`); } if (phase === "compact") { if (!report.hasAttribute("data-compact") || q("[data-track], [equipo-roster-facts], [equipo-roster-links] [rst-btn='primary']", report)) bad.push("a report beside its decision is not compact"); if (all("[equipo-needs-chip]", flat.closest("[data-card]").parentElement).length !== 1) bad.push("Needs you is not said exactly once"); } else { const track = q("[data-track]", report), dots = all("[equipo-dot]", track), content = inner(report); if (!near(box(dots[0]).left, content.left) || !near(box(dots.at(-1)).right, content.right)) bad.push(`track ${box(dots[0]).left}..${box(dots.at(-1)).right} does not span ${content.left}..${content.right}`); const steps = dots.slice(1).map((d, i) => box(d).left - box(dots[i]).left); if (steps.some(s => !near(s, steps[0]))) bad.push("track dots are uneven: " + steps.map(Math.round)); const now = q("[aria-current]", track), i = [...track.children].indexOf(now); if (i > 0 && i < dots.length - 1) { const range = document.createRange(); range.selectNodeContents(now.querySelector("span:not([equipo-dot])")); const l = box(range), d = box(dots[i]); if (!near((l.left + l.right) / 2, (d.left + d.right) / 2)) bad.push(`stage label is ${(l.left + l.right - d.left - d.right) / 2}px off its dot`); } const head = q("[equipo-roster-report-head]", report), stage = q("[equipo-roster-stage]", head), chip = q("[equipo-needs-chip]", head); if (box(stage).height > 1.6 * parseFloat(getComputedStyle(stage).fontSize)) bad.push("the eyebrow wraps"); if (chip && !near((box(stage).top + box(stage).bottom) / 2, (box(chip).top + box(chip).bottom) / 2, 2)) bad.push("eyebrow and chip are not on one line"); const links = all("[equipo-roster-links] > a", report), mids = links.map(a => Math.round((box(a).top + box(a).bottom) / 2)); if (!phone && new Set(mids).size > 1) bad.push("report actions are not one row"); } const scroll = q("[equipo-scroll]"); scroll.scrollTop = scroll.scrollHeight; const last = all("[equipo-feed] > li").filter(e => box(e).height > 0).at(-1), clear = box(q("#chat-composer")).top - box(last).bottom; if (clear < 16) bad.push(`the last item ends ${clear}px above the composer`); return bad.join("; "); }