mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
db98d30a78
* fix(playback): keep browsed server when queue plays elsewhere Lucky Mix on a non-playback server now clears the old queue and pins the active server before building. Now Playing metadata uses apiForServer against the queue server instead of forcing ensurePlaybackServerActive on every activeServerId change. * docs: note PR #768 in CHANGELOG and settings credits * fix(now-playing): gate AudioMuse similar artists on playback server Match getArtistInfoForServer credentials: when browsing another server while the queue plays elsewhere, similar-artist count follows the queue server's AudioMuse flag, not the browsed server.
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import { renderHook } from '@testing-library/react';
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
import { useAuthStore } from '../store/authStore';
|
|
import { usePlayerStore } from '../store/playerStore';
|
|
import { usePlaybackServerId } from './usePlaybackServerId';
|
|
|
|
vi.mock('../utils/server/switchActiveServer', () => ({
|
|
switchActiveServer: vi.fn(async () => true),
|
|
}));
|
|
|
|
describe('usePlaybackServerId', () => {
|
|
beforeEach(() => {
|
|
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: 'a',
|
|
isLoggedIn: true,
|
|
});
|
|
usePlayerStore.setState({
|
|
queue: [{ id: 't1', title: 'T', artist: 'A', album: 'Al', albumId: 'al1', duration: 100 }],
|
|
queueServerId: 'a',
|
|
queueIndex: 0,
|
|
});
|
|
});
|
|
|
|
it('returns queue server while playback queue is non-empty', () => {
|
|
useAuthStore.setState({ activeServerId: 'b' });
|
|
const { result } = renderHook(() => usePlaybackServerId());
|
|
expect(result.current).toBe('a');
|
|
});
|
|
|
|
it('does not call switchActiveServer when browsed server changes', async () => {
|
|
const { switchActiveServer } = await import('../utils/server/switchActiveServer');
|
|
vi.mocked(switchActiveServer).mockClear();
|
|
const { rerender } = renderHook(() => usePlaybackServerId());
|
|
useAuthStore.setState({ activeServerId: 'b' });
|
|
rerender();
|
|
expect(switchActiveServer).not.toHaveBeenCalled();
|
|
});
|
|
});
|