fix: align TrackNodeSend test with actual TrackNode API#1246
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the TrackNodeSend unit tests to match the actual TrackNode aux-send API (as implemented in PR #1039), unblocking CI by removing calls to a non-existent method.
Changes:
- Replace
updateSendPrePost()usage withupdateSendAmount(id, amount, preFader)inTrackNodeSend.test.ts. - Update
connectSend()calls to passpreFader: boolean(true/false) instead of'pre' | 'post'. - Adjust one test description/comment to reflect the updated API intent.
Comments suppressed due to low confidence (1)
src/engine/tests/TrackNodeSend.test.ts:120
- The comment here says the pre-fader tap point should be
sumGain, butTrackNode.connectSend()actually tapspreFaderOutput(compressor or latency-comp node) beforevolumeGain. Also, the test currently has no assertions—updating the comment and asserting which node performed theconnect()call would make this test meaningful.
trackNode.connectSend('send-1', sendDest, 0.5, true);
// The pre-fader tap point should be the sumGain (before volumeGain)
// Verify by checking that sumGain.connect was called (for the send gain node)
// This is an integration-level check — the send gain should connect from sumGain
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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 |
There was a problem hiding this comment.
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.
| 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); |
The test was calling `updateSendPrePost()` which doesn't exist. The actual API uses `updateSendAmount(id, amount, preFader: boolean)` for both amount changes and pre/post switching. Also fix `connectSend` calls to use boolean `preFader` parameter instead of string literals. https://claude.ai/code/session_017CJfg9zq4GvRCuPaSWvHKW
6ec96aa to
c52ed5e
Compare
Summary
TrackNodeSend.test.tscalling non-existentupdateSendPrePost()method — useupdateSendAmount()insteadconnectSend()calls to useboolean(true/false) instead of string literals ('pre'/'post')Test plan
Closes #1245
https://claude.ai/code/session_017CJfg9zq4GvRCuPaSWvHKW