Files
workinf_Blender_Wasm/tools/web/.probe48.mjs
mes123456 f3e21c6b98
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
chore: checkpoint web Blender migration source, tools and docs
Accumulated uncommitted work: GHOST Web backend, WebGL/GPU web layer,
web workflow engine and protocol, tooling, docs and task records.
Large generated evidence, user-testing archives, build snapshots and
imported test assets remain untracked.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-10 11:18:01 +08:00

58 lines
3.8 KiB
JavaScript

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);
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 state = () => page.evaluate(() => ({
engine: document.querySelector('[data-testid="engine-status"]')?.textContent,
detail: (document.querySelector("main")?.getAttribute("data-last-diagnostic-detail")||"").slice(0,200),
tree: [...document.querySelectorAll('[role="treeitem"]')].map(n => `${n.getAttribute('aria-level')}:${(n.getAttribute('aria-label')||'').trim()}`).filter(x => !x.endsWith(':')),
}));
console.log("A-start", JSON.stringify(await state()));
// drag Mount -> NewParent
const drag = 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' };
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');
const dropHandled = !dst.dispatchEvent(new DragEvent('drop', { bubbles: true, cancelable: true, dataTransfer: dt }));
fire(src, 'dragend');
return { payload: dt.getData('application/x-web-blender-objects'), dropHandled };
});
console.log("drag", JSON.stringify(drag));
await page.waitForTimeout(8000);
console.log("B-after-drag", JSON.stringify(await state()));
// control: menu-based reparent of Payload -> NewParent
await page.evaluate(() => {
const find = (name) => [...document.querySelectorAll('[role="treeitem"]')].find(n => (n.getAttribute('aria-label')||'').trim() === name);
find('Payload')?.querySelector('.tree-node-name')?.dispatchEvent(new MouseEvent('click', { bubbles: true }));
});
await page.waitForTimeout(2500);
await page.evaluate(() => {
const find = (name) => [...document.querySelectorAll('[role="treeitem"]')].find(n => (n.getAttribute('aria-label')||'').trim() === name);
find('NewParent')?.querySelector('.tree-node-name')?.dispatchEvent(new MouseEvent('click', { bubbles: true, ctrlKey: true }));
});
await page.waitForTimeout(2500);
console.log("C-selected", JSON.stringify(await page.evaluate(() => document.querySelector('main')?.getAttribute('data-selected-object-ids'))));
await page.getByRole('button', { name: '物体', exact: true }).click();
await page.waitForTimeout(800);
await page.getByRole('menuitem', { name: '父级', exact: true }).click();
await page.waitForTimeout(800);
await page.getByRole('menuitem', { name: '设定父级', exact: true }).click();
await page.waitForTimeout(8000);
console.log("D-after-menu", JSON.stringify(await state()));
await browser.close();