| 630 | } |
| 631 | |
| 632 | async function pathLayout(page) { |
| 633 | return page.evaluate(() => { |
| 634 | const rect = (el) => { const r = el.getBoundingClientRect(); return { left: r.left, right: r.right, top: r.top, bottom: r.bottom, text: el.textContent?.trim() ?? '' }; }; |
| 635 | const labels = [...document.querySelectorAll('.atlas-galaxy-path-label')].map(rect).filter((r) => r.right > r.left); |
| 636 | const names = [...document.querySelectorAll('.atlas-galaxy-path-node b, .atlas-galaxy-root-marker b')].map(rect).filter((r) => r.right > r.left); |
| 637 | const rings = [...document.querySelectorAll('.atlas-galaxy-path-node > i, .atlas-galaxy-root-marker > i')].map(rect); |
| 638 | const hit = (a, b) => !(a.right <= b.left || b.right <= a.left || a.bottom <= b.top || b.bottom <= a.top); |
| 639 | const overlaps = []; |
| 640 | for (const label of labels) for (const name of names) if (hit(label, name)) overlaps.push(`${label.text} x ${name.text}`); |
| 641 | for (let i = 0; i < labels.length; i += 1) for (let j = i + 1; j < labels.length; j += 1) if (hit(labels[i], labels[j])) overlaps.push(`${labels[i].text} x ${labels[j].text}`); |
| 642 | const canvas = document.querySelector('.atlas-galaxy canvas')?.getBoundingClientRect(); |
| 643 | const panel = document.querySelector('[data-testid="atlas-galaxy-path-panel"]')?.getBoundingClientRect(); |
| 644 | const centres = rings.map((r) => ({ x: (r.left + r.right) / 2, y: (r.top + r.bottom) / 2 })); |
| 645 | let spread = 0; |
| 646 | for (let i = 0; i < centres.length; i += 1) for (let j = i + 1; j < centres.length; j += 1) spread = Math.max(spread, Math.hypot(centres[i].x - centres[j].x, centres[i].y - centres[j].y)); |
| 647 | const inside = canvas ? centres.every((c) => c.x > canvas.left && c.x < canvas.right && c.y > canvas.top && c.y < canvas.bottom) : false; |
| 648 | const underPanel = panel ? centres.filter((c) => c.x > panel.left && c.x < panel.right && c.y > panel.top && c.y < panel.bottom).length : 0; |
| 649 | const box = (r) => `${r.text}@${Math.round(r.left)},${Math.round(r.top)},${Math.round(r.right)},${Math.round(r.bottom)}`; |
| 650 | return { labels: labels.length, names: names.map((n) => n.text), overlaps, spreadPx: Math.round(spread), inside, underPanel, |
| 651 | boxes: overlaps.length ? [...labels, ...names].map(box) : undefined, |
| 652 | camera: globalThis.__atlasGalaxyFit?.measure?.().camera.position.map((v) => Math.round(v)) ?? null }; |
| 653 | }); |
| 654 | } |
| 655 | |
| 656 | async function checkK6(page) { |
| 657 | await section(page, 'K6', 'Showing a path flies the camera onto its nodes, and no edge label lies under a node name'); |