mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
* feat(producer): report browser-computed reference backgrounds Preserve one initial root/page reference across local, streamed and distributed render results without guessing from film pixels. — Jerrai * fix(producer): preserve plan compatibility and optional inspection Keep reference metadata outside the v2 manifest hash and read it from the verified execution-plan artifact. Static planning uses a non-gating page inspection instead of requiring render-worker capabilities. — Jerrai * fix(producer): poll readiness independently of animation frames Use timed polling while the render clock parks animation frames. Cover readiness that changes after the first check with a short real-browser regression. — Jerrai * fix(producer): budget measured reference metadata runtime growth Producer adds 2,228 compressed bytes over current main. Tests, fixtures and source maps are already absent from its dist-only tarball. Allow 7,766 bytes of headroom above the verified 837,234-byte payload while retaining the unpacked limit. — Jerrai
82 lines
3.3 KiB
TypeScript
82 lines
3.3 KiB
TypeScript
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
import type { Browser } from "puppeteer-core";
|
|
import { resolveHeadlessShellPath } from "./browserManager.js";
|
|
import { closeTestChrome, launchTestChrome } from "./__fixtures__/loopback.js";
|
|
import { readReferenceBackground } from "./referenceBackground.js";
|
|
import { initTransparentBackground } from "./screenshotService.js";
|
|
|
|
const chromePath = process.env.HF_REFERENCE_TEST_CHROME ?? resolveHeadlessShellPath();
|
|
|
|
describe.skipIf(!chromePath)("browser-computed reference background", () => {
|
|
let browser: Browser;
|
|
beforeAll(async () => {
|
|
browser = await launchTestChrome(chromePath);
|
|
});
|
|
afterAll(() => closeTestChrome(browser));
|
|
|
|
it.each([
|
|
["body { background: rgb(10 46 138); }", { kind: "solid", rgb: [10, 46, 138] }],
|
|
[
|
|
"body { background: blue !important; } #film { background: rgb(10 46 138); }",
|
|
{ kind: "solid", rgb: [10, 46, 138] },
|
|
],
|
|
[
|
|
"body { --film-bg: rgb(10 46 138); background: var(--film-bg); }",
|
|
{ kind: "solid", rgb: [10, 46, 138] },
|
|
],
|
|
[
|
|
"#film { background: red !important; } [data-composition-id] { background: blue !important; }",
|
|
{ kind: "solid", rgb: [255, 0, 0] },
|
|
],
|
|
["body { background: none; }", { kind: "none" }],
|
|
["", { kind: "unknown" }],
|
|
["body { background-color: transparent; }", { kind: "unknown" }],
|
|
[
|
|
"body { background: linear-gradient(red, blue); background-color: white; }",
|
|
{ kind: "unsupported_non_solid" },
|
|
],
|
|
[
|
|
"body { background-image: url(data:image/png;base64,broken); background-color: white; }",
|
|
{ kind: "unsupported_non_solid" },
|
|
],
|
|
["body { background-color: var(--unresolved); }", { kind: "unknown" }],
|
|
])("reads the real cascade: %s", async (css, expected) => {
|
|
const page = await browser.newPage();
|
|
try {
|
|
await page.setContent(
|
|
`<style>${css}</style><body><div id="film" data-composition-id="film" data-duration="1"></div></body>`,
|
|
);
|
|
expect(await readReferenceBackground(page)).toEqual(expected);
|
|
} finally {
|
|
await page.close();
|
|
}
|
|
});
|
|
|
|
it("does not call a known animated background stable", async () => {
|
|
const page = await browser.newPage();
|
|
try {
|
|
await page.setContent(`<body style="background:blue"><div data-composition-id="film"></div><script>
|
|
window.__timelines = { film: { getChildren: () => [{ vars: { backgroundColor: 'red' }, targets: () => [document.body] }] } };
|
|
</script></body>`);
|
|
expect(await readReferenceBackground(page)).toEqual({ kind: "unknown" });
|
|
} finally {
|
|
await page.close();
|
|
}
|
|
});
|
|
|
|
it("uses the canonical initial JS state before transparent capture changes it", async () => {
|
|
const page = await browser.newPage();
|
|
try {
|
|
await page.setContent(`<body style="background: red"><div data-composition-id="film"></div><script>
|
|
window.__hf = { seek: (t) => { document.body.style.background = t === 0 ? 'rgb(10 46 138)' : 'yellow'; } };
|
|
</script></body>`);
|
|
const reference = await readReferenceBackground(page);
|
|
await initTransparentBackground(page);
|
|
expect(reference).toEqual({ kind: "solid", rgb: [10, 46, 138] });
|
|
expect(await readReferenceBackground(page)).toEqual({ kind: "unknown" });
|
|
} finally {
|
|
await page.close();
|
|
}
|
|
});
|
|
});
|