mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 23:35:44 +00:00
fix(connection): ignore spurious navigator.onLine offline hint in Tauri (#1234)
This commit is contained in:
@@ -11,6 +11,10 @@ vi.mock('@/lib/api/subsonicStarRating', () => ({
|
||||
|
||||
import { usePlayerStore } from '@/features/playback/store/playerStore';
|
||||
import type { Track } from '@/lib/media/trackTypes';
|
||||
import {
|
||||
resetActiveServerConnectionSnapshot,
|
||||
setActiveServerReachable,
|
||||
} from '@/lib/network/activeServerReachability';
|
||||
import { queueSongStar, queueSongRating, _resetPendingStarSyncForTest } from '@/features/playback/store/pendingStarSync';
|
||||
import {
|
||||
getCachedTrack,
|
||||
@@ -26,6 +30,8 @@ const track = (id: string): Track => ({
|
||||
describe('pendingStarSync', () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
resetActiveServerConnectionSnapshot();
|
||||
setActiveServerReachable(true);
|
||||
starMock.mockReset().mockResolvedValue(undefined);
|
||||
unstarMock.mockReset().mockResolvedValue(undefined);
|
||||
setRatingMock.mockReset().mockResolvedValue(undefined);
|
||||
@@ -75,6 +81,19 @@ describe('pendingStarSync', () => {
|
||||
expect(usePlayerStore.getState().starredOverrides.t1).toBe(true); // override survives (no rollback)
|
||||
});
|
||||
|
||||
it('flushes pending stars when the active server becomes reachable', async () => {
|
||||
starMock.mockRejectedValue(new Error('offline'));
|
||||
queueSongStar('t1', true);
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
expect(starMock).toHaveBeenCalledTimes(1);
|
||||
|
||||
setActiveServerReachable(false);
|
||||
setActiveServerReachable(true);
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
|
||||
expect(starMock.mock.calls.length).toBeGreaterThan(1);
|
||||
});
|
||||
|
||||
it('passes serverId through to star/unstar for cross-server favorites', async () => {
|
||||
queueSongStar('t1', true, 'srv-b');
|
||||
await vi.runAllTimersAsync();
|
||||
|
||||
Reference in New Issue
Block a user