import fs from "node:fs"; import path from "node:path"; import { test, expect } 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/basic_scene.blend"); test("probe undo after pack_all with no external images", 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)); await expect(page.getByTestId("engine-status")).toContainText("SceneIR", { timeout: 60000 }); const out = await page.evaluate(async () => { const worker = (window as any).__nativeWorkflowEngine as Worker; const send = (command: any) => new Promise((resolve, reject) => { const requestId = `nf-${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}: ${event.data.error?.message}`)); }; worker.addEventListener('message', receive); worker.postMessage({ requestId, command }); }); const log: any = {}; const py = (source: string) => send({ type: 'jsonCommand', cmd: 'pythonExec', params: { source, filename: 'Nf.py', console: false } }); const r = await py("import bpy\nprint('PACK', bpy.ops.file.pack_all())\nprint('IMAGES', len(bpy.data.images))"); log.pack = String(r.json?.output ?? '').slice(0, 300); log.packState = r.json?.state; try { const u = await send({ type: 'applyCommand', payload: { type: 'undo' } }); log.undo = { revision: u.snapshot?.revision }; } catch (e: any) { log.undo = String(e?.message ?? e).slice(0, 260); } return log; }); fs.writeFileSync("/tmp/pack-nofile.json", JSON.stringify(out, null, 2)); });