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>
51 lines
4.0 KiB
TypeScript
51 lines
4.0 KiB
TypeScript
import crypto from "node:crypto";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { expect, test } from "@playwright/test";
|
|
|
|
const root = path.resolve(import.meta.dirname, "../../..");
|
|
const fixture = fs.readFileSync(path.join(root, "tests/files/web/nonmesh_scene.blend"));
|
|
const fixtureSha256 = crypto.createHash("sha256").update(fixture).digest("hex");
|
|
|
|
test("WBV2-P1101-000 preserves createCurve Main creation and recovery", async ({ page }) => {
|
|
test.setTimeout(180_000);
|
|
await page.goto("/");
|
|
const result = await page.evaluate(async (input) => {
|
|
const { WebEngineClient } = await import("/src/engine-client/WebEngineClient.ts");
|
|
const client = new WebEngineClient({ timeoutMs: 60_000 });
|
|
const reopenedClient = new WebEngineClient({ timeoutMs: 60_000 });
|
|
const state = (snapshot: any, name: string) => ({ revision: snapshot.revision, objects: snapshot.nodes?.filter((node: any) => node.name === name).map((node: any) => ({ id: node.id, type: node.type, dataId: node.dataId })), curves: snapshot.nonMeshData?.filter((data: any) => data.name === name).map((data: any) => ({ id: data.id, type: data.type, pointCount: data.pointCount, resolution: data.resolution, controlPoints: data.controlPoints })) });
|
|
try {
|
|
const opened = await client.openBlend(Uint8Array.from(input.bytes).buffer);
|
|
const name = "WebCreatedCurve";
|
|
const before = state(opened.snapshot, name);
|
|
const points = [0, 0, 0, 1, 0.5, 0, 2, 0, 0];
|
|
const created = await client.applyCommand({ type: "createCurve", curveType: "CURVE", name, controlPoints: points, cyclic: false, resolution: 8 } as any);
|
|
const afterCreate = state(created.snapshot, name);
|
|
const undo = await client.applyCommand({ type: "undo" } as any);
|
|
const redo = await client.applyCommand({ type: "redo" } as any);
|
|
const malformed = await client.applyCommand({ type: "createCurve", curveType: "CURVE", name: "BadCurve", controlPoints: [0, 1], resolution: 8 } as any).then(() => ({ code: "NO_ERROR" })).catch((error: any) => ({ code: error?.code, message: error?.message }));
|
|
const afterMalformed = await client.snapshot();
|
|
const saved = await client.saveBlend();
|
|
const reopened = await reopenedClient.openBlend(saved.slice(0));
|
|
return { fixtureSha256: input.fixtureSha256, name, before, afterCreate, undo: state(undo.snapshot, name), redo: state(redo.snapshot, name), malformed, malformedRevisionPreserved: afterMalformed.snapshot.revision === redo.snapshot.revision, afterReopen: state(reopened.snapshot, name), savedSha256: await crypto.subtle.digest("SHA-256", saved).then((hash) => Array.from(new Uint8Array(hash), (byte) => byte.toString(16).padStart(2, "0")).join("")) };
|
|
}
|
|
catch (error: any) { return { error: { code: error?.code, message: error?.message, detail: String(error) } } as any; }
|
|
finally { client.terminate(); reopenedClient.terminate(); }
|
|
}, { bytes: Array.from(fixture), fixtureSha256 });
|
|
fs.mkdirSync(path.join(root, "tests/golden/WBV2-P1101-000"), { recursive: true });
|
|
fs.writeFileSync(path.join(root, "tests/golden/WBV2-P1101-000/curve-create-production.json"), `${JSON.stringify({ schemaVersion: 1, task: "WBV2-P1101-000", operation: "CURVE_CREATE_MAIN_CHROMIUM", browser: "chromium", queueMutation: false, ...result }, null, 2)}\n`);
|
|
expect(result.error).toBeUndefined();
|
|
expect(result.fixtureSha256).toBe(fixtureSha256);
|
|
expect(result.afterCreate.objects).toHaveLength(1);
|
|
expect(result.afterCreate.curves).toEqual([{ id: result.afterCreate.objects[0].dataId, type: "CURVE", pointCount: 3, resolution: 8 }]);
|
|
expect(result.undo.objects).toEqual(result.before.objects);
|
|
expect(result.redo.objects).toEqual(result.afterCreate.objects);
|
|
expect(result.malformed.code).not.toBe("NO_ERROR");
|
|
expect(result.malformedRevisionPreserved).toBe(true);
|
|
expect(result.afterReopen.objects).toEqual(result.afterCreate.objects);
|
|
expect(result.afterReopen.curves[0]).toEqual(result.afterCreate.curves[0]);
|
|
expect(result.afterReopen.revision).toBe(1);
|
|
expect(result.savedSha256).not.toBe(fixtureSha256);
|
|
});
|