mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
test(playerStore): characterize pure helpers + queue mutations (Phase F1 / PR 2a) (#540)
trackShape.test.ts: songToTrack mapping (required, optional, replayGain flattening, missing-block fallback, no invented flags); resolveReplayGainDb precedence (disabled, track, album, auto with prev/next neighbour match, missing albumId fallback, both gains missing); shuffleArray (non-mutating, preserves multiset, copies, empty/single, deterministic under mocked RNG). queue.test.ts: enqueue / enqueueAt (auto-added separator placement, queueIndex shift, index clamping), playNext (playNextAdded tag, position, empty input), clearQueue (state reset, audio_stop call), reorderQueue (splice, currentTrack-id-following queueIndex), removeTrack (clamp on shrink, keep when after cursor), undo / redo (empty stacks return false, rollback, replay, new edit drops pending redo). Adds a 5-line test-only export _resetQueueUndoStacksForTest in playerStore.ts because the undo/redo arrays live at module scope outside the Zustand state graph; storeReset.ts now calls it so resetPlayerStore is fully complete. playerStore.ts coverage 4.76% -> 18.1% lines. PR 2b + 2c push further toward the F1 floor of 50%.
This commit is contained in:
committed by
GitHub
parent
4f9ad07d65
commit
42e3fdb976
@@ -20,7 +20,7 @@
|
||||
* // or for cross-store tests:
|
||||
* beforeEach(resetAllStores);
|
||||
*/
|
||||
import { usePlayerStore } from '@/store/playerStore';
|
||||
import { usePlayerStore, _resetQueueUndoStacksForTest } from '@/store/playerStore';
|
||||
import { useAuthStore } from '@/store/authStore';
|
||||
import { usePreviewStore } from '@/store/previewStore';
|
||||
import { useOrbitStore } from '@/store/orbitStore';
|
||||
@@ -32,6 +32,8 @@ const INITIAL_ORBIT_STATE = useOrbitStore.getState();
|
||||
|
||||
export function resetPlayerStore(): void {
|
||||
usePlayerStore.setState(INITIAL_PLAYER_STATE, true);
|
||||
// Module-scoped queue undo/redo stacks live outside the Zustand state.
|
||||
_resetQueueUndoStacksForTest();
|
||||
}
|
||||
|
||||
export function resetAuthStore(): void {
|
||||
|
||||
Reference in New Issue
Block a user