diff --git a/src/bot/instance-recovery.test.ts b/src/bot/instance-recovery.test.ts index 6f57aec..b556b7d 100644 --- a/src/bot/instance-recovery.test.ts +++ b/src/bot/instance-recovery.test.ts @@ -29,6 +29,10 @@ function makeBot() { player.getVolume = () => 50; player.pause = AudioPlayer.prototype.pause; player.resume = AudioPlayer.prototype.resume; + // The real pause()/resume() drive the de-click transport ramp + // (a0f0b49..6f165b5). A stub player must expose it too, or the prototype + // methods throw "setTransportRamp is not a function". + player.setTransportRamp = vi.fn(); player.play = vi.fn((_url: string, position: number) => { player.sessionId++; player.elapsed = position; player.state = "playing"; }); player.stop = vi.fn(() => { player.sessionId++; player.state = "idle"; }); const provider = { getSongUrl: vi.fn(async (): Promise<{ url: string } | null> => ({ url: "fresh" })) }; diff --git a/src/bot/instance.test.ts b/src/bot/instance.test.ts index 685a1e7..eaffd8c 100644 --- a/src/bot/instance.test.ts +++ b/src/bot/instance.test.ts @@ -1780,6 +1780,10 @@ describe("BotInstance trackEnd — stale playback sessions", () => { player.getPlaybackSessionId = AudioPlayer.prototype.getPlaybackSessionId; player.pause = AudioPlayer.prototype.pause; player.resume = AudioPlayer.prototype.resume; + // The real pause()/resume() drive the de-click transport ramp + // (a0f0b49..6f165b5). A stub player must expose it too, or the prototype + // methods throw "setTransportRamp is not a function". + player.setTransportRamp = vi.fn(); player.play = vi.fn(() => { player.sessionId++; player.state = "playing"; }); const provider = { getSongUrl: vi.fn(async () => ({ url: "fresh" })) }; const advances: string[] = []; diff --git a/src/bot/voice-failure.test.ts b/src/bot/voice-failure.test.ts index a81bd9f..794ea8a 100644 --- a/src/bot/voice-failure.test.ts +++ b/src/bot/voice-failure.test.ts @@ -65,9 +65,17 @@ describe("BotInstance persistent voice send failure", () => { expect(frames).toBe(50); h.tsClient.emit("voiceSendFailed", { consecutiveFailures: 100, durationMs: 2000 }); vi.advanceTimersByTime(3000); - expect(frames).toBe(50); - expect(h.player.getElapsed()).toBe(1); + // Pausing emits a short de-click fade tail (pauseFrames) so the last + // audible frames ramp down instead of cutting off (a0f0b49). What this + // test guards is what happens AFTER that: the scheduler must go quiet + // and elapsed must stop advancing. expect(h.player.getState()).toBe("paused"); + const framesAfterFade = frames; + const elapsedAfterFade = h.player.getElapsed(); + expect(framesAfterFade).toBeLessThan(50 + 20); + vi.advanceTimersByTime(3000); + expect(frames).toBe(framesAfterFade); + expect(h.player.getElapsed()).toBe(elapsedAfterFade); } finally { h.player.stop(); } });