chore(web): continuous handoff WBV2-P1283-001
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

This commit is contained in:
mes123456
2026-09-05 06:10:21 +08:00
parent 7d015fe6a6
commit 06ba2a7c9c
13 changed files with 31293 additions and 4 deletions

View File

@@ -0,0 +1,55 @@
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/basic_scene.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-OBJECT-TRANSFORM-CLEAR";
const productionPath = process.env.WBV2_BATCH_PRODUCTION ?? `tests/golden/${task}/object-transform-clear-production.json`;
const sourceUnits = JSON.parse(process.env.WBV2_BATCH_UNITS ?? "[\"operator:OBJECT_OT_location_clear\"]") as string[];
const clearMode = process.env.WBV2_BATCH_CLEAR_MODE ?? "LOCATION";
test("native object transform clear batch preserves Main recovery semantics", async ({ page }) => {
await page.goto("/");
const result = await page.evaluate(async ({ bytes, clearMode }) => {
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 object: any = opened.snapshot.nodes.find((node: any) => node.type === "MESH");
if (!object) throw new Error("basic scene has no mesh object");
const translation = object.transform?.translation ?? object.translation ?? [0, 0, 0];
const rotationEuler = object.transform?.rotationEuler ?? object.rotationEuler ?? [0, 0, 0];
const scale = object.transform?.scale ?? object.scale ?? [1, 1, 1];
const next = { translation: clearMode === "LOCATION" ? [0, 0, 0] : translation, rotationEuler: clearMode === "ROTATION" ? [0, 0, 0] : rotationEuler, scale: clearMode === "SCALE" ? [1, 1, 1] : scale };
const changed = await client.applyCommand({ type: "setObjectTransform", objectId: object.id, ...next, baseRevision: opened.snapshot.revision } as any);
const undo = await client.applyCommand({ type: "undo" });
const redo = await client.applyCommand({ type: "redo" });
const malformed = await client.applyCommand({ type: "setObjectTransform", objectId: "object:missing", ...next, 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 restoredObject: any = restored.snapshot.nodes.find((node: any) => node.id === object.id);
const actual = (node: any) => ({ translation: node.transform?.translation ?? node.translation, rotationEuler: node.transform?.rotationEuler ?? node.rotationEuler, scale: node.transform?.scale ?? node.scale });
return { browser: "chromium", baseRevision: opened.snapshot.revision, changedRevision: changed.snapshot.revision, undoRevision: undo.snapshot.revision, redoRevision: redo.snapshot.revision, before: actual(object), after: actual(changed.snapshot.nodes.find((node: any) => node.id === object.id)), restored: actual(restoredObject), malformed, malformedRevisionPreserved: afterMalformed.snapshot.revision === redo.snapshot.revision, reopenedRevision: restored.snapshot.revision };
} finally { client.terminate(); reopened.terminate(); }
}, { bytes: Array.from(fixture), clearMode });
fs.mkdirSync(path.dirname(path.join(root, productionPath)), { recursive: true });
fs.writeFileSync(path.join(root, productionPath), `${JSON.stringify({ schemaVersion: 1, task, operation: `OBJECT_${clearMode}_CLEAR_ENGINE_CHROMIUM`, browser: "chromium", queueMutation: false, fixture: fixturePath, fixtureSha256, sourceUnits, ...result }, null, 2)}\n`);
expect(result.browser).toBe("chromium");
expect(result.changedRevision).toBe(result.baseRevision + 1);
expect(result.undoRevision).toBe(result.baseRevision + 2);
expect(result.redoRevision).toBe(result.baseRevision + 3);
if (clearMode === "LOCATION") expect(result.after.translation).toEqual([0, 0, 0]);
if (clearMode === "ROTATION") expect(result.after.rotationEuler).toEqual([0, 0, 0]);
if (clearMode === "SCALE") expect(result.after.scale).toEqual([1, 1, 1]);
expect(result.after).toEqual(result.restored);
expect(result.malformed.code).not.toBe("NO_ERROR");
expect(result.malformedRevisionPreserved).toBe(true);
expect(result.reopenedRevision).toBe(1);
});