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(); await page.goto("http://127.0.0.1:5411/?ui=web", { 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/hierarchy_simplify_combined.blend")); await page.waitForFunction(() => /SceneIR r\d+/.test(document.querySelector('[data-testid="engine-status"]')?.textContent ?? ""), undefined, { timeout: 120000 }); await page.waitForTimeout(3000); // A: is the Decimate panel present and enabled? const panel = await page.evaluate(() => { const h = [...document.querySelectorAll('.property-section h3')].find(n => (n.textContent||'').trim() === 'Decimate'); const section = h?.closest('.property-section'); if (!section) return { found: false }; const btn = (label) => { const b = section.querySelector(`[aria-label="${label}"]`); return b ? { disabled: b.disabled } : null; }; return { found: true, summary: section.querySelector('.modifier-summary span')?.textContent?.trim(), preview: btn('预览 Decimate'), apply: btn('应用 Decimate') }; }); console.log("PANEL", JSON.stringify(panel)); // B: preview and read counts if (panel.found && panel.preview && !panel.preview.disabled) { await page.getByRole('button', { name: '预览 Decimate', exact: true }).click(); try { await page.waitForFunction(() => /三角形/.test(document.querySelector('[data-testid="simplify-triangle-counts"]')?.textContent ?? ''), undefined, { timeout: 90000 }); } catch (e) { console.log("PREVIEW-TIMEOUT"); } console.log("COUNTS", JSON.stringify(await page.evaluate(() => ({ counts: document.querySelector('[data-testid="simplify-triangle-counts"]')?.textContent, engine: document.querySelector('[data-testid="engine-status"]')?.textContent, detail: (document.querySelector("main")?.getAttribute("data-last-diagnostic-detail")||"").slice(0,160), })))); } await browser.close();