Release: web UX overhaul + Android native port + server polish #59
@@ -35,21 +35,25 @@ describe('useGlobalShortcuts', () => {
|
||||
|
||||
test('Space toggles play/pause', async () => {
|
||||
const store = await import('./store.svelte');
|
||||
expect(store.player.state).toBe('paused');
|
||||
press(' ');
|
||||
flushSync();
|
||||
expect(store.player.state).toBe('playing');
|
||||
// playQueue leaves the store at 'loading' (intent-to-play; jsdom
|
||||
// never moves it to 'playing' because there's no real audio). The
|
||||
// togglePlay contract is: loading|playing -> paused, anything else
|
||||
// -> loading. So Space round-trips loading <-> paused.
|
||||
expect(store.player.state).toBe('loading');
|
||||
press(' ');
|
||||
flushSync();
|
||||
expect(store.player.state).toBe('paused');
|
||||
press(' ');
|
||||
flushSync();
|
||||
expect(store.player.state).toBe('loading');
|
||||
});
|
||||
|
||||
test('K is an alias for Space (YouTube convention)', async () => {
|
||||
const store = await import('./store.svelte');
|
||||
expect(store.player.state).toBe('paused');
|
||||
expect(store.player.state).toBe('loading');
|
||||
press('k');
|
||||
flushSync();
|
||||
expect(store.player.state).toBe('playing');
|
||||
expect(store.player.state).toBe('paused');
|
||||
});
|
||||
|
||||
test('ArrowRight advances to the next track', async () => {
|
||||
@@ -97,19 +101,20 @@ describe('useGlobalShortcuts', () => {
|
||||
|
||||
test('shortcuts are ignored when focus is in an input', async () => {
|
||||
const store = await import('./store.svelte');
|
||||
expect(store.player.state).toBe('paused');
|
||||
const before = store.player.state;
|
||||
const input = document.createElement('input');
|
||||
document.body.appendChild(input);
|
||||
input.focus();
|
||||
press(' ', input);
|
||||
flushSync();
|
||||
// No state change — Space should pass through to the input.
|
||||
expect(store.player.state).toBe('paused');
|
||||
expect(store.player.state).toBe(before);
|
||||
input.remove();
|
||||
});
|
||||
|
||||
test('modifier keys disable the shortcut (browser hotkey passthrough)', async () => {
|
||||
const store = await import('./store.svelte');
|
||||
const before = store.player.state;
|
||||
const event = new KeyboardEvent('keydown', {
|
||||
key: ' ',
|
||||
ctrlKey: true,
|
||||
@@ -118,6 +123,6 @@ describe('useGlobalShortcuts', () => {
|
||||
});
|
||||
window.dispatchEvent(event);
|
||||
flushSync();
|
||||
expect(store.player.state).toBe('paused');
|
||||
expect(store.player.state).toBe(before);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user