mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-13 20:12:54 -07:00
feat(config): show default keybindings in generated example config
- Expand `keybindings` array in `config.example.jsonc` to list all built-in defaults instead of `[]` - Inject `DEFAULT_KEYBINDINGS` into template when resolved config has an empty keybindings array - Add regression tests for template parity, default binding compile/action mapping, overlay keyboard dispatch, and mpv plugin registration/dispatch - Add fullscreen binding to docs shortcut tables and clarify keybindings can target mpv commands or session actions
This commit is contained in:
@@ -209,6 +209,41 @@ test('compileSessionBindings keeps default replay and next subtitle session acti
|
||||
assert.equal(next?.actionId, 'playNextSubtitle');
|
||||
});
|
||||
|
||||
test('compileSessionBindings wires every default keybinding to an overlay or mpv action', () => {
|
||||
const expectedSpecialActions: Record<string, string> = {
|
||||
[SPECIAL_COMMANDS.SHIFT_SUB_DELAY_TO_PREVIOUS_SUBTITLE_START]: 'shiftSubDelayPrevLine',
|
||||
[SPECIAL_COMMANDS.SHIFT_SUB_DELAY_TO_NEXT_SUBTITLE_START]: 'shiftSubDelayNextLine',
|
||||
[SPECIAL_COMMANDS.YOUTUBE_PICKER_OPEN]: 'openYoutubePicker',
|
||||
[SPECIAL_COMMANDS.PLAYLIST_BROWSER_OPEN]: 'openPlaylistBrowser',
|
||||
[SPECIAL_COMMANDS.REPLAY_SUBTITLE]: 'replayCurrentSubtitle',
|
||||
[SPECIAL_COMMANDS.PLAY_NEXT_SUBTITLE]: 'playNextSubtitle',
|
||||
};
|
||||
const result = compileSessionBindings({
|
||||
shortcuts: createShortcuts(),
|
||||
keybindings: DEFAULT_KEYBINDINGS,
|
||||
platform: 'linux',
|
||||
});
|
||||
|
||||
assert.deepEqual(result.warnings, []);
|
||||
const byOriginalKey = new Map(result.bindings.map((binding) => [binding.originalKey, binding]));
|
||||
assert.equal(byOriginalKey.size, DEFAULT_KEYBINDINGS.length);
|
||||
|
||||
for (const defaultBinding of DEFAULT_KEYBINDINGS) {
|
||||
const compiled = byOriginalKey.get(defaultBinding.key);
|
||||
assert.ok(compiled, `${defaultBinding.key} should compile`);
|
||||
|
||||
const specialAction = expectedSpecialActions[String(defaultBinding.command?.[0])];
|
||||
if (specialAction) {
|
||||
assert.equal(compiled.actionType, 'session-action');
|
||||
assert.equal(compiled.actionId, specialAction);
|
||||
continue;
|
||||
}
|
||||
|
||||
assert.equal(compiled.actionType, 'mpv-command');
|
||||
assert.deepEqual(compiled.command, defaultBinding.command);
|
||||
}
|
||||
});
|
||||
|
||||
test('compileSessionBindings omits disabled bindings', () => {
|
||||
const result = compileSessionBindings({
|
||||
shortcuts: createShortcuts({
|
||||
|
||||
Reference in New Issue
Block a user