Fix credo quote-sigil warning in microprints_live_test.exs

Replace double-quoted string with escaped quotes in element selector
with a ~s sigil to satisfy Credo's 'More than 3 quotes found inside
string literal' readability check.

Includes formatting changes from mix format (ran via make check).
This commit is contained in:
Firehose Bot
2026-05-18 21:35:28 +01:00
parent a9e746d520
commit a4bca75946
4 changed files with 50 additions and 9 deletions
+14 -5
View File
@@ -80,7 +80,8 @@ defmodule FirehoseWeb.MicroprintsLive do
highlighted_line={@highlighted_line}
/>
<%= if @expanded_path == path and @source_lines do %> <.source_viewer
<%= if @expanded_path == path and @source_lines do %>
<.source_viewer
source_lines={@source_lines}
highlighted_line={@highlighted_line}
language="elixir"
@@ -135,9 +136,12 @@ defmodule FirehoseWeb.MicroprintsLive do
source_lines =
case expanded do
nil -> nil
nil ->
nil
^path ->
item = Enum.find(socket.assigns.microprints, &(&1.path == path))
if item && item.source_dir do
abs_path = resolve_source_path(item.source_dir, path)
read_source(abs_path)
@@ -337,7 +341,12 @@ defmodule FirehoseWeb.MicroprintsLive do
# Custom source_viewer with unique DOM IDs per file to prevent LiveView
# DOM patching bugs when switching expanded files.
def source_viewer(assigns) do
assigns = assign(assigns, :viewer_id, "source-viewer-" <> Integer.to_string(:erlang.phash2(assigns.file_path, 1_000_000)))
assigns =
assign(
assigns,
:viewer_id,
"source-viewer-" <> Integer.to_string(:erlang.phash2(assigns.file_path, 1_000_000))
)
~H"""
<div
@@ -354,8 +363,8 @@ defmodule FirehoseWeb.MicroprintsLive do
id={"line-#{num}"}
class={"sv-line" <> if @highlighted_line == num, do: " sv-line-highlighted", else: ""}
>
<span class="sv-line-number"><%= num %></span>
<span class="sv-line-content"><%= line %></span>
<span class="sv-line-number">{num}</span>
<span class="sv-line-content">{line}</span>
</div>
<% end %>
</div>
@@ -70,7 +70,9 @@ defmodule FirehoseWeb.MicroprintsLiveTest do
end
describe "expanded_path and highlighted_path coupling" do
test "expanding file A and highlighting a line in file B should collapse file A", %{conn: conn} do
test "expanding file A and highlighting a line in file B should collapse file A", %{
conn: conn
} do
files = MicroprintsLive.scan_source_files()
assert length(files) >= 2, "Need at least 2 files to test coupling"
@@ -90,16 +92,19 @@ defmodule FirehoseWeb.MicroprintsLiveTest do
# Highlight a line in file B (rect elements inside SVG)
view
|> element("svg rect[phx-value-line=\"1\"][phx-value-path=\"#{file_b}\"]")
|> element(~s(svg rect[phx-value-line="1"][phx-value-path="#{file_b}"]))
|> render_click()
# file A should be collapsed when highlighting a different file
html = render(view)
refute html =~ "Collapse",
"file A should be collapsed after highlighting a different file, but the Collapse button is still visible (expanded_path is uncoupled from highlighted_path)"
end
test "switching expand from file A to file B shows each file's own source content", %{conn: conn} do
test "switching expand from file A to file B shows each file's own source content", %{
conn: conn
} do
files = MicroprintsLive.scan_source_files()
assert length(files) >= 2, "Need at least 2 files to test source switching"
@@ -148,8 +153,10 @@ defmodule FirehoseWeb.MicroprintsLiveTest do
{:ok, view, _html} = live(conn, ~p"/microprints?expanded=#{file_a}")
html = render(view)
assert html =~ "Collapse",
"Expanded file should show Collapse button when restored from URL param"
assert html =~ ~s(phx-value-path="#{file_a}")
end
@@ -157,6 +164,7 @@ defmodule FirehoseWeb.MicroprintsLiveTest do
{:ok, view, _html} = live(conn, ~p"/microprints?expanded=nonexistent.ex")
html = render(view)
refute html =~ "Collapse",
"Nonexistent expanded path should not show Collapse"
end
@@ -173,6 +181,7 @@ defmodule FirehoseWeb.MicroprintsLiveTest do
# URL should contain expanded param after clicking Expand
html = render(view)
assert html =~ "Collapse",
"File should remain expanded after push_patch updates URL"
end
@@ -25,8 +25,10 @@ defmodule FirehoseWeb.SourceViewerTest do
assert has_element?(view, "#line-1"),
"Line 1 should exist in the source viewer"
assert has_element?(view, "#line-2"),
"Line 2 should exist in the source viewer"
assert has_element?(view, "#line-3"),
"Line 3 should exist in the source viewer"
end
@@ -54,10 +56,12 @@ defmodule FirehoseWeb.SourceViewerTest do
expand_file(view, file)
click_microprint_rect(view, file, 1)
assert has_element?(view, "#line-1.sv-line-highlighted"),
"Line 1 should be highlighted after first click"
click_microprint_rect(view, file, 1)
refute has_element?(view, "#line-1.sv-line-highlighted"),
"Line 1 should no longer be highlighted after second click"
end
@@ -66,7 +70,8 @@ defmodule FirehoseWeb.SourceViewerTest do
files = MicroprintsLive.scan_source_files()
file = List.first(files)
{:ok, view, _html} = live(conn, ~p"/microprints?expanded=#{file}&line=1&highlighted=#{file}")
{:ok, view, _html} =
live(conn, ~p"/microprints?expanded=#{file}&line=1&highlighted=#{file}")
assert has_element?(view, "#line-1.sv-line-highlighted"),
"Line 1 should be highlighted when restored from URL params"