Skip to content

Commit f21af60

Browse files
committed
test(core): pin the clock's hold while seeking and its skip of a failed clip
1 parent a609388 commit f21af60

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,26 @@ describe("the audio the playhead follows", () => {
166166
}
167167
expect(lastTime).toBeGreaterThan(1.4);
168168
});
169+
170+
it("does not follow a clip whose media failed to load", async () => {
171+
mount(
172+
`<audio id="broken" data-start="0" data-duration="10" src="/assets/missing.mp3"></audio>` +
173+
`<audio id="vo" data-start="0" data-duration="10" src="/assets/vo.mp3"></audio>`,
174+
);
175+
const broken = document.getElementById("broken") as HTMLAudioElement;
176+
const vo = document.getElementById("vo") as HTMLAudioElement;
177+
initSandboxRuntimeModular();
178+
await flush();
179+
window.__player?.play();
180+
await flush();
181+
const playedAt = nowMs;
182+
Object.defineProperty(broken, "error", { value: { code: 4 } });
183+
Object.assign(broken, { paused: false, currentTime: 0 });
184+
Object.assign(vo, { paused: false });
185+
for (let frame = 0; frame < 90; frame++) {
186+
stepFrames(1);
187+
vo.currentTime = (nowMs - playedAt) / 1000;
188+
}
189+
expect(window.__player!.getTime()).toBeGreaterThan(1.4);
190+
});
169191
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,11 @@ describe("TransportClock", () => {
331331
expect(clock.now()).toBeCloseTo(6.37, 5);
332332
});
333333

334-
it("holds the playhead while its element seeks", () => {
334+
it("holds the playhead while its element seeks, even to a time ahead", () => {
335335
const { clock, advance } = createClock({ duration: 30 });
336336
clock.play();
337337
advancePolled(clock, advance, 2000);
338-
const voice = Object.assign(createMockAudioEl(0, false), { seeking: true });
338+
const voice = Object.assign(createMockAudioEl(3, false), { seeking: true });
339339
clock.attachAudioSource({ el: voice, compositionStart: 2, mediaStart: 0 });
340340
advance(150);
341341
expect(clock.now()).toBeCloseTo(2, 5);

0 commit comments

Comments
 (0)