fix(ui): match canonical name in parseAndReplaceArtists

The display string (record.artist/albumArtist) is sourced from
mf.Artist/mf.AlbumArtist, which carry the canonical-tag value.
Matching on creditedAs failed for Picard-default tagging (ARTIST
tag = canonical name, ARTIST_CREDIT = credit) because indexOf
could not find the credit inside the canonical display string,
silently degrading from inline linkification to bullet-list
fallback.

Match on artist.name (always equal to displayString slice) and
let ALink continue rendering creditedAs || name for visible text.
This commit is contained in:
Deluan 2026-05-24 21:28:05 -03:00
parent 86cb5fee93
commit 1cf5a9f215
2 changed files with 37 additions and 1 deletions

View File

@ -42,7 +42,11 @@ const parseAndReplaceArtists = (
let lastIndex = 0
albumArtists?.forEach((artist) => {
const matchName = artist.creditedAs || artist.name
// Match on the canonical name that's what appears in displayAlbumArtist
// (sourced from mf.Artist / mf.AlbumArtist, which are set from the canonical
// ARTIST tag at scan time). The ALink itself renders creditedAs || name,
// so the displayed link text still reflects the credit.
const matchName = artist.name
const index = displayAlbumArtist.indexOf(matchName, lastIndex)
if (index !== -1) {
// Add text before the artist name

View File

@ -286,6 +286,38 @@ describe('ArtistLinkField', () => {
const link = screen.getByRole('link')
expect(link).not.toHaveAttribute('title')
})
it('inline-linkifies when displayArtist holds the canonical name (Picard-default tagging)', () => {
// Picard "use standardized artist names" mode: ARTIST tag carries the
// canonical name, ARTIST_CREDIT carries the credit. The display string
// is the canonical name; parseAndReplaceArtists must match on `name`
// (not `creditedAs`) to embed the link inline. The link text itself
// still renders the credit via ALink.
const record = {
artist: 'Planetary Assault Systems',
participants: {
artist: [
{
id: 'canon-1',
name: 'Planetary Assault Systems',
creditedAs: 'PAS',
},
],
},
}
render(<ArtistLinkField record={record} source="artist" />)
const link = screen.getByRole('link')
// Link text is the credit, tooltip carries canonical
expect(link).toHaveTextContent('PAS')
expect(link).toHaveAttribute('title', 'Planetary Assault Systems')
// The original canonical string should not appear as raw plain text
// (it was replaced by the link)
expect(
screen.queryByText(/^Planetary Assault Systems$/),
).not.toBeInTheDocument()
})
})
describe('when limiting displayed artists', () => {