Skip to content

Commit 847b76c

Browse files
committed
test(core): drive the early-start tests the way the runtime receives a seek and a speed
1 parent f3a93fb commit 847b76c

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎packages/core/src/runtime/init.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3236,16 +3236,21 @@ describe("initSandboxRuntimeModular", () => {
32363236
const { raf, startedAt } = mountLateSfx();
32373237
window.__player?.play();
32383238
raf.step(16);
3239-
window.__player?.seek(0.99, { keepPlaying: true });
3239+
window.__player?.seek(0.99, { keepPlaying: true }); // lands on the frame at 0.967
32403240

32413241
expect(startedAt).toEqual([]);
3242-
raf.step(16);
3243-
expect(startedAt[0]).toBeGreaterThanOrEqual(1);
3242+
for (let frame = 0; frame < 10 && startedAt.length === 0; frame++) raf.step(16);
3243+
expect(startedAt[0]).toBeGreaterThanOrEqual(1 - 0.02);
32443244
});
32453245

32463246
it("starts a clip at most 40 ms of real time early at a slow speed", () => {
32473247
const { raf, startedAt } = mountLateSfx();
3248-
window.__player?.setPlaybackRate(0.25);
3248+
window.dispatchEvent(
3249+
new MessageEvent("message", {
3250+
source: window.parent,
3251+
data: { source: "hf-parent", type: "control", action: "set-playback-rate", playbackRate: 0.25 },
3252+
}),
3253+
);
32493254
window.__player?.play();
32503255
for (let frame = 0; frame < 60 && startedAt.length === 0; frame++) raf.step(100);
32513256

0 commit comments

Comments
 (0)