mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-31 07:30:32 +00:00
fix(SharePlayer): fallback to playlist ID for empty playlist descriptions
This commit is contained in:
parent
9a176781e6
commit
54e9f61c95
@ -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)
|
||||
}}
|
||||
|
||||
@ -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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user