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 } }); const page = await ctx.newPage(); const logs = []; page.on("console", m => logs.push(m.type()+": "+m.text().slice(0,400))); await page.goto("http://127.0.0.1:5402/", { 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 before = logs.length; await page.evaluate(() => { const b = [...document.querySelectorAll('nav[aria-label="工作区"] button')].find(n => (n.textContent||"").trim() === "Shading"); b?.click(); }); await page.waitForTimeout(12000); const state = await page.evaluate(() => ({ display: document.querySelector('canvas[aria-label="Blender desktop"]')?.getAttribute("data-native-display"), statusBar: document.querySelector('[data-testid="engine-status"]')?.textContent, bodyText: (document.body.innerText||"").split("\n").filter(l => /失败|错误|error|unavailable|无法/i.test(l)).slice(0,8), })); console.log("STATE", JSON.stringify(state)); console.log("NEWLOGS", JSON.stringify(logs.slice(before).slice(0,10), null, 1)); // confirm user impact: can we still add a cube after the wedge? await page.evaluate(() => document.querySelector('[aria-label="添加立方体"]')?.click()); await page.waitForTimeout(6000); console.log("AFTER-ADD", JSON.stringify(await page.evaluate(() => ({ stats: document.querySelector('[data-testid="scene-stats"]')?.textContent, engine: document.querySelector('[data-testid="engine-status"]')?.textContent, detail: (document.querySelector("main")?.getAttribute("data-last-diagnostic-detail")||"").slice(0,160) })))); await browser.close();