Advance WBV2 high-value domains through P13
This commit is contained in:
47
web/tests/e2e/wbv2-geometry-nodes-production.spec.ts
Normal file
47
web/tests/e2e/wbv2-geometry-nodes-production.spec.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
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 evidenceRoot = path.join(root, "tests/golden/WBV2-P13-002");
|
||||
const fixturePath = path.join(root, "tests/files/web/modifier_geometry_nodes_scene.blend");
|
||||
const fixture = fs.readFileSync(fixturePath);
|
||||
const sourceSha256 = crypto.createHash("sha256").update(fixture).digest("hex");
|
||||
|
||||
test("WBV2-P13-002 binds Geometry Nodes graph evidence to compiled WASM Main", 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 digest = async (value: ArrayBuffer): Promise<string> => { const hash = await crypto.subtle.digest("SHA-256", value); return Array.from(new Uint8Array(hash), (byte) => byte.toString(16).padStart(2, "0")).join(""); };
|
||||
try {
|
||||
const opened = await client.openBlend(Uint8Array.from(input.bytes).buffer);
|
||||
const graphs = opened.snapshot.geometryNodeGraphs ?? [];
|
||||
if (graphs.length < 2) throw new Error("Geometry Nodes fixture has fewer than two graphs");
|
||||
const hashesBefore = graphs.map((graph: any) => ({ name: graph.name, graphHash: graph.graphHash, nodes: graph.nodes.map((node: any) => node.type).sort(), links: graph.links.length }));
|
||||
const unsupported = graphs.find((graph: any) => graph.nodes.some((node: any) => node.type === "GeometryNodeSimulationOutput")) ?? graphs[graphs.length - 1];
|
||||
const meshId = opened.snapshot.meshes[0]?.id ?? "mesh:missing";
|
||||
const attempt = await client.applyCommand({ type: "setGeometryNodeGraph", meshId, graph: unsupported, baseRevision: opened.snapshot.revision } as any).then(() => ({ code: "NO_ERROR" })).catch((error: any) => ({ code: error?.code, message: error?.message }));
|
||||
const after = await client.snapshot();
|
||||
const saved = await client.saveBlend();
|
||||
const savedSha256 = await digest(saved.slice(0));
|
||||
const reopened = await reopenedClient.openBlend(saved.slice(0));
|
||||
const hashesAfter = (reopened.snapshot.geometryNodeGraphs ?? []).map((graph: any) => ({ name: graph.name, graphHash: graph.graphHash, nodes: graph.nodes.map((node: any) => node.type).sort(), links: graph.links.length }));
|
||||
return { baseRevision: opened.snapshot.revision, afterRevision: after.snapshot.revision, graphCount: graphs.length, hashesBefore, hashesAfter, unsupportedName: unsupported.name, attempt, savedSha256, sourceSha256: await digest(Uint8Array.from(input.bytes).buffer), saveReopenExact: JSON.stringify(hashesBefore) === JSON.stringify(hashesAfter) };
|
||||
}
|
||||
finally { client.terminate(); reopenedClient.terminate(); }
|
||||
}, { bytes: Array.from(fixture) });
|
||||
fs.mkdirSync(evidenceRoot, { recursive: true });
|
||||
const output = process.env.WBV2_GEOMETRY_NODES_REPORT ?? "geometry-nodes-production.json";
|
||||
fs.writeFileSync(path.join(evidenceRoot, output), `${JSON.stringify({ schemaVersion: 1, task: "WBV2-P13-002", operation: "GEOMETRY_NODES_ENGINE_CHROMIUM", browser: "chromium", queueMutation: false, ...result }, null, 2)}\n`);
|
||||
expect(result.sourceSha256).toBe(sourceSha256);
|
||||
expect(result.graphCount).toBeGreaterThanOrEqual(2);
|
||||
expect(result.hashesBefore.length).toBe(result.hashesAfter.length);
|
||||
expect(result.hashesBefore.every((entry) => /^[a-f0-9]{64}$/u.test(entry.graphHash ?? ""))).toBe(true);
|
||||
expect(result.saveReopenExact).toBe(true);
|
||||
expect(result.afterRevision).toBe(result.baseRevision);
|
||||
expect(result.attempt.code).not.toBe("NO_ERROR");
|
||||
});
|
||||
62
web/tests/e2e/wbv2-rig-pose-production.spec.ts
Normal file
62
web/tests/e2e/wbv2-rig-pose-production.spec.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
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 evidenceRoot = path.join(root, "tests/golden/WBV2-P13-003");
|
||||
const fixture = fs.readFileSync(path.join(root, "tests/files/web/generated/WBV2-P3-003-RIG.POSE_SKIN.blend"));
|
||||
const sourceSha256 = crypto.createHash("sha256").update(fixture).digest("hex");
|
||||
|
||||
test("WBV2-P13-003 binds rig pose and skin evidence to compiled WASM Main", 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 shape = (error: any) => ({ code: error?.code, message: error?.message });
|
||||
const digest = async (value: ArrayBuffer): Promise<string> => { const hash = await crypto.subtle.digest("SHA-256", value); return Array.from(new Uint8Array(hash), (byte) => byte.toString(16).padStart(2, "0")).join(""); };
|
||||
const rigSummary = (snapshot: any) => {
|
||||
const armature: any = snapshot.armatures?.find((candidate: any) => candidate.id === "armature:WBV2P3003Armature");
|
||||
const mesh: any = snapshot.meshes?.find((candidate: any) => candidate.id === "mesh:WBV2P3003SkinnedMesh");
|
||||
if (!armature || !mesh) throw new Error("rig fixture missing armature or skinned mesh");
|
||||
return { armatureId: armature.id, bones: armature.bones.map((bone: any) => ({ id: bone.id, name: bone.name, parentId: bone.parentId, head: bone.head, tail: bone.tail, poseMatrix: bone.poseMatrix })), meshId: mesh.id, vertexCount: mesh.vertexCount, skinWeights: mesh.skinWeights ? { boneNames: mesh.skinWeights.boneNames, armatureId: mesh.skinWeights.armatureId, jointIds: mesh.skinWeights.jointIds } : null, shapeKeyCount: mesh.shapeKeys?.length ?? 0 };
|
||||
};
|
||||
try {
|
||||
const opened = await client.openBlend(Uint8Array.from(input.bytes).buffer);
|
||||
const objectId = "object:WBV2P3003SkinnedMeshObject";
|
||||
const constraintName = "WBV2P3003BoundedObjectConstraint";
|
||||
const before = rigSummary(opened.snapshot);
|
||||
const edited = await client.applyCommand({ type: "setConstraint", objectId, constraintName, enabled: false, influence: 0.4, baseRevision: opened.snapshot.revision } as any);
|
||||
const after = rigSummary(edited.snapshot);
|
||||
const malformed = await client.applyCommand({ type: "setConstraint", objectId, constraintName: "constraint:missing", enabled: true, influence: 0.4, baseRevision: edited.snapshot.revision } as any).then(() => ({ code: "NO_ERROR" })).catch(shape);
|
||||
const afterMalformed = rigSummary((await client.snapshot()).snapshot);
|
||||
const saved = await client.saveBlend();
|
||||
const savedSha256 = await digest(saved.slice(0));
|
||||
const reopened = await reopenedClient.openBlend(saved.slice(0));
|
||||
const reopenedSummary = rigSummary(reopened.snapshot);
|
||||
const reopenedConstraint = reopened.snapshot.nodes.find((node: any) => node.id === objectId)?.constraints?.find((constraint: any) => constraint.name === constraintName);
|
||||
return { baseRevision: opened.snapshot.revision, editedRevision: edited.snapshot.revision, before, after, afterMalformed, malformed, reopened: reopenedSummary, reopenedConstraint, savedSha256, sourceSha256: await digest(Uint8Array.from(input.bytes).buffer), saveReopenExact: JSON.stringify(after) === JSON.stringify(reopenedSummary) };
|
||||
}
|
||||
finally { client.terminate(); reopenedClient.terminate(); }
|
||||
}, { bytes: Array.from(fixture) });
|
||||
fs.mkdirSync(evidenceRoot, { recursive: true });
|
||||
const output = process.env.WBV2_RIG_POSE_REPORT ?? "rig-pose-production.json";
|
||||
fs.writeFileSync(path.join(evidenceRoot, output), `${JSON.stringify({ schemaVersion: 1, task: "WBV2-P13-003", operation: "RIG_POSE_ENGINE_CHROMIUM", browser: "chromium", queueMutation: false, ...result }, null, 2)}\n`);
|
||||
expect(result.sourceSha256).toBe(sourceSha256);
|
||||
expect(result.before.armatureId).toBe("armature:WBV2P3003Armature");
|
||||
expect(result.before.bones).toHaveLength(2);
|
||||
expect(result.before.meshId).toBe("mesh:WBV2P3003SkinnedMesh");
|
||||
expect(result.before.skinWeights?.armatureId).toBe("armature:WBV2P3003Armature");
|
||||
expect(result.before.shapeKeyCount).toBeGreaterThanOrEqual(1);
|
||||
expect(result.editedRevision).toBe(result.baseRevision + 1);
|
||||
expect(result.after).toEqual(result.before);
|
||||
expect(result.afterMalformed).toEqual(result.after);
|
||||
expect(result.malformed.code).not.toBe("NO_ERROR");
|
||||
expect(result.reopened).toEqual(result.after);
|
||||
expect(result.reopenedConstraint.enabled).toBe(false);
|
||||
expect(result.reopenedConstraint.influence).toBeCloseTo(0.4, 5);
|
||||
expect(result.saveReopenExact).toBe(true);
|
||||
expect(result.savedSha256).not.toBe(result.sourceSha256);
|
||||
});
|
||||
Reference in New Issue
Block a user