feat(ui): add an explainArtwork data provider method

This commit is contained in:
Deluan 2026-09-03 23:30:39 -04:00
commit d17ef212ab
2 changed files with 23 additions and 0 deletions

View file

@ -229,6 +229,10 @@ const wrapperDataProvider = {
httpClient(`${REST_URL}/metadata/${REFRESH_KIND[resource]}/${id}/refresh`, {
method: 'POST',
}).then(() => ({ data: { id } })),
explainArtwork: (resource, id) =>
httpClient(
`${REST_URL}/artwork/explain?kind=${REFRESH_KIND[resource]}&id=${encodeURIComponent(id)}`,
).then(({ json }) => ({ data: json })),
}
export default wrapperDataProvider

View file

@ -120,4 +120,23 @@ describe('wrapperDataProvider', () => {
).resolves.toEqual({ data: { id: 'al-1' } })
})
})
describe('explainArtwork', () => {
it('requests the artist kind prefix', async () => {
mockHttpClient.mockResolvedValue({ json: { name: 'Radiohead' } })
const result = await wrapperDataProvider.explainArtwork('artist', 'ar-1')
expect(mockHttpClient).toHaveBeenCalledWith(
expect.stringContaining('/artwork/explain?kind=ar&id=ar-1'),
)
expect(result).toEqual({ data: { name: 'Radiohead' } })
})
it('requests the album kind prefix', async () => {
mockHttpClient.mockResolvedValue({ json: {} })
await wrapperDataProvider.explainArtwork('album', 'al-1')
expect(mockHttpClient).toHaveBeenCalledWith(
expect.stringContaining('kind=al&id=al-1'),
)
})
})
})