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>
57 lines
4.0 KiB
JavaScript
57 lines
4.0 KiB
JavaScript
import { createRequire } from "node:module";
|
|
import path from "node:path";
|
|
const { chromium } = createRequire(import.meta.url)(path.resolve("/home/mes123456/workinf_Blender_Wasm/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.addInitScript(() => {
|
|
const reg = []; window.__w = reg;
|
|
window.Worker = new Proxy(window.Worker, { construct(t, a) { const w = Reflect.construct(t, a); reg.push({ url: String(a[0]), worker: w }); return w; } });
|
|
});
|
|
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(3500);
|
|
const snap = () => page.evaluate(() => new Promise((resolve, reject) => {
|
|
const worker = window.__w.find(x => /web-engine\.worker/.test(x.url))?.worker;
|
|
if (!worker) return reject(new Error('no engine'));
|
|
const requestId = 'p-' + Math.random();
|
|
const timer = setTimeout(() => reject(new Error('timeout')), 30000);
|
|
const recv = ({ data }) => { if (data.requestId === requestId) { clearTimeout(timer); resolve(data); } };
|
|
worker.addEventListener('message', recv);
|
|
worker.postMessage({ requestId, command: { type: 'snapshot' } });
|
|
}));
|
|
const state = async () => {
|
|
const r = await snap(); const s = r.result?.snapshot;
|
|
const coll = Object.fromEntries((s?.collections ?? []).map(c => [c.name, c.objectIds.filter(Boolean).map(id => id.replace('object:', ''))]));
|
|
const parents = Object.fromEntries((s?.nodes ?? []).map(n => [n.name, n.parentId ? s.nodes.find(x => x.id === n.parentId)?.name : null]));
|
|
return { rev: s?.revision, coll, parents };
|
|
};
|
|
console.log("BEFORE", JSON.stringify(await state()));
|
|
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(2200); }
|
|
}
|
|
const drag = async (src, dst, mods = {}) => page.evaluate(({ srcName, dstName, ctrl }) => {
|
|
const find = (n) => [...document.querySelectorAll('[role="treeitem"]')].find(x => (x.getAttribute('aria-label')||'').trim() === n);
|
|
const s = find(srcName), d = find(dstName);
|
|
if (!s || !d) return { error: 'missing', s: Boolean(s), d: Boolean(d) };
|
|
const dt = new DataTransfer();
|
|
s.dispatchEvent(new DragEvent('dragstart', { bubbles: true, cancelable: true, dataTransfer: dt }));
|
|
d.dispatchEvent(new DragEvent('dragover', { bubbles: true, cancelable: true, dataTransfer: dt, ctrlKey: ctrl }));
|
|
const handled = !d.dispatchEvent(new DragEvent('drop', { bubbles: true, cancelable: true, dataTransfer: dt, ctrlKey: ctrl }));
|
|
return { handled };
|
|
}, { srcName: src, dstName: dst, ctrl: Boolean(mods.ctrl) });
|
|
// A: object -> collection row (Archive)
|
|
console.log("DRAG-TO-COLLECTION", JSON.stringify(await drag('Mount', 'Archive')));
|
|
await page.waitForTimeout(8000);
|
|
console.log("AFTER-COLLECTION", JSON.stringify(await state()));
|
|
// B: drop onto itself must do nothing
|
|
console.log("DRAG-SELF", JSON.stringify(await drag('Payload', 'Payload')));
|
|
await page.waitForTimeout(5000);
|
|
console.log("AFTER-SELF", JSON.stringify(await state()));
|
|
console.log("ENGINE", JSON.stringify(await page.evaluate(() => ({ e: document.querySelector('[data-testid="engine-status"]')?.textContent, d: (document.querySelector("main")?.getAttribute("data-last-diagnostic-detail")||"").slice(0,160) }))));
|
|
await browser.close();
|