diff --git a/lib/music_library_web/live/artist_live/show.html.heex b/lib/music_library_web/live/artist_live/show.html.heex
index 010e45f3..9bcaf1d0 100644
--- a/lib/music_library_web/live/artist_live/show.html.heex
+++ b/lib/music_library_web/live/artist_live/show.html.heex
@@ -62,6 +62,7 @@
<%!-- TODO: replace with OSS version --%>
@@ -101,6 +102,7 @@
<%!-- TODO: replace with OSS version --%>
diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot
index 7291df66..8ddf176f 100644
--- a/priv/gettext/default.pot
+++ b/priv/gettext/default.pot
@@ -326,7 +326,7 @@ msgid "Welcome to your Music Library"
msgstr ""
#: lib/music_library_web/components/layouts/app.html.heex:20
-#: lib/music_library_web/live/artist_live/show.html.heex:100
+#: lib/music_library_web/live/artist_live/show.html.heex:101
#: lib/music_library_web/live/wishlist_live/index.ex:76
#: lib/music_library_web/live/wishlist_live/show.ex:138
#, elixir-autogen, elixir-format
@@ -453,8 +453,8 @@ msgstr ""
msgid "Dev dashboard"
msgstr ""
-#: lib/music_library_web/live/artist_live/show.html.heex:80
-#: lib/music_library_web/live/artist_live/show.html.heex:119
+#: lib/music_library_web/live/artist_live/show.html.heex:81
+#: lib/music_library_web/live/artist_live/show.html.heex:121
#, elixir-autogen, elixir-format
msgid "View details"
msgstr ""
diff --git a/test/music_library_web/live/artist_live/show_test.exs b/test/music_library_web/live/artist_live/show_test.exs
index d58ded89..cf3363c4 100644
--- a/test/music_library_web/live/artist_live/show_test.exs
+++ b/test/music_library_web/live/artist_live/show_test.exs
@@ -10,16 +10,19 @@ defmodule MusicLibraryWeb.ArtistLive.ShowTest do
setup :verify_on_exit!
+ defp escape(string) do
+ string
+ |> Phoenix.HTML.html_escape()
+ |> Phoenix.HTML.safe_to_string()
+ end
+
describe "Show artist" do
- test "it shows records from the collection", %{conn: conn} do
+ test "it shows the artist bio and play count", %{conn: conn} do
current_time = DateTime.utc_now()
collection_record =
record_fixture_with_artist("Steven Wilson", %{purchased_at: current_time})
- _wishlist_record = record_fixture_with_artist("Steven Wilson", %{purchased_at: nil})
- _other_record = record_fixture_with_artist("Porcupine Tree", %{purchased_at: current_time})
-
[artist] = collection_record.artists
artist_musicbrainz_id = artist.musicbrainz_id
@@ -33,7 +36,73 @@ defmodule MusicLibraryWeb.ArtistLive.ShowTest do
{:ok, show_live, _html} = live(conn, ~p"/artists/#{artist_musicbrainz_id}")
- assert render_async(show_live) =~ "Steven Wilson"
+ render_async(show_live)
+
+ # play count
+ assert has_element?(show_live, "span", "123")
+
+ assert has_element?(show_live, "summary", "Biography")
+
+ assert element(show_live, "details")
+ end
+
+ test "it gracefully handles errors in fetching bio and play count", %{conn: conn} do
+ current_time = DateTime.utc_now()
+
+ collection_record =
+ record_fixture_with_artist("Steven Wilson", %{purchased_at: current_time})
+
+ [artist] = collection_record.artists
+ artist_musicbrainz_id = artist.musicbrainz_id
+
+ expect(APIBehaviourMock, :get_artist_info, fn {:musicbrainz_id, ^artist_musicbrainz_id},
+ _config ->
+ {:error, :timeout}
+ end)
+
+ {:ok, show_live, _html} = live(conn, ~p"/artists/#{artist_musicbrainz_id}")
+
+ render_async(show_live)
+
+ # play count
+ refute has_element?(show_live, "span", "123")
+ assert has_element?(show_live, "div", "There was an error loading the play count")
+
+ refute has_element?(show_live, "summary", "Biography")
+ assert has_element?(show_live, "div", "There was an error loading the biography")
+ end
+
+ test "it shows records from the collection and the wishlist", %{conn: conn} do
+ current_time = DateTime.utc_now()
+
+ collection_record =
+ record_fixture_with_artist("Steven Wilson", %{
+ title: "The Raven that refused to sing",
+ purchased_at: current_time
+ })
+
+ wishlist_record =
+ record_fixture_with_artist("Steven Wilson", %{
+ title: "Grace for drowning",
+ purchased_at: nil
+ })
+
+ other_record = record_fixture_with_artist("Porcupine Tree", %{purchased_at: current_time})
+
+ [artist] = collection_record.artists
+ artist_musicbrainz_id = artist.musicbrainz_id
+
+ {:ok, show_live, _html} = live(conn, ~p"/artists/#{artist_musicbrainz_id}")
+
+ # collection records
+ assert has_element?(show_live, "#collection p", escape(collection_record.title))
+
+ # wishlist records
+ assert has_element?(show_live, "#wishlist p", escape(wishlist_record.title))
+
+ # other records
+ refute has_element?(show_live, "#collection p", escape(other_record.title))
+ refute has_element?(show_live, "#wishlist p", escape(other_record.title))
end
end
end