chore(web): continuous handoff WBV2-P1158-001
This commit is contained in:
77
web/tests/e2e/wbv2-line-style-reader-production.spec.ts
Normal file
77
web/tests/e2e/wbv2-line-style-reader-production.spec.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
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 task = process.env.WBV2_BATCH_TASK ?? "WBV2-P1158-001";
|
||||
const fixture = "tests/files/web/generated/M16-GAP-00008-datablock-FreestyleLineStyle.blend";
|
||||
const fixtureBytes = fs.readFileSync(path.join(root, fixture));
|
||||
const fixtureSha256 = crypto.createHash("sha256").update(fixtureBytes).digest("hex");
|
||||
const sourceUnits = JSON.parse(process.env.WBV2_BATCH_UNITS ?? '["rna-struct:FreestyleLineStyle","rna-struct:LineStyleModifier","rna-struct:LineStyleAlphaModifier","rna-struct:LineStyleColorModifier","rna-struct:LineStyleGeometryModifier","rna-struct:LineStyleThicknessModifier"]');
|
||||
|
||||
test("line style reader preserves Blender Main style metadata", async ({ page }) => {
|
||||
test.setTimeout(180_000);
|
||||
await page.goto("/");
|
||||
const result = await page.evaluate(async (bytes) => {
|
||||
const { WebEngineClient } = await import("/src/engine-client/WebEngineClient.ts");
|
||||
const canonical = (snapshot: any) => (snapshot.lineStyles ?? []).map((style: any) => ({
|
||||
id: style.id,
|
||||
name: style.name,
|
||||
color: style.color,
|
||||
alpha: style.alpha,
|
||||
thickness: style.thickness,
|
||||
geometry: style.geometry,
|
||||
}));
|
||||
const client = new WebEngineClient({ timeoutMs: 60_000 });
|
||||
const reopenedClient = new WebEngineClient({ timeoutMs: 60_000 });
|
||||
const secondClient = new WebEngineClient({ timeoutMs: 60_000 });
|
||||
const output: any = {};
|
||||
try {
|
||||
const opened = await client.openBlend(Uint8Array.from(bytes).buffer);
|
||||
output.before = canonical(opened.snapshot);
|
||||
output.styleCount = output.before.length;
|
||||
const saved = await client.saveBlend();
|
||||
output.after = canonical((await reopenedClient.openBlend(saved.slice(0))).snapshot);
|
||||
output.second = canonical((await secondClient.openBlend(Uint8Array.from(bytes).buffer)).snapshot);
|
||||
output.saveReopenExact = JSON.stringify(output.before) === JSON.stringify(output.after);
|
||||
output.deterministicExact = JSON.stringify(output.before) === JSON.stringify(output.second);
|
||||
output.savedSha256 = await crypto.subtle.digest("SHA-256", saved).then((hash) =>
|
||||
Array.from(new Uint8Array(hash), (byte) => byte.toString(16).padStart(2, "0")).join(""));
|
||||
try {
|
||||
await client.openBlend(Uint8Array.from([0x42, 0x4c, 0x45, 0x4e, 0x44]).buffer);
|
||||
output.malformed = { code: "ACCEPTED_MALFORMED" };
|
||||
} catch (error: any) {
|
||||
output.malformed = { code: error?.code, message: error?.message };
|
||||
}
|
||||
} catch (error: any) {
|
||||
output.error = { code: error?.code, message: error?.message, detail: String(error) };
|
||||
} finally {
|
||||
client.terminate();
|
||||
reopenedClient.terminate();
|
||||
secondClient.terminate();
|
||||
}
|
||||
return output;
|
||||
}, Array.from(fixtureBytes));
|
||||
|
||||
const report = {
|
||||
schemaVersion: 1,
|
||||
task,
|
||||
operation: "LINE_STYLE_READER_CHROMIUM_SAVE_REOPEN",
|
||||
browser: "chromium",
|
||||
queueMutation: false,
|
||||
fixture,
|
||||
fixtureSha256,
|
||||
sourceUnits,
|
||||
...result,
|
||||
};
|
||||
const outputPath = path.join(root, `tests/golden/${task}/line-style-reader-production.json`);
|
||||
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
||||
fs.writeFileSync(outputPath, `${JSON.stringify(report, null, 2)}\n`);
|
||||
|
||||
expect(result.error).toBeUndefined();
|
||||
expect(result.styleCount).toBeGreaterThan(0);
|
||||
expect(result.saveReopenExact).toBe(true);
|
||||
expect(result.deterministicExact).toBe(true);
|
||||
expect(result.malformed?.code).not.toBe("ACCEPTED_MALFORMED");
|
||||
});
|
||||
Reference in New Issue
Block a user