Files
psysonic/src/utils/playback/trackArtistRefs.test.ts
T
cucadmuh 4c70408bd6 fix(now-playing): split artist links and About the Artist tabs (#960)
* fix(now-playing): split artist links and About the Artist tabs

OpenSubsonic artists[] now drives per-artist navigation on Now Playing
hero and the queue current-track row (matching player bar). About the
Artist loads bio for each performer via tabs when a track has multiple
artist ids; queue Info uses the primary ref for bio/tour fetch.

Reported by zunoz on the Psysonic Discord (v1.47.0-rc.3).

* docs: note Now Playing multi-artist fix in CHANGELOG (PR #960)
2026-06-03 22:16:06 +03:00

34 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { primaryTrackArtistRef, resolveTrackArtistRefs } from './trackArtistRefs';
describe('resolveTrackArtistRefs', () => {
it('prefers OpenSubsonic artists[] when present', () => {
const refs = [{ id: 'a1', name: 'Dan Balan' }, { id: 'a2', name: 'Katerina Begu' }];
expect(resolveTrackArtistRefs({
artist: 'Dan Balan feat. Katerina Begu',
artistId: 'legacy',
artists: refs,
})).toEqual(refs);
});
it('falls back to legacy artistId + artist', () => {
expect(resolveTrackArtistRefs({
artist: 'Solo',
artistId: 'ar-solo',
})).toEqual([{ id: 'ar-solo', name: 'Solo' }]);
});
it('returns name-only ref when no id', () => {
expect(resolveTrackArtistRefs({ artist: 'Unknown' })).toEqual([{ name: 'Unknown' }]);
});
});
describe('primaryTrackArtistRef', () => {
it('returns the first structured ref', () => {
expect(primaryTrackArtistRef({
artist: 'A feat. B',
artists: [{ id: 'a1', name: 'A' }, { id: 'a2', name: 'B' }],
})).toEqual({ id: 'a1', name: 'A' });
});
});