Files
workinf_Blender_Wasm/web/tests/e2e/b3-pack-all-probe.spec.ts
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

53 lines
2.5 KiB
TypeScript

import fs from "node:fs";
import path from "node:path";
import { test } from "@playwright/test";
import { NativeUIWorkflow, observeNative } from "../fixtures/native-ui-workflow";
const root = path.resolve(import.meta.dirname, "../../..");
const fixture = path.join(root, "tests/files/web/image_resource_matrix.blend");
test("probe browser MEMFS layout and pack_all resolution", async ({ page }, testInfo) => {
test.setTimeout(180_000);
await observeNative(page);
await page.goto("/");
const flow = new NativeUIWorkflow(page, testInfo.outputPath("cases"));
await flow.command(() => page.getByTestId("blend-file-input").setInputFiles(fixture));
const out = await page.evaluate(async () => {
const worker = (window as any).__nativeWorkflowEngine as Worker;
const send = (command: any) => new Promise<any>((resolve, reject) => {
const requestId = `mem-${crypto.randomUUID()}`;
const receive = (event: MessageEvent) => {
if (event.data?.requestId !== requestId || event.data?.kind !== 'result') return;
worker.removeEventListener('message', receive);
if (event.data.ok) resolve(event.data.result); else reject(new Error(`${event.data.error?.code ?? 'NATIVE'}: ${event.data.error?.message ?? JSON.stringify(event.data.error)}`));
};
worker.addEventListener('message', receive); worker.postMessage({ requestId, command });
});
const source = [
"import bpy, os, json",
"def ls(p):",
" try: return sorted(os.listdir(p))[:25]",
" except Exception as e: return ['ERR:'+str(e)[:50]]",
"print('CWD', os.getcwd())",
"print('FILEPATH', repr(bpy.data.filepath))",
"print('ROOT', json.dumps(ls('/')))",
"print('BROWSER', json.dumps(ls('/browser')))",
"print('TMP', json.dumps(ls('/tmp')))",
"print('RES_EXISTS', os.path.exists('/resources'), os.path.exists('/missing'))",
"try:",
" print('PACK_ALL', bpy.ops.file.pack_all())",
"except Exception as e:",
" print('PACK_ALL_ERROR', type(e).__name__, str(e)[:300])",
].join("\n");
const log: any = {};
try {
const r = await send({ type: 'jsonCommand', cmd: 'pythonExec', params: { source, filename: 'MemFs.py', console: false } });
log.output = String(r.json?.output ?? '').slice(0, 2000);
log.state = r.json?.state;
log.revision = r.snapshot?.revision;
} catch (e: any) { log.error = String(e?.message ?? e); }
return log;
});
fs.writeFileSync("/tmp/pack-memfs-probe.json", JSON.stringify(out, null, 2));
});