Files
workinf_Blender_Wasm/web/tests/e2e/b3-pack-write-stability-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

44 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 effects = path.join(root, "blender-5.2.0/tests/files/sequence_editing/effects");
const mask = fs.readFileSync(path.join(effects, "mask.png"));
test("probe Main write stability after pack_all", 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(path.join(effects, "fx_comp.blend")));
await expect(page.getByTestId("engine-status")).toContainText("SceneIR", { timeout: 60000 });
const out = await page.evaluate(async (maskBase64) => {
const worker = (window as any).__nativeWorkflowEngine as Worker;
const send = (command: any) => new Promise<any>((resolve, reject) => {
const requestId = `ws-${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: 'Stab.py', console: false } });
const digest = (buf: ArrayBuffer) => crypto.subtle.digest('SHA-256', buf).then((h) => Array.from(new Uint8Array(h), (b) => b.toString(16).padStart(2, '0')).join(''));
const log: any = {};
const saveBlend = async () => (await send({ type: 'saveBlend' })).blend as ArrayBuffer;
log.before = (await digest(await saveBlend())).slice(0, 16);
await py(["import bpy, base64", "open('/browser/mask.png','wb').write(base64.b64decode('" + maskBase64 + "'))", "print('PACK', bpy.ops.file.pack_all())"].join("\n"));
const a = await saveBlend(), b = await saveBlend();
log.afterFirst = (await digest(a)).slice(0, 16);
log.afterSecond = (await digest(b)).slice(0, 16);
log.stable = log.afterFirst === log.afterSecond;
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); }
return log;
}, mask.toString("base64"));
fs.writeFileSync("/tmp/pack-write-stability.json", JSON.stringify(out, null, 2));
});