Advance deduplicated transform apply coverage
This commit is contained in:
3
web/tests/e2e/wbv2-object-transform-production.spec.ts
Normal file
3
web/tests/e2e/wbv2-object-transform-production.spec.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { expect, test } from "@playwright/test";import crypto from "node:crypto";import fs from "node:fs";import path from "node:path";
|
||||
const root=path.resolve(import.meta.dirname,"../../..");const fixture=fs.readFileSync(path.join(root,"tests/files/web/basic_scene.blend"));const fixtureSha256=crypto.createHash("sha256").update(fixture).digest("hex");
|
||||
test("WBV2-P23-002 binds applyObjectTransform to compiled WASM Main",async({page})=>{test.setTimeout(120000);await page.goto("/");const result=await page.evaluate(async(bytes)=>{const{WebEngineClient}=await import("/src/engine-client/WebEngineClient.ts");const client=new WebEngineClient({timeoutMs:30000}),reopened=new WebEngineClient({timeoutMs:30000});try{const opened=await client.openBlend(Uint8Array.from(bytes).buffer);const object=opened.snapshot.nodes.find(n=>n.type==="MESH");if(!object)throw new Error("basic scene has no mesh object");const baseRevision=opened.snapshot.revision;const beforeTransform={translation:object.translation,rotationEuler:object.rotationEuler,scale:object.scale};const changed=await client.applyCommand({type:"applyObjectTransform",objectId:object.id}as any);const after=changed.snapshot.nodes.find(n=>n.id===object.id);const undone=await client.applyCommand({type:"undo"});const redone=await client.applyCommand({type:"redo"});const malformed=await client.applyCommand({type:"applyObjectTransform",objectId:"object:missing"}as any).then(()=>({code:"NO_ERROR"})).catch((e:any)=>({code:e?.code,message:e?.message}));const afterMalformed=await client.snapshot();const saved=await client.saveBlend();const reopen=await reopened.openBlend(saved);const reopenedNode=reopen.snapshot.nodes.find(n=>n.id===object.id);return{browser:"chromium",baseRevision,objectId:object.id,beforeTransform,afterTransform:{translation:after?.translation,rotationEuler:after?.rotationEuler,scale:after?.scale},applyRevision:changed.snapshot.revision,undoRevision:undone.snapshot.revision,redoRevision:redone.snapshot.revision,malformed,malformedRevisionPreserved:afterMalformed.snapshot.revision===redone.snapshot.revision,reopenedTransform:{translation:reopenedNode?.translation,rotationEuler:reopenedNode?.rotationEuler,scale:reopenedNode?.scale},reopenedRevision:reopen.snapshot.revision,savedSha256:await(async(v)=>{const h=await crypto.subtle.digest("SHA-256",v);return Array.from(new Uint8Array(h),b=>b.toString(16).padStart(2,"0")).join("")})(saved)}}finally{client.terminate();reopened.terminate()}} ,Array.from(fixture));fs.mkdirSync(path.join(root,"tests/golden/WBV2-P23-002"),{recursive:true});const output=process.env.WBV2_TRANSFORM_REPORT??"object-transform-production.json";fs.writeFileSync(path.join(root,"tests/golden/WBV2-P23-002",output),`${JSON.stringify({schemaVersion:1,task:"WBV2-P23-002",operation:"OBJECT_TRANSFORM_APPLY_ENGINE_CHROMIUM",queueMutation:false,fixtureSha256,...result},null,2)}\n`);expect(result.browser).toBe("chromium");expect(result.applyRevision).toBe(result.baseRevision+1);expect(result.undoRevision).toBe(result.baseRevision+2);expect(result.redoRevision).toBe(result.baseRevision+3);expect(result.malformed.code).not.toBe("NO_ERROR");expect(result.malformedRevisionPreserved).toBe(true);expect(result.reopenedRevision).toBe(1);expect(result.reopenedTransform).toEqual(result.afterTransform)});
|
||||
Reference in New Issue
Block a user