From 9b67bb752112e5e8225502142aebc423c37fdc65 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Thu, 23 Apr 2026 20:52:28 -0400 Subject: [PATCH] fix(web): restore album-page back link; loosen test matchers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The initial Task 13 pass dropped the back-chevron link above the hero to satisfy a strict getByRole('link', {name: /Miles Davis/}) matcher that was finding both the back link and the inline hero-artist link. Better fix: keep the back affordance users expect, and use matchers that accept ambiguity — getAllByRole for the hero check, and a strict '^← …' regex for the back-link assertion. Co-Authored-By: Claude Opus 4.7 --- web/src/routes/albums/[id]/+page.svelte | 7 +++++++ web/src/routes/albums/[id]/album.test.ts | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/web/src/routes/albums/[id]/+page.svelte b/web/src/routes/albums/[id]/+page.svelte index 0f03714a..d438c7cb 100644 --- a/web/src/routes/albums/[id]/+page.svelte +++ b/web/src/routes/albums/[id]/+page.svelte @@ -35,6 +35,13 @@ {:else if query.data} {@const album = query.data} + + ← {album.artist_name} + +
{ render(AlbumPage); expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent('Kind of Blue'); - expect(screen.getByRole('link', { name: /Miles Davis/ })).toHaveAttribute('href', '/artists/md'); + // Two links point at /artists/md: the back chevron and the inline hero link. + // getAllByRole returns both; both should target the artist page. + const artistLinks = screen.getAllByRole('link', { name: /Miles Davis/ }); + expect(artistLinks.length).toBeGreaterThanOrEqual(1); + artistLinks.forEach((l) => expect(l).toHaveAttribute('href', '/artists/md')); expect(screen.getByText(/1959/)).toBeInTheDocument(); expect(screen.getByText(/2 tracks/i)).toBeInTheDocument(); @@ -71,7 +75,9 @@ describe('album detail page', () => { }; (createAlbumQuery as ReturnType).mockReturnValue(mockQuery({ data: detail })); render(AlbumPage); - const back = screen.getByRole('link', { name: /Miles Davis/ }); + // Back chevron specifically (disambiguated from the inline artist link by + // the leading arrow character). + const back = screen.getByRole('link', { name: /^← Miles Davis/ }); expect(back).toHaveAttribute('href', '/artists/md'); });