Merge pull request #59 from KGAudioLab/feat/2026-06-30-misc

fix: failed test cases
This commit is contained in:
Xiaohan-Tian
2026-07-07 17:25:13 -07:00
committed by GitHub
3 changed files with 19 additions and 7 deletions
@@ -130,6 +130,13 @@ export class CreateNoteCommand extends KGCommand {
return this.regionId; return this.regionId;
} }
/**
* Get the velocity that will be used for the created note.
*/
public getVelocity(): number {
return this.velocity;
}
/** /**
* Factory method to create a note command from UI coordinates * Factory method to create a note command from UI coordinates
*/ */
+6 -6
View File
@@ -173,9 +173,9 @@ describe('useNoteOperations', () => {
}); });
expect(coreState.executeCommand).toHaveBeenCalledTimes(1); expect(coreState.executeCommand).toHaveBeenCalledTimes(1);
const createCommand = coreState.executeCommand.mock.calls[0][0] as CreateNoteCommand & { velocity: number }; const createCommand = coreState.executeCommand.mock.calls[0][0] as CreateNoteCommand;
expect(createCommand).toBeInstanceOf(CreateNoteCommand); expect(createCommand).toBeInstanceOf(CreateNoteCommand);
expect(createCommand.velocity).toBe(91); expect(createCommand.getVelocity()).toBe(91);
}); });
it('uses the most recently selected note velocity after deselecting a multi-selection', () => { it('uses the most recently selected note velocity after deselecting a multi-selection', () => {
@@ -201,9 +201,9 @@ describe('useNoteOperations', () => {
}); });
expect(coreState.executeCommand).toHaveBeenCalledTimes(1); expect(coreState.executeCommand).toHaveBeenCalledTimes(1);
const createCommand = coreState.executeCommand.mock.calls[0][0] as CreateNoteCommand & { velocity: number }; const createCommand = coreState.executeCommand.mock.calls[0][0] as CreateNoteCommand;
expect(createCommand).toBeInstanceOf(CreateNoteCommand); expect(createCommand).toBeInstanceOf(CreateNoteCommand);
expect(createCommand.velocity).toBe(105); expect(createCommand.getVelocity()).toBe(105);
}); });
it('falls back to velocity 127 when creating a manual note with no selection', () => { it('falls back to velocity 127 when creating a manual note with no selection', () => {
@@ -220,9 +220,9 @@ describe('useNoteOperations', () => {
}); });
expect(coreState.executeCommand).toHaveBeenCalledTimes(1); expect(coreState.executeCommand).toHaveBeenCalledTimes(1);
const createCommand = coreState.executeCommand.mock.calls[0][0] as CreateNoteCommand & { velocity: number }; const createCommand = coreState.executeCommand.mock.calls[0][0] as CreateNoteCommand;
expect(createCommand).toBeInstanceOf(CreateNoteCommand); expect(createCommand).toBeInstanceOf(CreateNoteCommand);
expect(createCommand.velocity).toBe(127); expect(createCommand.getVelocity()).toBe(127);
}); });
it('applies the cached velocity to every note in manual chord creation after deselecting', () => { it('applies the cached velocity to every note in manual chord creation after deselecting', () => {
+5
View File
@@ -59,6 +59,10 @@ const mockProject = {
setShowGlobalTracks: vi.fn((value: boolean) => { setShowGlobalTracks: vi.fn((value: boolean) => {
mockShowGlobalTracks = value; mockShowGlobalTracks = value;
}), }),
getPlayheadPosition: () => mockPlayheadPosition,
setPlayheadPosition: vi.fn((position: number) => {
mockPlayheadPosition = position;
}),
getLoopingRange: () => [0, 0] as [number, number], getLoopingRange: () => [0, 0] as [number, number],
getPianoRollZoom: () => 1, getPianoRollZoom: () => 1,
}; };
@@ -224,6 +228,7 @@ describe('projectStore piano roll state', () => {
mockShowGlobalTracks = false; mockShowGlobalTracks = false;
mockProject.setIsMetronomeEnabled.mockClear(); mockProject.setIsMetronomeEnabled.mockClear();
mockProject.setShowGlobalTracks.mockClear(); mockProject.setShowGlobalTracks.mockClear();
mockProject.setPlayheadPosition.mockClear();
configValues.set('audio.input_device_id', 'default'); configValues.set('audio.input_device_id', 'default');
}); });