#!/usr/bin/env node /** * Focused case: Geometry Nodes workspace Spreadsheet attributes + evaluated read. * * node tools/web/complete/probe-spreadsheet.mjs --base-url http://127.0.0.1:5176 */ import { ASSETS, parseArgs, launchBrowser, newPage, openFile, waitScene, switchWorkspace } 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(90_000); const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts); const state = async () => page.evaluate(() => { const view = document.querySelector('[data-testid="spreadsheet-view"]'); return { rows: view?.querySelectorAll('[data-testid="spreadsheet-row"]').length ?? null, text: view?.querySelector('table')?.textContent?.slice(0, 300) ?? null, status: document.querySelector('[data-testid="engine-status"]')?.textContent ?? "", }; }); try { await openFile(page, ASSETS.studio); await waitScene(page, { objects: 6, timeout: 240_000 }); await switchWorkspace(page, "Geometry Nodes"); const view = page.locator('[data-testid="spreadsheet-view"]').first(); await view.waitFor({ timeout: 30_000 }); const source = view.locator('select[aria-label="数据源"]'); log("sources", JSON.stringify(await source.locator('option').evaluateAll((nodes) => nodes.map((node) => node.value)))); await source.selectOption("attributes"); await page.waitForTimeout(1200); log("attributes", JSON.stringify(await state())); const evaluated = view.locator('[data-testid="spreadsheet-evaluated"]'); log("evaluated button", await evaluated.count()); if (await evaluated.count()) { await evaluated.click(); await page.waitForTimeout(3000); log("evaluated", 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(-8))); await context.close(); await browser.close(); }