mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 15:25:46 +00:00
fix(playback): pin queue playback to source server when browsing another library (#717)
* fix(playback): pin queue streams, cover art, and library links to queue server When the active server changes while a queue from another server is playing, keep streams and UI on queueServerId; switch back for artist/album links and queue or player-bar context menus. * fix(playback): switch to queue server when opening Now Playing Ensure active server matches queueServerId before Subsonic fetches on the Now Playing page, mobile player route, and queue info panel; scope caches by server id. * docs(credits): mention Now Playing in PR #717 contribution line * fix(playback): route scrobble and queue sync to queue server Address PR review: apiForServer for scrobble/now-playing/savePlayQueue, clear queueServerId on server removal, mini-player queueServerId sync, block cross-server enqueue with toast, and regression tests.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { useAuthStore } from '../store/authStore';
|
||||
import { usePlayerStore } from '../store/playerStore';
|
||||
import { scrobbleSong } from './subsonicScrobble';
|
||||
|
||||
const { apiForServerMock } = vi.hoisted(() => ({
|
||||
apiForServerMock: vi.fn(async () => ({})),
|
||||
}));
|
||||
|
||||
vi.mock('./subsonicClient', () => ({
|
||||
api: vi.fn(),
|
||||
apiForServer: apiForServerMock,
|
||||
}));
|
||||
|
||||
describe('subsonicScrobble', () => {
|
||||
beforeEach(() => {
|
||||
apiForServerMock.mockClear();
|
||||
useAuthStore.setState({
|
||||
servers: [
|
||||
{ id: 'a', name: 'A', url: 'http://a.test', username: 'u', password: 'p' },
|
||||
{ id: 'b', name: 'B', url: 'http://b.test', username: 'u', password: 'p' },
|
||||
],
|
||||
activeServerId: 'b',
|
||||
isLoggedIn: true,
|
||||
});
|
||||
usePlayerStore.setState({
|
||||
queue: [{ id: 't1', title: 'T', artist: 'A', album: 'Al', albumId: 'al1', duration: 100 }],
|
||||
queueServerId: 'a',
|
||||
queueIndex: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it('scrobbleSong targets the queue server when active server differs', async () => {
|
||||
await scrobbleSong('t1', 1_700_000_000_000, 'a');
|
||||
expect(apiForServerMock).toHaveBeenCalledWith(
|
||||
'a',
|
||||
'scrobble.view',
|
||||
expect.objectContaining({ id: 't1', submission: true, time: 1_700_000_000_000 }),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user