|
| 1 | +import { chromium } from "playwright"; |
| 2 | + |
| 3 | +const port = process.argv[2] || "3380"; |
| 4 | +const outDir = process.argv[3] || "docs"; |
| 5 | + |
| 6 | +console.log(`Connecting to http://localhost:${port}...`); |
| 7 | +const browser = await chromium.launch({ headless: true }); |
| 8 | +const page = await browser.newPage({ viewport: { width: 1440, height: 900 } }); |
| 9 | + |
| 10 | +await page.goto(`http://localhost:${port}`, { waitUntil: "networkidle" }); |
| 11 | + |
| 12 | +// Wait for 3D graph to render (force-graph needs time to stabilize) |
| 13 | +console.log("Waiting for graph to render..."); |
| 14 | +await page.waitForTimeout(8000); |
| 15 | + |
| 16 | +// Check for console errors |
| 17 | +page.on("console", (msg) => { |
| 18 | + if (msg.type() === "error") console.error(`[BROWSER] ${msg.text()}`); |
| 19 | +}); |
| 20 | + |
| 21 | +// Debug: check what's visible on page |
| 22 | +const legendVisible = await page.locator(".fixed.bottom-4.left-4").isVisible().catch(() => false); |
| 23 | +console.log(`Legend visible: ${legendVisible}`); |
| 24 | + |
| 25 | +const legendHTML = await page.locator(".fixed.bottom-4.left-4").innerHTML().catch(() => "NOT FOUND"); |
| 26 | +console.log(`Legend content length: ${legendHTML.length}`); |
| 27 | +const hasGroups = legendHTML.includes("Groups"); |
| 28 | +console.log(`Legend has Groups section: ${hasGroups}`); |
| 29 | + |
| 30 | +// Check if clouds are rendered (data attribute on container) |
| 31 | +const cloudCount = await page.locator("[data-cloud-count]").getAttribute("data-cloud-count").catch(() => "N/A"); |
| 32 | +console.log(`Cloud count: ${cloudCount}`); |
| 33 | + |
| 34 | +// Take the main galaxy view screenshot |
| 35 | +await page.screenshot({ |
| 36 | + path: `${outDir}/screenshot-galaxy.png`, |
| 37 | + fullPage: false, |
| 38 | +}); |
| 39 | +console.log("Galaxy view captured"); |
| 40 | + |
| 41 | +// Switch to Module view |
| 42 | +await page.click('button:has-text("Module")'); |
| 43 | +await page.waitForTimeout(4000); |
| 44 | +await page.screenshot({ |
| 45 | + path: `${outDir}/screenshot-module.png`, |
| 46 | + fullPage: false, |
| 47 | +}); |
| 48 | +console.log("Module view captured"); |
| 49 | + |
| 50 | +// Switch to Forces view |
| 51 | +await page.click('button:has-text("Forces")'); |
| 52 | +await page.waitForTimeout(4000); |
| 53 | +await page.screenshot({ |
| 54 | + path: `${outDir}/screenshot-forces.png`, |
| 55 | + fullPage: false, |
| 56 | +}); |
| 57 | +console.log("Forces view captured"); |
| 58 | + |
| 59 | +await browser.close(); |
| 60 | +console.log("Done — screenshots saved to " + outDir); |
0 commit comments