import { tmpdir } from "node:os"; import { join } from "node:path"; import { chromium } from "playwright"; const base = process.env.TESSERA_URL ?? "http://127.0.0.1:8787/"; const outFlow = process.env.FLOW_SHOT ?? join(tmpdir(), "tessera-galaxy-flowing.png"); const outLock = process.env.LOCK_SHOT ?? join(tmpdir(), "tessera-galaxy-locked.png"); const browser = await chromium.launch({ headless: true }); try { const page = await browser.newPage({ viewport: { width: 1440, height: 900 } }); const [orbitResponse] = await Promise.all([ page.waitForResponse((response) => new URL(response.url()).pathname === "/api/v1/orbits" && response.ok()), page.goto(base), ]); await page.getByText("Hub online", { exact: true }).waitFor(); await page.screenshot({ path: outFlow }); const firstOrbit = page.locator(".register-row").first(); if ((await orbitResponse.json()).length) await firstOrbit.click(); else await page.getByRole("button", { name: "Pause motion" }).click(); await page.getByRole("button", { name: "Resume motion" }).waitFor(); await page.screenshot({ path: outLock }); console.log("saved", outFlow, outLock); } finally { await browser.close(); }