Files
hyperframes/packages/studio/src/player/components/AudioWaveform.test.tsx
T
Miguel ÁngelandCodex 96861cbafc perf(studio-server): coordinate cancelable thumbnail generation (#2720)
* 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>
2026-08-05 20:41:35 -07:00

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());
});
});