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:5412/?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); // expand parents so the drop target is visible for (const name of ['Parts','Mount','RootRig']) { const btn = page.getByRole('button', { name: `展开 ${name}`, exact: true }).first(); if (await btn.count()) { await btn.click(); await page.waitForTimeout(2500); } } const rows = () => page.evaluate(() => [...document.querySelectorAll('[role="treeitem"]')].map(n => ({ name: (n.getAttribute('aria-label')||'').trim(), level: n.getAttribute('aria-level'), node: n.getAttribute('data-node-id'), parent: n.getAttribute('data-parent-id'), draggable: n.getAttribute('draggable') })).filter(r => r.name)); console.log("BEFORE", JSON.stringify(await rows())); const draggable = await page.evaluate(() => document.querySelectorAll('[role="treeitem"][draggable="true"]').length); console.log("DRAGGABLE-ROWS", draggable); // HTML5 drag: Mount -> NewParent const res = await page.evaluate(() => { const find = (name) => [...document.querySelectorAll('[role="treeitem"]')].find(n => (n.getAttribute('aria-label')||'').trim() === name); const src = find('Mount'), dst = find('NewParent'); if (!src || !dst) return { error: 'missing node', src: Boolean(src), dst: Boolean(dst) }; const dt = new DataTransfer(); const fire = (el, type) => el.dispatchEvent(new DragEvent(type, { bubbles: true, cancelable: true, dataTransfer: dt })); fire(src, 'dragstart'); fire(dst, 'dragover'); fire(dst, 'drop'); fire(src, 'dragend'); return { payload: dt.getData('application/x-web-blender-objects') }; }); console.log("DRAG", JSON.stringify(res)); await page.waitForTimeout(7000); console.log("AFTER", JSON.stringify(await rows())); console.log("ENGINE", JSON.stringify(await page.evaluate(() => ({ engine: document.querySelector('[data-testid="engine-status"]')?.textContent, detail: (document.querySelector("main")?.getAttribute("data-last-diagnostic-detail")||"").slice(0,200) })))); await browser.close();