#!/usr/bin/env node /** * Focused case: Properties -> Modifier Stack add SUBSURF and Apply through the * native operator channel in the ?ui=web entry. * * node tools/web/complete/probe-modifier.mjs --base-url http://127.0.0.1:5176 */ import { ASSETS, parseArgs, launchBrowser, newPage, openFile, waitScene } from "../course/lib/lesson-recorder.mjs"; const args = parseArgs(); const BASE = args.baseUrl || "http://127.0.0.1:5176"; const browser = await launchBrowser(args.gpu); const { context, page, consoleErrors } = await newPage(browser, { baseUrl: BASE }); page.setDefaultTimeout(60_000); const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts); const state = async () => page.evaluate(() => ({ stats: document.querySelector('[data-testid="scene-stats"]')?.textContent ?? "", status: document.querySelector('[data-testid="engine-status"]')?.textContent ?? "", alerts: Array.from(document.querySelectorAll('[role="alert"]')).map((node) => node.textContent).slice(0, 3), rows: Array.from(document.querySelectorAll('.modifier-row')).map((node) => node.textContent?.slice(0, 120)), })); try { await openFile(page, ASSETS.studio); await waitScene(page, { objects: 6, timeout: 240_000 }); const authoring = page.locator('.modifier-stack-authoring').first(); await authoring.waitFor({ timeout: 30_000 }); log("start", JSON.stringify(await state())); await authoring.locator('[data-modifier-type-input]').fill("SUBSURF"); await authoring.getByRole("button", { name: "Add", exact: true }).click(); const row = page.locator('.modifier-row').filter({ hasText: "SUBSURF" }).first(); await row.waitFor({ timeout: 30_000 }); log("added", JSON.stringify(await state())); await row.locator('[aria-label^="Apply "]').first().click(); const deadline = Date.now() + 90_000; while (Date.now() < deadline) { const current = await state(); if (!current.rows.some((text) => text.includes("SUBSURF")) || current.alerts.length) { log("applied", JSON.stringify(current)); break; } await page.waitForTimeout(250); } log("final", JSON.stringify(await state())); } catch (error) { log("probe error", error instanceof Error ? error.message : String(error)); log("state", JSON.stringify(await state().catch(() => null))); } finally { log("consoleErrors", JSON.stringify(consoleErrors.slice(-12))); await context.close(); await browser.close(); }