Files
workinf_Blender_Wasm/web/tests/e2e/native-main-lifecycle.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

28 lines
1.4 KiB
TypeScript

import { expect, test } from "@playwright/test";
import fs from "node:fs";
import path from "node:path";
test("repeated native object creation and deletion survives serialization", async ({ page }) => {
await page.goto("/");
const bytes = fs.readFileSync(path.resolve(import.meta.dirname, "../../../tests/files/web/basic_scene.blend"));
const result = await page.evaluate(async (input) => {
const { WebEngineClient } = await import("/src/engine-client/WebEngineClient.ts");
const client = new WebEngineClient();
let cycle = 0;
try {
const opened = await client.openBlend(Uint8Array.from(input).buffer);
await client.saveBlend();
for (; cycle < 10; cycle++) {
const added = await client.applyCommand({ type: "createPrimitive", primitive: "CUBE", location: [0, 0, 0] });
if (added.snapshot.nodes.length !== opened.snapshot.nodes.length + 1) throw new Error("creation count mismatch");
const removed = await client.applyCommand({ type: "deleteObject", objectId: added.snapshot.activeObjectId! });
if (removed.snapshot.nodes.length !== opened.snapshot.nodes.length) throw new Error("deletion count mismatch");
await client.saveBlend();
}
return { cycle };
} catch (error) { throw new Error(JSON.stringify({ cycle, error })); }
finally { client.terminate(); }
}, Array.from(bytes));
expect(result.cycle).toBe(10);
});