feat(web): add ArtistRow component

One row in the artists list: avatar initial, name, album count,
chevron. Entire row is an <a> for click + keyboard activation.
This commit is contained in:
2026-04-23 18:18:52 -04:00
parent ce6b79ec95
commit a1252c1ef4
2 changed files with 52 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import { describe, expect, test } from 'vitest';
import { render, screen } from '@testing-library/svelte';
import ArtistRow from './ArtistRow.svelte';
import type { ArtistRef } from '$lib/api/types';
const artist: ArtistRef = { id: 'abc', name: 'alice', album_count: 12 };
describe('ArtistRow', () => {
test('renders initial, name, album count inside a link to /artists/:id', () => {
render(ArtistRow, { props: { artist } });
const link = screen.getByRole('link');
expect(link).toHaveAttribute('href', '/artists/abc');
expect(link).toHaveTextContent('alice');
expect(link).toHaveTextContent('12 albums');
expect(link).toHaveTextContent('A'); // initial letter
});
test('singular "1 album" when album_count is 1', () => {
render(ArtistRow, { props: { artist: { ...artist, album_count: 1 } } });
expect(screen.getByRole('link')).toHaveTextContent('1 album');
});
test('empty name still renders a safe initial', () => {
render(ArtistRow, { props: { artist: { ...artist, name: '' } } });
// No crash; initial container present but empty or a placeholder char.
expect(screen.getByRole('link')).toBeInTheDocument();
});
});