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>
49 lines
2.7 KiB
TypeScript
49 lines
2.7 KiB
TypeScript
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 history after pythonExec and undo behaviour", 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<any>((resolve, reject) => {
|
|
const requestId = `uh-${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 historyOf = async (tag: string) => {
|
|
try { const h = await send({ type: 'jsonCommand', cmd: 'history', params: {} }); log[tag] = { cursor: h.json?.cursor, entries: (h.json?.entries ?? []).map((e: any) => e.label) }; }
|
|
catch (e: any) { log[tag] = String(e?.message ?? e); }
|
|
};
|
|
await historyOf('historyAfterOpen');
|
|
try {
|
|
await send({ type: 'jsonCommand', cmd: 'pythonExec', params: { source: "import bpy\nbpy.context.scene['probe_marker']='x'\nprint('OK')", filename: 'Mark.py', console: false } });
|
|
log.pythonExec = 'ok';
|
|
} catch (e: any) { log.pythonExec = String(e?.message ?? e); }
|
|
await historyOf('historyAfterPython');
|
|
try { const u = await send({ type: 'applyCommand', payload: { type: 'undo' } }); log.undoAfterPython = { revision: u.snapshot?.revision }; }
|
|
catch (e: any) { log.undoAfterPython = String(e?.message ?? e); }
|
|
try {
|
|
const e2 = await send({ type: 'applyCommand', payload: { type: 'setFrame', frame: 2 } });
|
|
log.setFrame = { revision: e2.snapshot?.revision };
|
|
} catch (e: any) { log.setFrame = String(e?.message ?? e); }
|
|
await historyOf('historyAfterSetFrame');
|
|
return log;
|
|
});
|
|
fs.writeFileSync("/tmp/undo-history.json", JSON.stringify(out, null, 2));
|
|
});
|