chore(web): continuous handoff WBV2-P1291-001
This commit is contained in:
52
web/tests/e2e/wbv2-uv-unwrap-batch-production.spec.ts
Normal file
52
web/tests/e2e/wbv2-uv-unwrap-batch-production.spec.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
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 fixturePath = process.env.WBV2_BATCH_FIXTURE ?? "tests/files/web/generated/WBV2-P3-001-MATERIAL.PBR_UV.blend";
|
||||
const fixture = fs.readFileSync(path.join(root, fixturePath));
|
||||
const fixtureSha256 = crypto.createHash("sha256").update(fixture).digest("hex");
|
||||
const task = process.env.WBV2_BATCH_TASK ?? "WBV2-UV-UNWRAP";
|
||||
const productionPath = process.env.WBV2_BATCH_PRODUCTION ?? `tests/golden/${task}/uv-unwrap-production.json`;
|
||||
const sourceUnits = JSON.parse(process.env.WBV2_BATCH_UNITS ?? "[\"operator:UV_OT_unwrap\"]") as string[];
|
||||
|
||||
test("native UV unwrap batch preserves Main recovery semantics", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
const result = await page.evaluate(async (bytes) => {
|
||||
const { WebEngineClient } = await import("/src/engine-client/WebEngineClient.ts");
|
||||
const client = new WebEngineClient({ timeoutMs: 60_000 });
|
||||
const reopened = new WebEngineClient({ timeoutMs: 60_000 });
|
||||
const shape = (error: any) => ({ code: error?.code, message: error?.message });
|
||||
try {
|
||||
const opened = await client.openBlend(Uint8Array.from(bytes).buffer);
|
||||
const mesh: any = opened.snapshot.meshes.find((candidate: any) => candidate.id === "mesh:WBV2P3001MaterialCubeMesh") ?? opened.snapshot.meshes.find((candidate: any) => candidate.vertexCount > 0);
|
||||
const object: any = opened.snapshot.nodes.find((candidate: any) => candidate.dataId === mesh?.id);
|
||||
if (!mesh || !object) throw new Error("UV fixture has no mesh object");
|
||||
const added = await client.applyCommand({ type: "createUVMap", meshId: mesh.id, name: "WBV2UnwrapUV", baseRevision: opened.snapshot.revision } as any);
|
||||
const active = await client.applyCommand({ type: "setActiveUVMap", meshId: mesh.id, name: "WBV2UnwrapUV", baseRevision: added.snapshot.revision } as any);
|
||||
const unwrapped = await client.applyCommand({ type: "unwrapUV", meshId: mesh.id, faceIndices: [0], method: "CUBE", baseRevision: active.snapshot.revision } as any);
|
||||
const undo = await client.applyCommand({ type: "undo" });
|
||||
const redo = await client.applyCommand({ type: "redo" });
|
||||
const malformed = await client.applyCommand({ type: "unwrapUV", meshId: "mesh:missing", faceIndices: [0], method: "CUBE", baseRevision: redo.snapshot.revision } as any).then(() => ({ code: "NO_ERROR" })).catch(shape);
|
||||
const afterMalformed = await client.snapshot();
|
||||
const saved = await client.saveBlend();
|
||||
const restored = await reopened.openBlend(saved.slice(0));
|
||||
const restoredMesh: any = restored.snapshot.meshes.find((candidate: any) => candidate.id === mesh.id);
|
||||
return { browser: "chromium", baseRevision: opened.snapshot.revision, addRevision: added.snapshot.revision, activeRevision: active.snapshot.revision, unwrapRevision: unwrapped.snapshot.revision, undoRevision: undo.snapshot.revision, redoRevision: redo.snapshot.revision, activeUVMap: unwrapped.snapshot.meshes.find((candidate: any) => candidate.id === mesh.id)?.activeUVMap, restoredUVMap: restoredMesh?.activeUVMap, malformed, malformedRevisionPreserved: afterMalformed.snapshot.revision === redo.snapshot.revision, reopenedRevision: restored.snapshot.revision };
|
||||
} finally { client.terminate(); reopened.terminate(); }
|
||||
}, Array.from(fixture));
|
||||
fs.mkdirSync(path.dirname(path.join(root, productionPath)), { recursive: true });
|
||||
fs.writeFileSync(path.join(root, productionPath), `${JSON.stringify({ schemaVersion: 1, task, operation: "UV_UNWRAP_ENGINE_CHROMIUM", browser: "chromium", queueMutation: false, fixture: fixturePath, fixtureSha256, sourceUnits, ...result }, null, 2)}\n`);
|
||||
expect(result.browser).toBe("chromium");
|
||||
expect(result.addRevision).toBe(result.baseRevision + 1);
|
||||
expect(result.activeRevision).toBe(result.baseRevision + 2);
|
||||
expect(result.unwrapRevision).toBe(result.baseRevision + 3);
|
||||
expect(result.undoRevision).toBe(result.baseRevision + 4);
|
||||
expect(result.redoRevision).toBe(result.baseRevision + 5);
|
||||
expect(result.activeUVMap).toBe("WBV2UnwrapUV");
|
||||
expect(result.restoredUVMap).toBe("WBV2UnwrapUV");
|
||||
expect(result.malformed.code).not.toBe("NO_ERROR");
|
||||
expect(result.malformedRevisionPreserved).toBe(true);
|
||||
expect(result.reopenedRevision).toBe(1);
|
||||
});
|
||||
Reference in New Issue
Block a user