diff --git a/web/src/lib/components/PlaylistCard.test.ts b/web/src/lib/components/PlaylistCard.test.ts index 95258924..cd33c451 100644 --- a/web/src/lib/components/PlaylistCard.test.ts +++ b/web/src/lib/components/PlaylistCard.test.ts @@ -32,9 +32,15 @@ describe('PlaylistCard', () => { }); test('renders cover image when cover_url is set', () => { - render(PlaylistCard, { props: { playlist: { ...base, cover_url: '/api/playlists/p-1/cover' } } }); - const img = screen.getByRole('img'); - expect(img.getAttribute('src')).toBe('/api/playlists/p-1/cover'); + // The has alt="" (decorative — the playlist name is in the + // sibling text below, so duplicating it for screen readers would be + // noise). Empty alt makes Testing Library expose role="presentation" + // instead of role="img"; query the DOM directly so the assertion + // doesn't fight the (correct) a11y choice. + const { container } = render(PlaylistCard, { props: { playlist: { ...base, cover_url: '/api/playlists/p-1/cover' } } }); + const img = container.querySelector('img'); + expect(img).not.toBeNull(); + expect(img!.getAttribute('src')).toBe('/api/playlists/p-1/cover'); }); test('renders glyph fallback when cover_url is empty', () => {