fix now playing swipe softlock

This commit is contained in:
Boof2015
2026-07-28 14:08:15 -04:00
parent 4c40af970b
commit f00cd0abcd
8 changed files with 328 additions and 103 deletions
@@ -1,8 +1,11 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { parseNowPlayingCompanion } from './nowPlayingPreferences.ts';
import { splitCollaborators } from '../../shared/library/albumGrouping.ts';
import { buildArtistNameTokens } from '../../shared/library/artistCredits.ts';
import {
buildArtistNameTokens,
formatArtistNames,
parseArtistMetadata,
} from '../../shared/library/artistCredits.ts';
test('defaults missing and invalid companion preferences to queue', () => {
assert.equal(parseNowPlayingCompanion(null), 'queue');
@@ -16,18 +19,33 @@ test('restores persisted queue and lyrics companion preferences', () => {
});
test('builds separate clickable credits for collaborative track artists', () => {
const artists = splitCollaborators('Dazbee feat. 9Lana & ValkyR');
assert.deepEqual(artists, ['Dazbee', '9Lana', 'ValkyR']);
const artists = ['Dazbee', '9Lana', 'ValkyR'];
assert.equal(formatArtistNames(artists), 'Dazbee, 9Lana, ValkyR');
assert.deepEqual(buildArtistNameTokens(artists), [
{ artist: 'Dazbee', separator: ', ' },
{ artist: '9Lana', separator: ' & ' },
{ artist: '9Lana', separator: ', ' },
{ artist: 'ValkyR', separator: null },
]);
});
test('structured credits preserve commas and ampersands inside one artist name', () => {
assert.deepEqual(buildArtistNameTokens(['Earth, Wind & Fire', 'The Emotions']), [
{ artist: 'Earth, Wind & Fire', separator: ' & ' },
{ artist: 'Earth, Wind & Fire', separator: ', ' },
{ artist: 'The Emotions', separator: null },
]);
});
test('legacy display credits keep their literal separators', () => {
assert.deepEqual(parseArtistMetadata('1, 2, 3'), [
{ artist: '1', separator: ', ' },
{ artist: '2', separator: ', ' },
{ artist: '3', separator: null },
]);
assert.deepEqual(parseArtistMetadata('Simon & Garfunkel'), [
{ artist: 'Simon & Garfunkel', separator: null },
]);
assert.deepEqual(parseArtistMetadata('One; Two'), [
{ artist: 'One', separator: '; ' },
{ artist: 'Two', separator: null },
]);
});