Files
workinf_Blender_Wasm/web/tests/e2e/wasm-threading-capability.spec.ts
2026-08-15 01:01:23 -04:00

42 lines
2.0 KiB
TypeScript

import { expect, test } from "@playwright/test";
test("gates only the pthread WASM engine on its three platform requirements", async ({ page }) => {
await page.goto("/");
const gates = await page.evaluate(async () => {
const { gateWasmThreadingCapability } = await import("/src/platform/capabilities.ts");
return {
ready: gateWasmThreadingCapability({ crossOriginIsolated: true, sharedArrayBuffer: true, worker: true }),
noIsolation: gateWasmThreadingCapability({ crossOriginIsolated: false, sharedArrayBuffer: true, worker: true }),
noSharedArrayBuffer: gateWasmThreadingCapability({ crossOriginIsolated: true, sharedArrayBuffer: false, worker: true }),
noWorker: gateWasmThreadingCapability({ crossOriginIsolated: true, sharedArrayBuffer: true, worker: false }),
none: gateWasmThreadingCapability({ crossOriginIsolated: false, sharedArrayBuffer: false, worker: false }),
};
});
expect(gates.ready).toEqual({
taskId: "M6-02",
capability: "WASM_PTHREAD_ENGINE",
status: "READY",
issues: [],
});
expect(gates.noIsolation.issues.map(({ code, path }) => ({ code, path }))).toEqual([
{ code: "PLATFORM_CAPABILITY_UNAVAILABLE", path: "crossOriginIsolated" },
]);
expect(gates.noSharedArrayBuffer.issues.map(({ code, path }) => ({ code, path }))).toEqual([
{ code: "PLATFORM_CAPABILITY_UNAVAILABLE", path: "sharedArrayBuffer" },
]);
expect(gates.noWorker.issues.map(({ code, path }) => ({ code, path }))).toEqual([
{ code: "PLATFORM_CAPABILITY_UNAVAILABLE", path: "worker" },
]);
expect(gates.none).toMatchObject({
taskId: "M6-02",
capability: "WASM_PTHREAD_ENGINE",
status: "BLOCKED",
});
expect(gates.none.issues.map(({ code, path }) => ({ code, path }))).toEqual([
{ code: "PLATFORM_CAPABILITY_UNAVAILABLE", path: "crossOriginIsolated" },
{ code: "PLATFORM_CAPABILITY_UNAVAILABLE", path: "sharedArrayBuffer" },
{ code: "PLATFORM_CAPABILITY_UNAVAILABLE", path: "worker" },
]);
});