diff --git a/web/src/lib/components/ArtistRow.svelte b/web/src/lib/components/ArtistRow.svelte deleted file mode 100644 index 33fd5698..00000000 --- a/web/src/lib/components/ArtistRow.svelte +++ /dev/null @@ -1,29 +0,0 @@ - - -
- - - {artist.name} - {countLabel} - - - - -
diff --git a/web/src/lib/components/ArtistRow.test.ts b/web/src/lib/components/ArtistRow.test.ts deleted file mode 100644 index 5ff56b58..00000000 --- a/web/src/lib/components/ArtistRow.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { describe, expect, test, vi } from 'vitest'; -import { render, screen } from '@testing-library/svelte'; -import { readable } from 'svelte/store'; -import ArtistRow from './ArtistRow.svelte'; -import type { ArtistRef } from '$lib/api/types'; - -vi.mock('$lib/api/likes', () => ({ - createLikedIdsQuery: () => readable({ - data: { track_ids: [], album_ids: [], artist_ids: [] }, - isPending: false, - isError: false - }), - likeEntity: vi.fn(), - unlikeEntity: vi.fn() -})); - -vi.mock('@tanstack/svelte-query', async (orig) => { - const actual = (await orig()) as Record; - return { ...actual, useQueryClient: () => ({}) }; -}); - -const artist: ArtistRef = { id: 'abc', name: 'alice', sort_name: 'alice', album_count: 12, cover_url: '' }; - -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(screen.getByText('alice')).toBeInTheDocument(); - expect(screen.getByText('12 albums')).toBeInTheDocument(); - expect(screen.getByText('A')).toBeInTheDocument(); - }); - - test('singular "1 album" when album_count is 1', () => { - render(ArtistRow, { props: { artist: { ...artist, album_count: 1 } } }); - expect(screen.getByText('1 album')).toBeInTheDocument(); - }); - - 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(); - }); -}); diff --git a/web/src/lib/components/Shell.svelte b/web/src/lib/components/Shell.svelte index 80d7af57..5d69f6a6 100644 --- a/web/src/lib/components/Shell.svelte +++ b/web/src/lib/components/Shell.svelte @@ -22,7 +22,9 @@ } const navItems = [ - { href: '/', label: 'Library' }, + { href: '/', label: 'Home' }, + { href: '/library/artists', label: 'Artists' }, + { href: '/library/albums', label: 'Albums' }, { href: '/library/liked', label: 'Liked' }, { href: '/library/hidden', label: 'Hidden' }, { href: '/search', label: 'Search' }, diff --git a/web/src/lib/components/Shell.test.ts b/web/src/lib/components/Shell.test.ts index b3f24b90..d1885fb9 100644 --- a/web/src/lib/components/Shell.test.ts +++ b/web/src/lib/components/Shell.test.ts @@ -39,9 +39,16 @@ describe('Shell', () => { expect(screen.getByText('alice')).toBeInTheDocument(); }); - test('renders nav items including Discover and Requests between Search and Playlists', () => { + test('renders nav items in expected order', () => { render(Shell); - expect(screen.getByRole('link', { name: 'Library' })).toHaveAttribute('href', '/'); + const labels = ['Home', 'Artists', 'Albums', 'Liked', 'Hidden', 'Search', + 'Discover', 'Requests', 'Playlists', 'Settings']; + for (const label of labels) { + expect(screen.getByRole('link', { name: label })).toBeInTheDocument(); + } + expect(screen.getByRole('link', { name: 'Home' })).toHaveAttribute('href', '/'); + expect(screen.getByRole('link', { name: 'Artists' })).toHaveAttribute('href', '/library/artists'); + expect(screen.getByRole('link', { name: 'Albums' })).toHaveAttribute('href', '/library/albums'); expect(screen.getByRole('link', { name: 'Search' })).toHaveAttribute('href', '/search'); expect(screen.getByRole('link', { name: 'Discover' })).toHaveAttribute('href', '/discover'); expect(screen.getByRole('link', { name: 'Requests' })).toHaveAttribute('href', '/requests'); diff --git a/web/src/routes/library/liked/+page.svelte b/web/src/routes/library/liked/+page.svelte index 1c722f70..a905f4a1 100644 --- a/web/src/routes/library/liked/+page.svelte +++ b/web/src/routes/library/liked/+page.svelte @@ -4,7 +4,7 @@ createLikedAlbumsInfiniteQuery, createLikedArtistsInfiniteQuery } from '$lib/api/likes'; - import ArtistRow from '$lib/components/ArtistRow.svelte'; + import ArtistCard from '$lib/components/ArtistCard.svelte'; import AlbumCard from '$lib/components/AlbumCard.svelte'; import TrackRow from '$lib/components/TrackRow.svelte'; @@ -33,9 +33,9 @@ {#if artistsTotal === 0}

No liked artists yet.

{:else} -
+
{#each artists as a (a.id)} - + {/each}
{#if artistsQuery?.hasNextPage} diff --git a/web/src/routes/search/+page.svelte b/web/src/routes/search/+page.svelte index c5501398..c21dc1c0 100644 --- a/web/src/routes/search/+page.svelte +++ b/web/src/routes/search/+page.svelte @@ -1,7 +1,7 @@