mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
* 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
33 lines
1.1 KiB
TypeScript
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));
|
|
});
|
|
});
|