diff --git a/test/music_library_web/live/wishlist_live/show_test.exs b/test/music_library_web/live/wishlist_live/show_test.exs new file mode 100644 index 00000000..492cdc96 --- /dev/null +++ b/test/music_library_web/live/wishlist_live/show_test.exs @@ -0,0 +1,46 @@ +defmodule MusicLibraryWeb.WishlistLive.ShowTest do + use MusicLibraryWeb.ConnCase + + import MusicLibrary.RecordsFixtures + alias MusicLibrary.Records.Record + + describe "Edit record from show page" do + test "can navigate to the record edit form", %{conn: conn} do + record = record() + + conn + |> visit(~p"/wishlist/#{record.id}") + |> assert_has("a", text: "Edit") + |> click_link("Edit") + |> assert_path(~p"/wishlist/#{record}/show/edit") + end + end + + describe "Show record" do + test "it includes all needed information", %{conn: conn} do + record = record(purchased_at: nil) + cover_url = ~p"/covers/#{record.id}?vsn=#{record.cover_hash}" + + session = + conn + |> visit(~p"/wishlist/#{record.id}") + |> assert_has("h2", text: escape(record.title)) + |> assert_has("p", text: record.release) + |> assert_has("p", text: Record.format_long_label(record.format)) + |> assert_has("p", text: Record.type_long_label(record.type)) + |> assert_has("dd", text: record.id) + |> assert_has("a", text: record.musicbrainz_id) + |> assert_has("dd", text: Record.format_as_date(record.inserted_at)) + |> assert_has("dd", text: Record.format_as_date(record.updated_at)) + |> assert_has("img[src='#{cover_url}']") + + for artist <- record.artists do + assert_has(session, "a", text: escape(artist.name)) + end + + for genre <- record.genres do + assert_has(session, "a", text: genre) + end + end + end +end