fix(SharePlayer): fallback to playlist ID for empty playlist descriptions

This commit is contained in:
Katelyn Dickey 2026-06-19 14:57:32 -04:00
parent 9a176781e6
commit 54e9f61c95
2 changed files with 27 additions and 2 deletions

View File

@ -103,7 +103,7 @@ const SharePlayer = () => {
/>
<Dialog
id="share-download-menu"
open={downloadInfo}
open={!!downloadInfo}
onClose={handleClose}
aria-labelledby="share-download-title"
>
@ -126,9 +126,12 @@ const SharePlayer = () => {
startIcon={<QueueMusicIcon />}
disabled={!shareInfo}
onClick={() => {
let url = shareDownloadUrl(shareInfo?.id)
downloadFile(
shareDownloadUrl(shareInfo?.id),
shareInfo?.description + '.zip',
shareInfo?.description && shareInfo.description.trim() !== ''
? shareInfo.description + '.zip'
: shareInfo?.id + '.zip',
)
setDownloadInfo(null)
}}

View File

@ -212,6 +212,28 @@ describe('SharePlayer', () => {
expect(createdLinks[0]).not.toBeInTheDocument()
})
it('fallback to share id if description is empty', () => {
configModule.shareInfo.description = ''
render(
<TestContext>
<SharePlayer />
</TestContext>,
)
capturedCustomDownloader({ src: '/share/s/track-1' })
fireEvent.click(
screen.getByText('resources.share.actions.download.allTracks'),
)
expect(createdLinks).toHaveLength(1)
expect(createdLinks[0].href).toContain('/share/d/share-1')
expect(createdLinks[0].download).toBe('share-1.zip')
expect(createdLinks[0].click).toHaveBeenCalled()
expect(createdLinks[0]).not.toBeInTheDocument()
})
it('closes the dialog after clicking "All Tracks"', async () => {
render(
<TestContext>