Files
hyperframes/packages/cli/src/browser/gpuPolicy.test.ts
T
James Russo 3a6b7f0612 fix: align local WebGPU capture behavior (#2907)
* fix: align local WebGPU capture behavior

* fix: address WebGPU capture review feedback

* fix: retain overlapping GPU seek work

* fix: satisfy runtime seek completion types

* fix: drain concurrent GPU seek work

* fix: prevent WebGPU capture barrier starvation

* fix: keep WebGPU presentation active during render seeks
2026-07-30 21:52:30 -07:00

35 lines
1.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
assertWebGpuRequirement,
compositionRequiresWebGpu,
resolveLocalBrowserGpuMode,
} from "./gpuPolicy.js";
describe("local browser GPU policy", () => {
it("defaults to auto and preserves explicit CLI/env overrides", () => {
expect(resolveLocalBrowserGpuMode(undefined, undefined)).toBe("auto");
expect(resolveLocalBrowserGpuMode(undefined, "hardware")).toBe("hardware");
expect(resolveLocalBrowserGpuMode(undefined, "software")).toBe("software");
expect(resolveLocalBrowserGpuMode(true, "software")).toBe("hardware");
expect(resolveLocalBrowserGpuMode(false, "hardware")).toBe("software");
});
it("detects the explicit WebGPU capability marker on the composition root", () => {
expect(
compositionRequiresWebGpu(
'<div data-requires-webgpu data-composition-id="gpu" data-duration="2"></div>',
),
).toBe(true);
expect(compositionRequiresWebGpu('<div data-composition-id="dom"></div>')).toBe(false);
});
it("rejects an auto software fallback for required WebGPU compositions", () => {
const html = '<div data-composition-id="gpu" data-requires-webgpu></div>';
expect(() => assertWebGpuRequirement(html, "auto", "software")).toThrow(
"PRODUCER_BROWSER_GPU_MODE=hardware",
);
expect(() => assertWebGpuRequirement(html, "hardware", "hardware")).not.toThrow();
expect(() => assertWebGpuRequirement(html, "software", "software")).not.toThrow();
});
});