import { createRequire } from "node:module"; import path from "node:path"; const { chromium } = createRequire(import.meta.url)(path.resolve("web/node_modules/playwright")); const browser = await chromium.launch({ headless: true, executablePath: "/usr/bin/google-chrome-stable", args: ["--no-sandbox","--use-gl=swiftshader","--enable-unsafe-swiftshader","--enable-unsafe-webgpu","--enable-dawn-features=allow_unsafe_apis","--use-webgpu-adapter=swiftshader"] }); const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 }, acceptDownloads: true }); const page = await ctx.newPage(); const logs = []; page.on("console", m => logs.push(`${m.type()}: ${m.text()}`.slice(0, 400))); page.on("pageerror", e => logs.push("pageerror: " + String(e).slice(0, 300))); await page.goto("http://127.0.0.1:5401/", { waitUntil: "domcontentloaded" }); await page.waitForFunction(() => document.body.innerText.includes("WASM ABI: ready"), undefined, { timeout: 120000 }); await page.getByTestId("blend-file-input").setInputFiles(path.resolve("tests/files/web/basic_scene.blend")); await page.waitForFunction(() => /Active Basic/.test(document.querySelector('[data-testid="scene-stats"]')?.textContent ?? ""), undefined, { timeout: 120000 }); await page.waitForTimeout(2000); const st = () => page.evaluate(() => ({ engine: document.querySelector('[data-testid="engine-status"]')?.textContent, diag: document.querySelector("main")?.getAttribute("data-diagnostic-count"), rev: document.querySelector("main")?.getAttribute("data-current-main-revision"), stats: document.querySelector('[data-testid="scene-stats"]')?.textContent, workspace: document.querySelector("main")?.getAttribute("data-workspace"), area: document.querySelector("main")?.getAttribute("data-editor-workflow-area") })); await page.evaluate(() => document.querySelector('[aria-label="添加立方体"]')?.click()); await page.waitForTimeout(3000); console.log("ADD:", JSON.stringify(await st())); await page.evaluate(() => document.querySelector('[aria-label="撤销"]')?.click()); await page.waitForTimeout(5000); console.log("UNDO:", JSON.stringify(await st())); console.log("BANNER:", JSON.stringify(await page.evaluate(() => [...document.querySelectorAll("[role=alert],[data-testid*=error],[class*=error],[class*=diagnostic]")].map(n => (n.textContent||"").trim().slice(0,200)).filter(Boolean).slice(0,8)))); console.log("LOGS:", JSON.stringify(logs.slice(-14), null, 1)); for (const name of ["Modeling", "Scripting", "Layout"]) { await page.evaluate((v) => { const b = [...document.querySelectorAll('nav[aria-label="工作区"] button')].find(n => (n.textContent||"").trim() === v); b?.click(); }, name); await page.waitForTimeout(4000); console.log("WS-"+name+":", JSON.stringify(await st()), "areas:", JSON.stringify(await page.evaluate(() => [...document.querySelectorAll("[data-editor-workflow-area]")].map(n => n.getAttribute("data-editor-workflow-area"))))); } await browser.close();