From ba645e5ccb190168dbe9c62060b10dff63e19a62 Mon Sep 17 00:00:00 2001 From: zbn297427669 <17957946+zbn297427669@users.noreply.github.com> Date: Mon, 2 Nov 2026 15:53:06 +0800 Subject: [PATCH] test: catch bot tests up with the de-click transport ramp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upstream a0f0b49..6f165b5 added the pause/resume fade tail but shipped no test updates, leaving 5 assertions red (also reproducible on pristine upstream/main, so not merge-induced). - instance-recovery/instance harnesses: stub players borrow AudioPlayer.prototype.pause/resume, which now call this.setTransportRamp(). Give the stubs that method or they throw TypeError on pause/resume. - voice-failure: pausing deliberately emits a fade tail, so the frame count no longer freezes at exactly 50. Assert the de-click fade completes, then that the scheduler and elapsed clock are genuinely frozen — the actual behavior under test. No production code changed. Co-Authored-By: Claude Code --- src/bot/instance-recovery.test.ts | 4 ++++ src/bot/instance.test.ts | 4 ++++ src/bot/voice-failure.test.ts | 12 ++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) 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(); } });