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("/?engine=manual"); 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); });