Convert phoenix_test assertions to simplified syntax

This commit is contained in:
Claudio Ortolina
2026-03-06 06:41:06 +00:00
parent 348d062822
commit c3cb510892
13 changed files with 153 additions and 153 deletions
@@ -48,7 +48,7 @@ defmodule MusicLibraryWeb.ScrobbleLive.IndexTest do
test "shows connect Last.fm button when not authenticated", %{conn: conn} do
conn
|> visit(~p"/scrobble")
|> assert_has("a", text: "Connect your Last.fm account")
|> assert_has("a", "Connect your Last.fm account")
end
test "search with results shows release groups", %{conn: conn} do
@@ -63,8 +63,8 @@ defmodule MusicLibraryWeb.ScrobbleLive.IndexTest do
# Process the {:perform_search, query} message
render(view)
end)
|> assert_has("h3", text: "Release Groups")
|> assert_has("p", text: "Marbles")
|> assert_has("h3", "Release Groups")
|> assert_has("p", "Marbles")
end
test "search with empty query does not trigger search", %{conn: conn} do
@@ -76,7 +76,7 @@ defmodule MusicLibraryWeb.ScrobbleLive.IndexTest do
|> form("form[phx-submit='search']", %{query: ""})
|> render_submit()
end)
|> refute_has("h3", text: "Release Groups")
|> refute_has("h3", "Release Groups")
end
test "select release group shows releases", %{conn: conn} do
@@ -102,8 +102,8 @@ defmodule MusicLibraryWeb.ScrobbleLive.IndexTest do
# Process the {:fetch_releases, release_group} message
render(view)
end)
|> assert_has("h3", text: "Releases for")
|> assert_has("button", text: "Back")
|> assert_has("h3", "Releases for")
|> assert_has("button", "Back")
end
test "clear selection goes back to release groups", %{conn: conn} do
@@ -130,8 +130,8 @@ defmodule MusicLibraryWeb.ScrobbleLive.IndexTest do
view
|> render_click("clear_selection", %{})
end)
|> assert_has("h3", text: "Release Groups")
|> refute_has("h3", text: "Releases for")
|> assert_has("h3", "Release Groups")
|> refute_has("h3", "Releases for")
end
end
@@ -149,7 +149,7 @@ defmodule MusicLibraryWeb.ScrobbleLive.IndexTest do
render(view)
end)
|> assert_has("p", text: "No release groups found")
|> assert_has("p", "No release groups found")
end
end
end
@@ -49,20 +49,20 @@ defmodule MusicLibraryWeb.ScrobbleLive.ShowTest do
test "renders release details", %{conn: conn} do
conn
|> visit(~p"/scrobble/#{@release_id}")
|> assert_has("h2", text: "Marbles")
|> assert_has("a", text: "Back to search")
|> assert_has("h2", "Marbles")
|> assert_has("a", "Back to search")
end
test "shows Last.fm not connected alert when no session key", %{conn: conn} do
conn
|> visit(~p"/scrobble/#{@release_id}")
|> assert_has("div", text: "You need to connect your Last.fm account")
|> assert_has("div", "You need to connect your Last.fm account")
end
test "displays tracks", %{conn: conn} do
conn
|> visit(~p"/scrobble/#{@release_id}")
|> assert_has("h3", text: "Tracks")
|> assert_has("h3", "Tracks")
end
end
@@ -72,7 +72,7 @@ defmodule MusicLibraryWeb.ScrobbleLive.ShowTest do
test "does not show Last.fm not connected alert", %{conn: conn} do
conn
|> visit(~p"/scrobble/#{@release_id}")
|> refute_has("[data-part='title']", text: "Last.fm not connected")
|> refute_has("[data-part='title']", "Last.fm not connected")
end
test "scrobble full release", %{conn: conn} do
@@ -82,7 +82,7 @@ defmodule MusicLibraryWeb.ScrobbleLive.ShowTest do
|> unwrap(fn view ->
render_click(view, "scrobble_release", %{})
end)
|> assert_has("#toast-group", text: "Release scrobbled successfully")
|> assert_has("#toast-group", "Release scrobbled successfully")
end
test "scrobble single medium", %{conn: conn} do
@@ -92,7 +92,7 @@ defmodule MusicLibraryWeb.ScrobbleLive.ShowTest do
|> unwrap(fn view ->
render_click(view, "scrobble_medium", %{"medium_number" => "1"})
end)
|> assert_has("#toast-group", text: "Disc scrobbled successfully")
|> assert_has("#toast-group", "Disc scrobbled successfully")
end
test "toggle track selection", %{conn: conn} do
@@ -120,7 +120,7 @@ defmodule MusicLibraryWeb.ScrobbleLive.ShowTest do
# Then scrobble selected
render_click(view, "scrobble_selected_tracks", %{})
end)
|> assert_has("#toast-group", text: "Selected tracks scrobbled successfully")
|> assert_has("#toast-group", "Selected tracks scrobbled successfully")
end
end