mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 14:35:41 +00:00
568f3aeb7d
39 new tests targeting the response normalization paths the F3 PR (#544) deferred. Mocks axios at the module boundary; pins: - api() helper envelope: unwrap subsonic-response on status=ok, throw "Invalid response" without envelope, throw the server message on status=failed, throw a generic on failed-without-message, propagate network failures. - song-array vs single-object normalization paths: - getMusicDirectory normalizes child (object -> [object]), empty -> []. - getMusicIndexes flattens index -> artist arrays (object or array). - getMusicFolders coerces numeric ids to strings + defaults name. - getRandomSongs pass-through behaviour pinned (no normalization -- Navidrome always returns the array form). - collection-shape contracts: getAlbum splits { album, songs } + empty fallback when album.song is absent, getStarred returns empty arrays on missing starred2 / missing fields / pass-through arrays. - single endpoint behaviours: getSong null on failure, getTopSongs [] + slice to 5, getArtists flatten + empty, search whitespace-query short-circuit (no HTTP), getAlbumInfo2 null on error, ping true/false based on status. - pingWithCredentials (explicit-URL path): full response (type + serverVersion + openSubsonic), http:// prepend when scheme missing, trailing-slash strip before /rest/ping.view, ok=false on any failure / status=failed, openSubsonic defaults to false when omitted. subsonic.ts coverage 12.66% -> 31.87% lines (+19pp). The remaining surface lives in niche endpoints (playlist mutations, statistics overview/aggregates, internet radio CRUD, cover-art uploads, ratings prefetch). Not gate-eligible yet; a follow-up could push to ~60% but diminishing returns relative to other backlog items. Frontend suite: 412 -> 451 tests (+39).