mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 14:35:41 +00:00
test(previewStore): startPreview + main-player volume sync (Phase F4) (#545)
Adds 22 new tests on top of the existing 7 _on* / stopPreview ones. startPreview happy path: invokes audio_preview_play with the configured args (id, url, durationSec, startSec, volume) and stores the previewing track + duration + reset elapsed / audioStarted. Short tracks (duration <= previewDuration * 1.5) start at 0; longer tracks seek to duration * trackPreviewStartRatio. Camel-case IPC keys pinned (startSec / durationSec, not snake_case -- CLAUDE.md gotcha). Cross-store guard tests: no-op when previews globally disabled, no-op when disabled at the calling location, no-op while a host or guest is inside any Orbit phase (active / joining / starting), falls through to play when role is null (no session). Same-id re-click: treats it as a stop -- audio_preview_stop fires, audio_preview_play does not. Failure path: engine invoke rejects -> store state rolls back (previewingId / previewingTrack / audioStarted) and the error propagates to the caller. Loudness pre-attenuation folding: with normalizationEngine=loudness + loudnessPreAnalysisAttenuationDb=-6 dB, volume is multiplied by 10^(-6/20). normalizationEngine=off keeps volume verbatim. Positive pre-attenuation values are pulled to 0 by the Math.min(0, ...) guard. Main-player volume sync side-effect (module-level usePlayerStore.subscribe): pings audio_preview_set_volume when volume changes during a preview, skips when no preview is active, skips when the new value equals the prior value (subscription guard). previewStore.ts coverage 33% -> 100% lines. Added to the hot-path gate. Plus the typed `OrbitRole` is `'host' | 'guest'` (null when no session), not 'idle' as a string -- minor type-correctness alignment.
This commit is contained in:
committed by
GitHub
parent
d2898ebaf6
commit
6e646351ee
@@ -19,7 +19,6 @@
|
||||
# work lands.
|
||||
#
|
||||
# Deferred from the gate, with current coverage shown for reference:
|
||||
# - src/store/previewStore.ts (33 % — only `_on*` + `stopPreview` covered, Phase 4 target)
|
||||
# - src/store/playerStore.ts (40 % — F1 closed under the 50 % floor; further coverage TBD)
|
||||
# - src/store/authStore.ts (79 % — F2 cleared 60 % floor; staying out one or two PRs to verify stability)
|
||||
# - src/api/subsonic.ts (13 % — F3 covered the URL-builder + parser surface; async API endpoints need axios mocking, deferred)
|
||||
@@ -32,3 +31,6 @@ src/utils/shareLink.ts
|
||||
src/utils/dynamicColors.ts
|
||||
src/utils/resolvePlaybackUrl.ts
|
||||
src/utils/copyEntityShareLink.ts
|
||||
|
||||
# ── stores (added as their tests grew past the floor) ────────────────
|
||||
src/store/previewStore.ts
|
||||
|
||||
Reference in New Issue
Block a user