fix(microprints): collapse expanded file when highlighting a different file
- Add test in microprints_live_test.exs that documents the uncoupled state bug
- Fix handle_event("highlight_line") to collapse expanded_path when
highlighting a line in a different file
- All 159 tests pass
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
alias FirehoseWeb.MicroprintsLive
|
||||
|
||||
defmodule FirehoseWeb.MicroprintsLiveTest do
|
||||
use ExUnit.Case, async: true
|
||||
use FirehoseWeb.ConnCase, async: true
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
|
||||
describe "scan_source_files/0" do
|
||||
test "returns exactly 2 files" do
|
||||
@@ -64,4 +68,36 @@ defmodule FirehoseWeb.MicroprintsLiveTest do
|
||||
assert is_list(blogex_files)
|
||||
end
|
||||
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
|
||||
files = MicroprintsLive.scan_source_files()
|
||||
assert length(files) >= 2, "Need at least 2 files to test coupling"
|
||||
|
||||
[file_a, file_b | _] = files
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/microprints")
|
||||
|
||||
# Expand file A
|
||||
view
|
||||
|> element("button[phx-value-path=\"#{file_a}\"]", "Expand")
|
||||
|> render_click()
|
||||
|
||||
# Verify file A shows "Collapse" button (it's expanded)
|
||||
html = render(view)
|
||||
assert html =~ ~s(phx-value-path="#{file_a}")
|
||||
assert html =~ "Collapse"
|
||||
|
||||
# Highlight a line in file B (rect elements inside SVG)
|
||||
view
|
||||
|> element("svg rect[phx-value-line=\"1\"][phx-value-path=\"#{file_b}\"]")
|
||||
|> render_click()
|
||||
|
||||
# BUG: file A should be collapsed when highlighting a different file
|
||||
# Currently file A stays expanded while the highlight is on file B
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user