fix(web): say what to do when Discover starts from a listening that is empty

Found against a real server: with the setting on and nothing played, the answer is empty with no seeds. The page now says to play something or pick an artist, instead of a plain 'no suggestions'.
This commit is contained in:
tgiachi 2026-11-12 14:12:57 +01:00
commit 0198a6d10b
4 changed files with 13 additions and 1 deletions

View file

@ -78,6 +78,7 @@
"fromListening": "Started from your listening: {{names}}",
"onlyNew": "Only artists I do not have",
"none": "No suggestions yet.",
"nothingPlayed": "You have not played anything to start from yet. Play something, or pick an artist above.",
"partial": "Last.fm could not be reached for some artists, so this list may be shorter.",
"busy": "Discover is busy with another request. Try again in a moment.",
"retryIn": "Try again in {{seconds}} s",

View file

@ -78,6 +78,7 @@
"fromListening": "Partito dai tuoi ascolti: {{names}}",
"onlyNew": "Solo artisti che non ho",
"none": "Ancora nessun suggerimento.",
"nothingPlayed": "Non hai ancora ascoltato niente da cui partire. Ascolta qualcosa, oppure scegli un artista qui sopra.",
"partial": "Last.fm non era raggiungibile per alcuni artisti, quindi la lista può essere più corta.",
"busy": "Discover è occupato con un'altra richiesta. Riprova tra poco.",
"retryIn": "Riprova tra {{seconds}} s",

View file

@ -144,6 +144,13 @@ test('when Last.fm failed for some artists the rest is shown with a warning', as
expect(screen.getByText('Last.fm could not be reached for some artists, so this list may be shorter.')).toBeInTheDocument()
})
test('starting from a listening that is empty says to play something, not just "nothing"', async () => {
mockFetch(routes(true, { 'GET /api/v1/discover': () => answer({ from_listening: true, seeds: [], items: [] }) }))
renderTab()
expect(await screen.findByText('You have not played anything to start from yet. Play something, or pick an artist above.')).toBeInTheDocument()
expect(screen.queryByText('No suggestions yet.')).not.toBeInTheDocument()
})
test('an empty answer says there is nothing yet', async () => {
mockFetch(routes(true, { 'GET /api/v1/discover': () => answer({ items: [] }) }))
renderTab()

View file

@ -101,7 +101,10 @@ export default function SuggestionsTab() {
</p>
)}
{data.items.length === 0 ? (
<EmptyMessage>{t('discover.none')}</EmptyMessage>
<EmptyMessage>
{/* Listening was the only start and it is empty: say what to do, not just "nothing". */}
{data.from_listening && data.seeds.length === 0 && seeds.length === 0 ? t('discover.nothingPlayed') : t('discover.none')}
</EmptyMessage>
) : (
<ul className="flex flex-col gap-3">
{data.items.map((item) => (