mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-13 07:40:06 +00:00
* perf(studio): schedule adaptive timeline thumbnails * perf(studio): bound thumbnail decoding resources * perf(studio): virtualize timeline thumbnail media * perf(studio): prioritize timeline thumbnail work * perf(studio-server): coordinate cancelable thumbnail generation --------- Co-authored-by: Codex <codex@local>
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
// @vitest-environment happy-dom
|
|
|
|
import React, { act } from "react";
|
|
import { createRoot } from "react-dom/client";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
const { leaseSpy } = vi.hoisted(() => ({
|
|
leaseSpy: vi.fn((_request: unknown) => ({ status: "loading" as const })),
|
|
}));
|
|
|
|
vi.mock("../../hooks/useThumbnailLease", () => ({
|
|
useThumbnailLease: leaseSpy,
|
|
}));
|
|
|
|
import { AudioWaveform } from "./AudioWaveform";
|
|
|
|
(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
|
|
afterEach(() => {
|
|
leaseSpy.mockClear();
|
|
document.body.innerHTML = "";
|
|
});
|
|
|
|
describe("AudioWaveform", () => {
|
|
it("leases waveform decoding with the clip's project, session, and viewport priority", () => {
|
|
const host = document.createElement("div");
|
|
document.body.append(host);
|
|
const root = createRoot(host);
|
|
|
|
act(() => {
|
|
root.render(
|
|
<AudioWaveform
|
|
audioUrl="/media/voice.wav"
|
|
label=""
|
|
labelColor="#fff"
|
|
projectId="project-a"
|
|
sessionEpoch={9}
|
|
priority="interaction"
|
|
/>,
|
|
);
|
|
});
|
|
|
|
expect(leaseSpy).toHaveBeenCalled();
|
|
expect(leaseSpy.mock.calls.at(-1)?.[0]).toMatchObject({
|
|
projectId: "project-a",
|
|
sessionEpoch: 9,
|
|
kind: "waveform",
|
|
priority: "interaction",
|
|
rich: false,
|
|
});
|
|
|
|
act(() => root.unmount());
|
|
});
|
|
});
|