fix: align youtube playback with shared overlay startup

This commit is contained in:
2026-03-22 18:34:25 -07:00
parent 7666a094f4
commit e7242d006f
31 changed files with 3545 additions and 60 deletions

View File

@@ -332,6 +332,7 @@ function createKeyboardHandlerHarness() {
return true;
},
handleControllerDebugKeydown: () => false,
handleYoutubePickerKeydown: () => false,
handleSessionHelpKeydown: () => false,
openSessionHelpModal: () => {},
appendClipboardVideoToQueue: () => {},
@@ -489,6 +490,34 @@ test('keyboard mode: repeated popup navigation keys are forwarded while popup is
}
});
test('popup-visible mpv keybindings still fire for bound keys', async () => {
const { ctx, handlers, testGlobals } = createKeyboardHandlerHarness();
try {
await handlers.setupMpvInputForwarding();
handlers.updateKeybindings([
{
key: 'Space',
command: ['cycle', 'pause'],
},
{
key: 'KeyQ',
command: ['quit'],
},
] as never);
ctx.state.yomitanPopupVisible = true;
testGlobals.setPopupVisible(true);
testGlobals.dispatchKeydown({ key: ' ', code: 'Space' });
testGlobals.dispatchKeydown({ key: 'q', code: 'KeyQ' });
assert.deepEqual(testGlobals.mpvCommands.slice(-2), [['cycle', 'pause'], ['quit']]);
} finally {
testGlobals.restore();
}
});
test('keyboard mode: controller helpers dispatch popup audio play/cycle and scroll bridge commands', async () => {
const { ctx, handlers, testGlobals } = createKeyboardHandlerHarness();
@@ -817,6 +846,22 @@ test('keyboard mode: closing lookup clears yomitan active text source so same to
}
});
test('subtitle refresh outside keyboard mode clears yomitan active text source', async () => {
const { handlers, testGlobals } = createKeyboardHandlerHarness();
try {
handlers.handleSubtitleContentUpdated();
await wait(0);
const clearCommands = testGlobals.commandEvents.filter(
(event) => event.type === 'clearActiveTextSource',
);
assert.deepEqual(clearCommands, [{ type: 'clearActiveTextSource' }]);
} finally {
testGlobals.restore();
}
});
test('keyboard mode: lookup toggle closes popup when DOM visibility is the source of truth', async () => {
const { ctx, handlers, testGlobals } = createKeyboardHandlerHarness();