Files
workinf_Blender_Wasm/web/tests/e2e/b3-reset-semantic5-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

39 lines
2.8 KiB
TypeScript

import fs from "node:fs";
import path from "node:path";
import { test, expect } from "@playwright/test";
import { observeNative } from "../fixtures/native-ui-workflow";
const root = path.resolve(import.meta.dirname, "../../..");
test("undo routes after python exec on fx_comp", async ({ page }) => {
test.setTimeout(300_000);
await observeNative(page);
await page.goto("/");
await page.getByTestId("blend-file-input").setInputFiles(path.join(root, "blender-5.2.0/tests/files/sequence_editing/effects/fx_comp.blend"));
await expect.poll(async () => page.locator("main.blender-app").evaluate((n) => (n as HTMLElement).dataset.projectId), { timeout: 60000 }).toBe("fx_comp");
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 = `sem5-${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(Object.assign(new Error(`${event.data.error?.code}: ${event.data.error?.message}`), { detail: event.data.error }));
};
worker.addEventListener('message', receive); worker.postMessage({ requestId, command });
});
const brief = (r: any) => r?.status ?? r?.json?.state ?? r?.snapshot?.revision ?? 'ok';
const log: any = {};
log.exec = await send({ type: 'jsonCommand', cmd: 'pythonExec', params: { source: 'import bpy\nbpy.context.scene.name = bpy.context.scene.name\n', filename: 'Probe.py', console: false } }).then(brief, (e: Error) => String(e.message));
log.undoApply = await send({ type: 'applyCommand', payload: { type: 'undo' } }).then(brief, (e: Error) => String(e.message));
log.redoApply = await send({ type: 'applyCommand', payload: { type: 'redo' } }).then(brief, (e: Error) => String(e.message));
log.history = await send({ type: 'jsonCommand', cmd: 'history', params: {} }).then((r: any) => JSON.stringify(r?.json ?? r).slice(0, 300), (e: Error) => String(e.message));
log.openAfter = await send({ type: 'jsonCommand', cmd: 'pythonReset', params: {} }).then(brief, (e: Error) => String(e.message));
log.exec2 = await send({ type: 'jsonCommand', cmd: 'pythonExec', params: { source: 'import bpy\nprint(len(bpy.data.images))\n', filename: 'Probe2.py', console: false } }).then(brief, (e: Error) => String(e.message));
log.undo2 = await send({ type: 'applyCommand', payload: { type: 'undo' } }).then(brief, (e: Error) => String(e.message));
return log;
});
fs.writeFileSync("/tmp/reset-semantic5.json", JSON.stringify(out, null, 2));
});