chore(web): continuous handoff WBV2-P1163-001
This commit is contained in:
75
web/tests/e2e/compositor-main-reader-production.spec.ts
Normal file
75
web/tests/e2e/compositor-main-reader-production.spec.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
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/m11_compositor_allowlist.blend";
|
||||
const fixture = fs.readFileSync(path.join(root, fixturePath));
|
||||
const fixtureSha256 = crypto.createHash("sha256").update(fixture).digest("hex");
|
||||
const expectedTypes = JSON.parse(process.env.WBV2_BATCH_TYPES ?? "[\"EXPOSURE\",\"INVERT\"]") as string[];
|
||||
const sourceUnits = JSON.parse(process.env.WBV2_BATCH_UNITS ?? "[\"node:CompositorNodeExposure\",\"node:CompositorNodeInvert\"]") as string[];
|
||||
const task = process.env.WBV2_BATCH_TASK ?? "WBV2-P1104-000";
|
||||
const productionPath = process.env.WBV2_BATCH_PRODUCTION ?? `tests/golden/${task}/compositor-main-reader-production.json`;
|
||||
|
||||
test("WBV2-P1104-000 reads compositor NodeTree and links from Blender Main without JS execution", async ({ page }) => {
|
||||
test.setTimeout(120_000);
|
||||
await page.goto("/");
|
||||
const result = await page.evaluate(async (bytes) => {
|
||||
const { WebEngineClient } = await import("/src/engine-client/WebEngineClient.ts");
|
||||
const summarize = (snapshot: any) => snapshot.scenes
|
||||
.filter((scene: any) => scene.compositorGraph)
|
||||
.map((scene: any) => ({
|
||||
id: scene.compositorGraph.id,
|
||||
name: scene.compositorGraph.name,
|
||||
nodeTypes: scene.compositorGraph.nodes.map((node: any) => node.blenderType ?? node.type).sort(),
|
||||
links: scene.compositorGraph.links.map((link: any) => ({ ...link })).sort((a: any, b: any) => JSON.stringify(a).localeCompare(JSON.stringify(b))),
|
||||
}));
|
||||
const client = new WebEngineClient({ timeoutMs: 60_000 });
|
||||
const reopenedClient = new WebEngineClient({ timeoutMs: 60_000 });
|
||||
try {
|
||||
const opened = await client.openBlend(Uint8Array.from(bytes).buffer);
|
||||
const graphs = summarize(opened.snapshot);
|
||||
if (graphs.length === 0 || graphs.every((graph: any) => graph.nodeTypes.length === 0)) throw new Error("Blender Main has no compositor graph");
|
||||
const saved = await client.saveBlend();
|
||||
const reopened = await reopenedClient.openBlend(saved.slice(0));
|
||||
return {
|
||||
browser: "chromium",
|
||||
fixtureSha256: await crypto.subtle.digest("SHA-256", Uint8Array.from(bytes)).then((hash) => Array.from(new Uint8Array(hash), (value) => value.toString(16).padStart(2, "0")).join("")),
|
||||
graphs,
|
||||
reopenedGraphs: summarize(reopened.snapshot),
|
||||
openedRevision: opened.snapshot.revision,
|
||||
reopenedRevision: reopened.snapshot.revision,
|
||||
};
|
||||
}
|
||||
finally {
|
||||
client.terminate();
|
||||
reopenedClient.terminate();
|
||||
}
|
||||
}, Array.from(fixture));
|
||||
fs.mkdirSync(path.dirname(path.join(root, productionPath)), { recursive: true });
|
||||
fs.writeFileSync(path.join(root, productionPath), `${JSON.stringify({
|
||||
schemaVersion: 1,
|
||||
task,
|
||||
operation: "COMPOSITOR_MAIN_READER_CHROMIUM",
|
||||
browser: "chromium",
|
||||
queueMutation: false,
|
||||
fixture: fixturePath,
|
||||
sourceUnits,
|
||||
expectedTypes,
|
||||
sourceRnaStructs: {
|
||||
"rna-struct:CompositorNodeTree": "scene.compositorGraph",
|
||||
"rna-struct:NodeTree": "scene.compositorGraph",
|
||||
"rna-struct:NodeLinks": "scene.compositorGraph.links",
|
||||
"rna-struct:NodeLink": "scene.compositorGraph.links[]",
|
||||
},
|
||||
...result,
|
||||
}, null, 2)}\n`);
|
||||
expect(result.fixtureSha256).toBe(fixtureSha256);
|
||||
expect(result.graphs.length).toBeGreaterThan(0);
|
||||
expect(result.graphs.some((graph: any) => graph.nodeTypes.length > 0)).toBe(true);
|
||||
const observedTypes = new Set(result.graphs.flatMap((graph: any) => graph.nodeTypes));
|
||||
for (const type of expectedTypes) expect(observedTypes.has(type)).toBe(true);
|
||||
expect(result.graphs).toEqual(result.reopenedGraphs);
|
||||
expect(result.reopenedRevision).toBe(1);
|
||||
});
|
||||
Reference in New Issue
Block a user