Checkpoint web parity through Chromium input tasks
This commit is contained in:
42
web/tests/e2e/glb-desktop-import.spec.ts
Normal file
42
web/tests/e2e/glb-desktop-import.spec.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const report = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-06A/desktop-fixtures.json"), "utf8"));
|
||||
const fixtureRoot = path.join(root, "tests/files/web/m12_glb_desktop_v1");
|
||||
|
||||
test("imports the M12-06A desktop GLB fixture group in a Chromium Worker", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
const fixtures = report.fixtures.map((fixture: { id: string; file: string; sha256: string; semantic: unknown }) => ({
|
||||
id: fixture.id,
|
||||
bytes: Array.from(fs.readFileSync(path.join(fixtureRoot, fixture.file))),
|
||||
sourceSha256: fixture.sha256,
|
||||
expected: fixture.semantic,
|
||||
}));
|
||||
const result = await page.evaluate(async (input) => new Promise<Record<string, unknown>>((resolve, reject) => {
|
||||
const worker = new Worker("/src/workers/glb-desktop-import-test.worker.ts", { type: "module" });
|
||||
worker.onmessage = (event: MessageEvent<Record<string, unknown>>) => {
|
||||
worker.terminate();
|
||||
resolve(event.data);
|
||||
};
|
||||
worker.onerror = (event) => {
|
||||
worker.terminate();
|
||||
reject(new Error(event.message));
|
||||
};
|
||||
const transferred = input.map((fixture) => {
|
||||
const bytes = Uint8Array.from(fixture.bytes);
|
||||
return { ...fixture, bytes: bytes.buffer };
|
||||
});
|
||||
worker.postMessage({ fixtures: transferred }, transferred.map((fixture) => fixture.bytes));
|
||||
}), fixtures);
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
expect(result.results).toEqual([
|
||||
{ id: "mesh", sourceSha256: report.fixtures[0].sha256, compatible: true, mismatches: [], topology: 1, attributes: ["COLOR_0", "NORMAL", "POSITION"], materials: 1, nodes: 1, animations: 0 },
|
||||
{ id: "pbr", sourceSha256: report.fixtures[1].sha256, compatible: true, mismatches: [], topology: 1, attributes: ["NORMAL", "POSITION"], materials: 1, nodes: 1, animations: 0 },
|
||||
{ id: "uv", sourceSha256: report.fixtures[2].sha256, compatible: true, mismatches: [], topology: 1, attributes: ["NORMAL", "POSITION", "TEXCOORD_0"], materials: 1, nodes: 1, animations: 0 },
|
||||
{ id: "skin", sourceSha256: report.fixtures[3].sha256, compatible: true, mismatches: [], topology: 1, attributes: ["JOINTS_0", "NORMAL", "POSITION", "WEIGHTS_0"], materials: 1, nodes: 4, animations: 0 },
|
||||
{ id: "animation", sourceSha256: report.fixtures[4].sha256, compatible: true, mismatches: [], topology: 1, attributes: ["NORMAL", "POSITION"], materials: 1, nodes: 1, animations: 1 },
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user