ML-169.10: drop socket-internals delete tests

Remove 12 unit tests that accessed socket internals via :sys.get_state
and called handle_async directly — these leak implementation details and
error/exit paths can't be reached through the DOM.

Keep the 3 integration delete tests that use pure DOM assertions: visit,
assert_has, click, refute_has, render_async, DB verification.
This commit is contained in:
Claudio Ortolina
2026-05-22 16:27:42 +01:00
parent b10be7ba3c
commit 3f2e5f2e27
3 changed files with 0 additions and 209 deletions
@@ -4,7 +4,6 @@ defmodule MusicLibraryWeb.ScrobbledTracksLiveTest do
import MusicLibrary.ScrobbledTracksFixtures
alias MusicLibrary.ListeningStats
alias MusicLibraryWeb.ScrobbledTracksLive.Index, as: ScrobbledTracksIndex
@valid_track_attrs %{
title: "Updated Track Title",
@@ -156,75 +155,4 @@ defmodule MusicLibraryWeb.ScrobbledTracksLiveTest do
end
end
end
describe "handle_async delete_track" do
import Phoenix.LiveViewTest
defp build_socket(conn) do
{:ok, view, _html} = live(conn, ~p"/scrobbled-tracks")
state = :sys.get_state(view.pid)
state.socket
end
test "{:ok, {{:ok, _}, _}} is a no-op", %{conn: conn} do
track = track_fixture()
element = %{track: track}
socket = build_socket(conn)
socket = Phoenix.LiveView.stream_delete(socket, :tracks, element)
assert {:noreply, _socket} =
ScrobbledTracksIndex.handle_async(
{:delete_track, track.scrobbled_at_uts},
{:ok, {{:ok, track}, element}},
socket
)
end
test "{:ok, {{:error, _}, _}} does not crash", %{conn: conn} do
track = track_fixture()
element = %{track: track}
socket = build_socket(conn)
socket = Phoenix.LiveView.stream_delete(socket, :tracks, element)
assert {:noreply, _socket} =
ScrobbledTracksIndex.handle_async(
{:delete_track, track.scrobbled_at_uts},
{:ok, {{:error, :not_found}, element}},
socket
)
end
test "{:exit, _} does not crash", %{conn: conn} do
track = track_fixture()
element = %{track: track}
socket = build_socket(conn)
socket = Phoenix.LiveView.stream_delete(socket, :tracks, element)
assert {:noreply, _socket} =
ScrobbledTracksIndex.handle_async(
{:delete_track, track.scrobbled_at_uts},
{:exit, :killed},
socket
)
end
test "{:exit, _} uses generic message, never leaks reason", %{conn: conn} do
track = track_fixture()
element = %{track: track}
socket = build_socket(conn)
socket = Phoenix.LiveView.stream_delete(socket, :tracks, element)
{:noreply, socket} =
ScrobbledTracksIndex.handle_async(
{:delete_track, track.scrobbled_at_uts},
{:exit, {:killed, "some stacktrace that should not leak"}},
socket
)
assert socket.assigns[:toasts_sync]
[toast | _] = socket.assigns.toasts_sync
refute inspect(toast) =~ "stacktrace"
refute inspect(toast) =~ "killed"
end
end
end