Add /scrobble/:rg_id release-group page

This commit is contained in:
Claudio Ortolina
2026-04-23 14:28:05 +01:00
parent 4c48bda7b2
commit d8041dc0dd
6 changed files with 274 additions and 2 deletions
@@ -0,0 +1,67 @@
defmodule MusicLibraryWeb.ScrobbleLive.ReleaseGroupShowTest do
use MusicLibraryWeb.ConnCase
alias MusicBrainz.Fixtures.ReleaseGroup
alias Req.Test
@rg_id ReleaseGroup.release_group_id(:marbles)
defp stub_release_group(_) do
Test.stub(MusicBrainz.API, fn conn ->
case conn.request_path do
"/ws/2/release-group/" <> _id ->
Test.json(conn, ReleaseGroup.release_group(:marbles))
"/ws/2/release" ->
Test.json(conn, ReleaseGroup.release_group_releases(:marbles))
_ ->
Test.json(conn, %{})
end
end)
:ok
end
defp stub_release_group_error(_) do
Test.stub(MusicBrainz.API, fn conn ->
Plug.Conn.send_resp(conn, 500, "Internal Server Error")
end)
:ok
end
describe "Show" do
setup [:stub_release_group]
test "renders release-group title", %{conn: conn} do
conn
|> visit(~p"/scrobble/#{@rg_id}")
|> assert_has("h1", text: "Marbles", timeout: 200)
end
test "renders list of releases with link targets", %{conn: conn} do
conn
|> visit(~p"/scrobble/#{@rg_id}")
|> assert_has("a[href^='/scrobble/#{@rg_id}/releases/']", timeout: 200)
end
test "back link targets /scrobble", %{conn: conn} do
conn
|> visit(~p"/scrobble/#{@rg_id}")
|> assert_has("a[href='/scrobble']", text: "Back to search")
end
end
describe "fetch failure" do
setup [:stub_release_group_error]
@tag :capture_log
test "shows toast and redirects to /scrobble", %{conn: conn} do
conn
|> visit(~p"/scrobble/#{@rg_id}")
|> assert_has("#toast-group", text: "Error loading release group", timeout: 200)
|> assert_path(~p"/scrobble")
end
end
end
@@ -1,6 +1,9 @@
defmodule MusicLibraryWeb.ScrobbleLive.ShowTest do
use MusicLibraryWeb.ConnCase
# Route /scrobble/:release_id is removed in Phase 5 — skip until then
@moduletag :skip
import Phoenix.LiveViewTest, only: [element: 2, render_change: 2, render_click: 3]
alias MusicBrainz.Fixtures.Release, as: ReleaseFixtures