chore(web): continuous handoff WBV2-P1268-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-04 13:25:06 +08:00
parent 856bf629af
commit 8c2c3c319a
13 changed files with 28737 additions and 6 deletions

View File

@@ -4,8 +4,12 @@ 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 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-P17-002";
const productionPath = process.env.WBV2_BATCH_PRODUCTION ?? `tests/golden/${task}/object-duplicate-production.json`;
const sourceUnits = JSON.parse(process.env.WBV2_BATCH_UNITS ?? "[\"operator:OBJECT_OT_duplicate\"]") as string[];
test("WBV2-P17-002 binds duplicateObject to compiled WASM Main", async ({ page }) => {
test.setTimeout(120_000); await page.goto("/");
@@ -14,6 +18,6 @@ test("WBV2-P17-002 binds duplicateObject to compiled WASM Main", async ({ page }
const digest = async (value: ArrayBuffer): Promise<string> => { const hash = await crypto.subtle.digest("SHA-256", value); return Array.from(new Uint8Array(hash), (b) => b.toString(16).padStart(2, "0")).join(""); };
try { const opened = await client.openBlend(Uint8Array.from(bytes).buffer); const original = opened.snapshot.nodes.find((node) => node.id === opened.snapshot.activeObjectId && node.type === "MESH") ?? opened.snapshot.nodes.find((node) => node.type === "MESH"); if (!original) throw new Error("basic scene has no mesh object"); const beforeCount = opened.snapshot.nodes.length; const baseRevision = opened.snapshot.revision; const duplicated = await client.applyCommand({ type: "duplicateObject", objectId: original.id, offset: [2, 0, 0], linked: false } as any); const afterDuplicate = duplicated.snapshot; const duplicateNodes = afterDuplicate.nodes.filter((node) => node.type === "MESH"); const duplicate = duplicateNodes.find((node) => node.id !== original.id && Math.abs((node.translation?.[0] ?? 0) - ((original.translation?.[0] ?? 0) + 2)) < 1e-4); const undone = await client.applyCommand({ type: "undo" }); const redone = await client.applyCommand({ type: "redo" }); const malformed = await client.applyCommand({ type: "duplicateObject", objectId: "object:missing", offset: [1, 0, 0] } as any).then(() => ({ code: "NO_ERROR" })).catch((error: any) => ({ code: error?.code, message: error?.message })); const afterMalformed = await client.snapshot(); const saved = await client.saveBlend(); const reopen = await reopened.openBlend(saved); return { browser: "chromium", baseRevision, beforeCount, duplicateRevision: afterDuplicate.revision, undoRevision: undone.snapshot.revision, redoRevision: redone.snapshot.revision, afterCount: afterDuplicate.nodes.length, duplicateId: duplicate?.id, malformed, malformedRevisionPreserved: afterMalformed.snapshot.revision === redone.snapshot.revision, reopenedCount: reopen.snapshot.nodes.length, reopenedRevision: reopen.snapshot.revision, savedSha256: await digest(saved) }; } finally { client.terminate(); reopened.terminate(); }
}, Array.from(fixture));
fs.mkdirSync(path.join(root, "tests/golden/WBV2-P17-002"), { recursive: true }); const output = process.env.WBV2_OBJECT_REPORT ?? "object-duplicate-production.json"; fs.writeFileSync(path.join(root, "tests/golden/WBV2-P17-002", output), `${JSON.stringify({ schemaVersion: 1, task: "WBV2-P17-002", operation: "OBJECT_DUPLICATE_ENGINE_CHROMIUM", queueMutation: false, fixtureSha256, ...result }, null, 2)}\n`);
fs.mkdirSync(path.dirname(path.join(root, productionPath)), { recursive: true }); fs.writeFileSync(path.join(root, productionPath), `${JSON.stringify({ schemaVersion: 1, task, operation: "OBJECT_DUPLICATE_ENGINE_CHROMIUM", browser: "chromium", queueMutation: false, fixture: fixturePath, fixtureSha256, sourceUnits, ...result }, null, 2)}\n`);
expect(result.browser).toBe("chromium"); expect(result.afterCount).toBe(result.beforeCount + 1); expect(result.duplicateRevision).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.reopenedCount).toBe(result.afterCount); expect(result.reopenedRevision).toBe(1);
});