#!/usr/bin/env node /** One-off probe: dump the native render panel DOM after a still and an animation. */ import fs from "node:fs"; import path from "node:path"; import { REPO, parseArgs, waitForServer, launchBrowser, newPage, openFile, waitScene } from "./course/lib/lesson-recorder.mjs"; const args = parseArgs(); const BASE = args.baseUrl || `http://127.0.0.1:${args.port}`; const SCENE = path.join(REPO, "web/app/public/tutorial/rendering/render-studio.blend"); const OUT = path.join(REPO, "tests/golden/RENDER-PATHS-001/server-native"); const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); await waitForServer(`${BASE}/?ui=web`); const browser = await launchBrowser(args.gpu); const { context } = await newPage(browser, { baseUrl: `${BASE}/?ui=web` }); const page = context.pages()[0] ?? await context.newPage(); const log = []; page.on("console", (message) => log.push(`${message.type()}: ${message.text()}`)); page.on("requestfailed", (request) => log.push(`requestfailed: ${request.url()} ${request.failure()?.errorText}`)); page.on("response", async (response) => { if (!response.url().includes("/api/blender-workflow")) return; const request = response.request(); if (request.method() !== "POST") return; log.push(`workflow-response ${response.status()} ${response.url()}`); }); await page.locator("main.blender-app").waitFor({ timeout: 180_000 }); await openFile(page, SCENE); await waitScene(page, { objects: 7, timeout: 180_000 }); await page.getByRole("button", { name: "渲染", exact: true }).click({ force: true }); await page.getByRole("menuitem", { name: /渲染图像/ }).first().click(); await page.locator("details.native-render-fallback").first().evaluate((element) => { element.open = true; }); await sleep(45_000); const still = await page.locator(".native-render-panel").evaluate((element) => element.outerHTML); fs.writeFileSync(path.join(OUT, "probe-still.html"), still); const stillOutput = await page.locator(".native-render-panel .native-workflow-output").innerText().catch(() => ""); const status = await page.locator('[data-testid="engine-status"]').innerText().catch(() => ""); await page.screenshot({ path: path.join(OUT, "probe-still.png") }); const panel = page.locator(".native-render-panel"); await panel.locator('select[aria-label="Format"]').selectOption("FFMPEG"); await panel.locator('input[type="number"]').nth(1).fill("1"); await panel.locator('input[type="number"]').nth(2).fill("4"); await panel.getByRole("button", { name: "Render Animation", exact: true }).click({ force: true }); await sleep(90_000); const animation = await page.locator(".native-render-panel").evaluate((element) => element.outerHTML); fs.writeFileSync(path.join(OUT, "probe-animation.html"), animation); const animationOutput = await page.locator(".native-render-panel .native-workflow-output").innerText().catch(() => ""); const status2 = await page.locator('[data-testid="engine-status"]').innerText().catch(() => ""); await page.screenshot({ path: path.join(OUT, "probe-animation.png") }); fs.writeFileSync(path.join(OUT, "probe-log.txt"), log.join("\n")); console.log(JSON.stringify({ stillOutput, status, animationOutput, status2, log: log.slice(-25) }, null, 2)); await context.close(); await browser.close();