운영 안정화와 화면 회귀 검증을 반영
Some checks failed
API contract / OpenAPI type drift (push) Failing after 6m2s

This commit is contained in:
Yun Chan 2026-10-20 16:33:48 +09:00
parent 6e3123091a
commit aeddaa6972
69 changed files with 3178 additions and 424 deletions

View file

@ -210,7 +210,11 @@ function scanLayoutDefects(): Finding[] {
const viewportWidth = doc.clientWidth;
const findings: Finding[] = [];
const all = Array.from(document.querySelectorAll<HTMLElement>("body *"));
type ScannedElement = HTMLElement | SVGSVGElement;
const isScannedElement = (el: Element): el is ScannedElement =>
el instanceof HTMLElement || (el instanceof SVGSVGElement && el.ownerSVGElement === null);
const all = Array.from(document.querySelectorAll("body *")).filter(isScannedElement);
const scanned = new Set<Element>(all);
const styles = new Map<Element, CSSStyleDeclaration>();
const rects = new Map<Element, DOMRect>();
// body 도 overflow 경계가 될 수 있으므로 캐시에 포함한다(순회 대상은 아니다).
@ -221,6 +225,20 @@ function scanLayoutDefects(): Finding[] {
const cs = (el: Element) => styles.get(el) ?? window.getComputedStyle(el);
const rc = (el: Element) => rects.get(el) ?? el.getBoundingClientRect();
const scopedParents = new Map<ScannedElement, Element | null>();
const scopedChildren = new Map<Element, ScannedElement[]>();
for (const el of all) {
let parent = el.parentElement;
while (parent && parent !== document.body && !scanned.has(parent)) parent = parent.parentElement;
const scopedParent = parent ?? null;
scopedParents.set(el, scopedParent);
if (scopedParent) {
const children = scopedChildren.get(scopedParent) ?? [];
children.push(el);
scopedChildren.set(scopedParent, children);
}
}
function classOf(el: Element) {
const raw = (el as HTMLElement).className as unknown;
const source =
@ -250,7 +268,10 @@ function scanLayoutDefects(): Finding[] {
else if (rect.width <= 0 && rect.height <= 0) result = false;
else if (el.getAttribute("aria-hidden") === "true") result = false;
else if (el.hasAttribute("hidden") || el.hasAttribute("inert")) result = false;
else if (el.parentElement && el.parentElement !== document.body && !isVisible(el.parentElement)) result = false;
else {
const parent = el instanceof HTMLElement || el instanceof SVGSVGElement ? scopedParents.get(el) : null;
if (parent && parent !== document.body && !isVisible(parent)) result = false;
}
visibleCache.set(el, result);
return result;
}
@ -333,7 +354,7 @@ function scanLayoutDefects(): Finding[] {
// 최근접 overflow 경계(또는 containing-block 을 바꾸는 absolute/fixed 조상).
const nearestBoundary = new Map<Element, Element | null>();
for (const el of all) {
const parent = el.parentElement;
const parent = scopedParents.get(el);
if (!parent || !styles.has(parent)) {
nearestBoundary.set(el, null);
continue;
@ -445,11 +466,11 @@ function scanLayoutDefects(): Finding[] {
사용자가 스크롤로 도달할 수 있으므로 정상으로 본다. */
const interactiveSelector = "button,a[href],input,select,textarea,[role='button'],[role='tab']";
function hasHorizontalScrollAncestor(el: Element) {
let node: Element | null = el.parentElement;
let node: Element | null = el instanceof HTMLElement || el instanceof SVGSVGElement ? scopedParents.get(el) ?? null : null;
while (node && node !== document.body) {
const style = cs(node);
if (scrollsX(style) && node.scrollWidth - node.clientWidth > 1) return true;
node = node.parentElement;
node = node instanceof HTMLElement || node instanceof SVGSVGElement ? scopedParents.get(node) ?? null : null;
}
return false;
}
@ -481,11 +502,11 @@ function scanLayoutDefects(): Finding[] {
pointer-events:none, aria-hidden, float/transform,
grid-template-areas 를 쓰는 부모(의도적 겹침 레이아웃)는 제외. */
const parents = new Set<Element>();
for (const el of all) if (el.parentElement) parents.add(el.parentElement);
for (const parent of scopedParents.values()) if (parent) parents.add(parent);
for (const parent of parents) {
const parentStyle = parent === document.body ? window.getComputedStyle(parent) : cs(parent);
if (parentStyle.gridTemplateAreas && parentStyle.gridTemplateAreas !== "none") continue;
const siblings = Array.from(parent.children).filter((el) => {
const siblings = (scopedChildren.get(parent) ?? []).filter((el) => {
if (!styles.has(el) || !isVisible(el)) return false;
const style = cs(el);
if (style.position !== "static" && style.position !== "relative") return false;
@ -702,6 +723,33 @@ test.describe("브레이크포인트 경계 스윕 @single-run", () => {
}
});
test("SVG 내부 레이어는 제외하고 외부 SVG와 HTML 레이아웃 결함은 잡는다", async ({ page }) => {
await page.setContent(`
<style>
.svg-clip { width: 100px; height: 40px; overflow: hidden; }
.html-overlap { width: 160px; height: 100px; }
.html-overlap > div { position: relative; width: 120px; height: 60px; }
.html-overlap > div + div { margin-top: -30px; }
</style>
<svg width="120" height="80" aria-label="internal-svg">
<g><rect x="10" y="10" width="70" height="50"></rect><rect x="40" y="20" width="70" height="50"></rect></g>
</svg>
<div class="svg-clip"><svg width="180" height="30" aria-label="outer-svg"></svg></div>
<div class="html-overlap"><div>first</div><div>second</div></div>
`);
const findings = await page.evaluate(scanLayoutDefects);
expect(findings.filter((finding) => finding.kind === "overlap" && finding.element.includes("rect"))).toEqual([]);
expect(
findings.some((finding) => finding.kind === "clip-x" && finding.element.includes("svg-clip")),
`외부 SVG의 HTML clip 경계를 못 잡았다: ${JSON.stringify(findings)}`,
).toBe(true);
expect(
findings.some((finding) => finding.kind === "overlap" && finding.element.includes("html-overlap")),
`실제 HTML 형제 겹침을 못 잡았다: ${JSON.stringify(findings)}`,
).toBe(true);
});
/**
* 검출기 자기검증.
*