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, "blender-5.2.0/tests/files/sequence_editing/effects/fx_comp.blend"); test("probe filepath and external image resolution in browser session", 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((resolve, reject) => { const requestId = `path-${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", "print('FILEPATH', repr(bpy.data.filepath))", "print('ABS_MASK', bpy.path.abspath('//mask.png'))", "print('IMAGES', json.dumps([{'n': i.name, 'fp': i.filepath, 'packed': i.packed_file is not None} for i in bpy.data.images]))", "print('EXISTS', os.path.exists(bpy.path.abspath('//mask.png')))", "print('ROOTS', json.dumps(sorted(os.listdir('/'))))", "try:", " print('PACK', bpy.ops.file.pack_all())", "except Exception as e:", " print('PACK_ERROR', type(e).__name__, str(e)[:200])", "print('IMAGES_AFTER', json.dumps([{'n': i.name, 'packed': i.packed_file is not None} for i in bpy.data.images]))", ].join("\n"); const log: any = {}; try { const r = await send({ type: 'jsonCommand', cmd: 'pythonExec', params: { source, filename: 'PathProbe.py', console: false } }); log.state = r.json?.state; log.output = String(r.json?.output ?? '').slice(0, 2000); log.revisionBeforeAfter = r.snapshot?.revision; } catch (e: any) { log.error = String(e?.message ?? e); } return log; }); fs.writeFileSync("/tmp/pack-path-probe.json", JSON.stringify(out, null, 2)); });