Advance deduplicated collection creation coverage
This commit is contained in:
6
web/tests/e2e/wbv2-collection-create-production.spec.ts
Normal file
6
web/tests/e2e/wbv2-collection-create-production.spec.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
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-P20-002 binds createCollection 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});const reopened=new WebEngineClient({timeoutMs:30000});try{const opened=await client.openBlend(Uint8Array.from(bytes).buffer);const baseRevision=opened.snapshot.revision;const beforeCount=opened.snapshot.collections.length;const created=await client.applyCommand({type:"createCollection",name:"WBV2P2002Collection",parentCollectionId:opened.snapshot.scenes[0]?.rootCollectionId??null}as any);const afterCreate=created.snapshot;const createdCollection=afterCreate.collections.find(c=>c.name==="WBV2P2002Collection");const undone=await client.applyCommand({type:"undo"});const redone=await client.applyCommand({type:"redo"});const malformed=await client.applyCommand({type:"createCollection",name:"",parentCollectionId:null}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);return{browser:"chromium",baseRevision,beforeCount,createRevision:afterCreate.revision,undoRevision:undone.snapshot.revision,redoRevision:redone.snapshot.revision,afterCount:afterCreate.collections.length,createdId:createdCollection?.id,createdName:createdCollection?.name,malformed,malformedRevisionPreserved:afterMalformed.snapshot.revision===redone.snapshot.revision,reopenedCount:reopen.snapshot.collections.length,reopenedHasCollection:reopen.snapshot.collections.some(c=>c.name==="WBV2P2002Collection"),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-P20-002"),{recursive:true});const output=process.env.WBV2_COLLECTION_REPORT??"collection-create-production.json";fs.writeFileSync(path.join(root,"tests/golden/WBV2-P20-002",output),`${JSON.stringify({schemaVersion:1,task:"WBV2-P20-002",operation:"COLLECTION_CREATE_ENGINE_CHROMIUM",queueMutation:false,fixtureSha256,...result},null,2)}\n`);expect(result.browser).toBe("chromium");expect(result.afterCount).toBe(result.beforeCount+1);expect(result.createRevision).toBe(result.baseRevision+1);expect(result.undoRevision).toBe(result.baseRevision+2);expect(result.redoRevision).toBe(result.baseRevision+3);expect(result.createdId).toBeTruthy();expect(result.createdName).toBe("WBV2P2002Collection");expect(result.malformed.code).not.toBe("NO_ERROR");expect(result.malformedRevisionPreserved).toBe(true);expect(result.reopenedCount).toBe(result.afterCount);expect(result.reopenedHasCollection).toBe(true);expect(result.reopenedRevision).toBe(1)});
|
||||
Reference in New Issue
Block a user