Files
hyperframes/packages/cli/src/utils/compositionServer.test.ts
T
Miguel Ángel 3e16603d37 fix(render): a PNG's colour tags no longer change its pixels in preview, check, snapshot or render (#6453)
* fix(render): a PNG's colour tags no longer change its pixels in preview, check, snapshot or render

* fix(render): the play and present server also serves a PNG without its colour tags

* fix(render): bundled pages inline a PNG without its colour tags too
2026-10-26 17:48:57 +00:00

33 lines
1.1 KiB
TypeScript

import { afterEach, describe, expect, it } from "vitest";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { buildRangeResponse } from "./compositionServer.js";
const TAGGED_PNG = Buffer.from(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAABGNJQ1ABAQABlXPCVgAAAAxJREFUeJxj0NfXBwABHgCOTp25kgAAAABJRU5ErkJggg==",
"base64",
);
let dir: string | undefined;
afterEach(() => {
if (dir) rmSync(dir, { recursive: true, force: true });
dir = undefined;
});
describe("buildRangeResponse colour-tagged PNGs", () => {
it("serves a BT.709-tagged PNG without the tag, so play and present show the file's values", async () => {
dir = mkdtempSync(join(tmpdir(), "hf-composition-server-"));
const file = join(dir, "tagged.png");
writeFileSync(file, TAGGED_PNG);
const res = buildRangeResponse(file, "image/png", undefined);
const body = Buffer.from(await res.arrayBuffer());
expect(body.includes("cICP")).toBe(false);
expect(body.includes("IDAT")).toBe(true);
expect(res.headers.get("content-length")).toBe(String(body.length));
});
});