Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/engine/__tests__/TrackNodeSend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ describe('TrackNode send routing', () => {
// No throw = success; gain value update happens internally
});

it('updateSendAmount switches send to pre-fader', () => {
it('updateSendAmount switches send from post to pre-fader', () => {
const sendDest = { connect: vi.fn(), disconnect: vi.fn() } as unknown as AudioNode;
trackNode.connectSend('send-1', sendDest, 0.5, false);
trackNode.updateSendAmount('send-1', 0.5, true);
// No throw = success; pre/post gain swap happens internally
// No throw = success; pre/post switching happens via gain crossfade
Comment on lines +109 to +111
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test case doesn't assert any observable behavior (it will pass as long as no exception is thrown), even though the name suggests it validates switching from post- to pre-fader. Consider asserting the internal send gain state (e.g., pre gain ramps to amount and post gain ramps to 0) similar to src/engine/__tests__/TrackNode.sends.test.ts so the test actually verifies the tap-point switch.

Suggested change
trackNode.connectSend('send-1', sendDest, 0.5, false);
trackNode.updateSendAmount('send-1', 0.5, true);
// No throw = success; pre/post switching happens via gain crossfade
const amount = 0.5;
trackNode.connectSend('send-1', sendDest, amount, false);
trackNode.updateSendAmount('send-1', amount, true);
// Inspect all gain nodes created by the mock AudioContext
const gainCreationResults = (ctx.createGain as unknown as ReturnType<typeof vi.fn>).mock
.results;
const gainNodes = gainCreationResults.map((r: { value: any }) => r.value);
// Collect all linearRampToValueAtTime target values across all gain nodes
const rampCalls = gainNodes.flatMap((node: any) =>
(node.gain.linearRampToValueAtTime as ReturnType<typeof vi.fn>).mock.calls,
);
const rampTargets = rampCalls.map((args: any[]) => args[0]);
// Verify that we actually scheduled ramps
expect(rampTargets.length).toBeGreaterThan(0);
// One gain should ramp up to the send amount (pre-fader), another down to 0 (post-fader)
expect(rampTargets).toContain(amount);
expect(rampTargets).toContain(0);

Copilot uses AI. Check for mistakes.
});

it('pre-fader send taps before volumeGain', () => {
Expand Down
Loading