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 cases: Array<[string, string, string]> = [ ["blender-5.2.0/tests/files/sequence_editing/effects/fx_comp.blend", "fx_comp", "unpacked-missing-image"], ["tests/files/web/corrupt_packed_image.blend", "corrupt_packed_image", "packed-relative-image"], ["tests/files/web/basic_scene.blend", "basic_scene", "no-external-image"], ]; test("probe undo after edit across fixtures with reliable open wait", async ({ page }, testInfo) => { test.setTimeout(240_000); await observeNative(page); await page.goto("/"); const results: Record = {}; for (const [rel, project, tag] of cases) { try { await page.getByTestId("blend-file-input").setInputFiles(path.join(root, rel)); await expect.poll(async () => page.locator("main.blender-app").evaluate((n) => (n as HTMLElement).dataset.projectId), { timeout: 60000 }).toBe(project); 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 = `x-${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 py = (source: string) => send({ type: 'jsonCommand', cmd: 'pythonExec', params: { source, filename: 'X.py', console: false } }); const log: any = {}; log.state = String((await py("import bpy\nprint('SCENE', bpy.context.scene.name, 'FP', repr(bpy.data.filepath), 'IMGS', [(i.name, i.source, i.filepath, i.packed_file is not None, list(i.size)) for i in bpy.data.images])")).json?.output ?? '').trim().slice(0, 320); await py("import bpy\nbpy.context.scene['probe_marker']='m1'"); try { const u = await send({ type: 'applyCommand', payload: { type: 'undo' } }); log.undo = `ok rev ${u.snapshot?.revision}`; } catch (e: any) { log.undo = String(e?.message ?? e).slice(0, 90); } return log; }); results[tag] = out; } catch (error: any) { results[tag] = `OPEN_FAILED: ${String(error?.message ?? error).slice(0, 140)}`; } } fs.writeFileSync("/tmp/undo-image-matrix.json", JSON.stringify(results, null, 2)); });