fix(web): recover material slot remove batch contracts
This commit is contained in:
@@ -10,6 +10,7 @@ const fixtureSha256 = crypto.createHash("sha256").update(fixture).digest("hex");
|
||||
const task = process.env.WBV2_BATCH_TASK ?? "WBV2-P1100-003";
|
||||
const productionPath = process.env.WBV2_BATCH_PRODUCTION ?? `tests/golden/${task}/material-slot-production.json`;
|
||||
const sourceUnits = JSON.parse(process.env.WBV2_BATCH_UNITS ?? "[\"operator:OBJECT_OT_material_slot_add\"]") as string[];
|
||||
const slotOperation = process.env.WBV2_BATCH_SLOT_OPERATION ?? "ADD";
|
||||
|
||||
test("WBV2-P1100-003 preserves addMaterialSlot through Main recovery and reopen", async ({ page }) => {
|
||||
test.setTimeout(180_000);
|
||||
@@ -25,10 +26,11 @@ test("WBV2-P1100-003 preserves addMaterialSlot through Main recovery and reopen"
|
||||
if (!object) throw new Error("basic scene has no mesh object");
|
||||
const before = materialNames(opened.snapshot);
|
||||
const added = await client.applyCommand({ type: "addMaterialSlot", objectId: object.id, name: "WebSlotMaterial" } as any);
|
||||
const afterAdd = materialNames(added.snapshot);
|
||||
const removed = input.slotOperation === "REMOVE" ? await client.applyCommand({ type: "removeMaterialSlot", objectId: object.id, slotIndex: (added.snapshot.nodes.find((node: any) => node.id === object.id)?.materialSlotIds?.length ?? 1) - 1 } as any) : added;
|
||||
const afterAdd = materialNames(removed.snapshot);
|
||||
const undo = await client.applyCommand({ type: "undo" } as any);
|
||||
const redo = await client.applyCommand({ type: "redo" } as any);
|
||||
const malformed = await client.applyCommand({ type: "addMaterialSlot", objectId: "object:missing", name: "Bad" } as any).then(() => ({ code: "NO_ERROR" })).catch((error: any) => ({ code: error?.code, message: error?.message }));
|
||||
const malformed = await client.applyCommand({ type: input.slotOperation === "REMOVE" ? "removeMaterialSlot" : "addMaterialSlot", objectId: "object:missing", ...(input.slotOperation === "REMOVE" ? { slotIndex: 0 } : { name: "Bad" }) } 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 reopened = await reopenedClient.openBlend(saved.slice(0));
|
||||
@@ -36,15 +38,21 @@ test("WBV2-P1100-003 preserves addMaterialSlot through Main recovery and reopen"
|
||||
}
|
||||
catch (error: any) { return { error: { code: error?.code, message: error?.message, detail: String(error) } } as any; }
|
||||
finally { client.terminate(); reopenedClient.terminate(); }
|
||||
}, { bytes: Array.from(fixture), fixtureSha256 });
|
||||
}, { bytes: Array.from(fixture), fixtureSha256, slotOperation });
|
||||
fs.mkdirSync(path.dirname(path.join(root, productionPath)), { recursive: true });
|
||||
fs.writeFileSync(path.join(root, productionPath), `${JSON.stringify({ schemaVersion: 1, task, operation: "MATERIAL_SLOT_MAIN_CHROMIUM", browser: "chromium", queueMutation: false, fixture: fixturePath, fixtureSha256, sourceUnits, ...result }, null, 2)}\n`);
|
||||
fs.writeFileSync(path.join(root, productionPath), `${JSON.stringify({ schemaVersion: 1, task, operation: `MATERIAL_SLOT_${slotOperation}_MAIN_CHROMIUM`, browser: "chromium", queueMutation: false, fixture: fixturePath, fixtureSha256, sourceUnits, ...result }, null, 2)}\n`);
|
||||
expect(result.error).toBeUndefined();
|
||||
expect(result.fixtureSha256).toBe(fixtureSha256);
|
||||
expect(result.afterAdd).toContain("WebSlotMaterial");
|
||||
if (slotOperation === "REMOVE") expect(result.afterAdd).not.toContain("WebSlotMaterial");
|
||||
else expect(result.afterAdd).toContain("WebSlotMaterial");
|
||||
expect(result.addRevision).toBe(result.beforeRevision + 1);
|
||||
expect(result.undo).toEqual(result.before);
|
||||
expect(result.redo).toEqual(result.afterAdd);
|
||||
if (slotOperation === "REMOVE") {
|
||||
expect(result.undo).toContain("WebSlotMaterial");
|
||||
expect(result.redo).not.toContain("WebSlotMaterial");
|
||||
} else {
|
||||
expect(result.undo).toEqual(result.before);
|
||||
expect(result.redo).toEqual(result.afterAdd);
|
||||
}
|
||||
expect(result.malformed.code).not.toBe("NO_ERROR");
|
||||
expect(result.malformedRevisionPreserved).toBe(true);
|
||||
expect(result.reopened).toEqual(result.afterAdd);
|
||||
|
||||
Reference in New Issue
Block a user