yak(behavior-tests-editorial-liveviews-microprints-editor-dashboard-llh3): behavior tests: editorial LiveViews (microprints, editor dashboard)

This commit is contained in:
Willem van den Ende
2026-10-28 22:27:59 +00:00
parent 44a343ae72
commit b72446b80e
5 changed files with 120 additions and 31 deletions
+43
View File
@@ -0,0 +1,43 @@
defmodule FirehoseWeb.MicroprintsCase do
@moduledoc """
Helpers for driving the `/microprints` LiveView.
Both `FirehoseWeb.MicroprintsLiveTest` and `FirehoseWeb.SourceViewerTest` walk
the same page through the same two controls (the per-card Expand/Collapse
button and the microprint rects), so the mechanics live here instead of being
re-implemented in each test module.
A plain module, imported by the tests, rather than a `use`-able case template:
the LiveView tests own their own setup and only share these three actions.
"""
import Phoenix.LiveViewTest
@doc """
Clicks the Expand control of the card for `path` and returns the render.
"""
def expand_file(view, path) do
view
|> element(~s(button[phx-value-path="#{path}"]), "Expand")
|> render_click()
end
@doc """
Clicks the Collapse control of the card for `path` and returns the render.
"""
def collapse_file(view, path) do
view
|> element(~s(button[phx-value-path="#{path}"]), "Collapse")
|> render_click()
end
@doc """
Clicks a single line of a microprint, highlighting it in the source viewer.
The microprint renders several rect segments per line, so `element/3` cannot
pick one; the `highlight_line` event is dispatched directly instead.
"""
def click_microprint_rect(view, path, line) do
render_click(view, "highlight_line", %{"line" => Integer.to_string(line), "path" => path})
end
end