<%= render_slot(@inner_block) %>
- <%= for col <- @col do %><%= render_slot(col) %>,<% end %>
+ <%= for col <- @col do %>
+ <%= render_slot(col) %>,
+ <% end %>
"""
end
@@ -1555,7 +1556,9 @@ defmodule Phoenix.LiveView.DiffTest do
rendered = ~H"""
<%= for {component, index} <- Enum.with_index(@components, 1) do %>
- <%= if index > 1 do %><%= index %>: <%= component %><% end %>
+ <%= if index > 1 do %>
+ <%= index %>: <%= component %>
+ <% end %>
<% end %>
"""
@@ -1625,9 +1628,8 @@ defmodule Phoenix.LiveView.DiffTest do
defp tracking(assigns) do
~H"""
- <.live_component module={SlotComponent} :let={%{value: value}} id="TRACKING">
- WITH PARENT VALUE <%= @parent_value %>
- WITH VALUE <%= value %>
+ <.live_component :let={%{value: value}} module={SlotComponent} id="TRACKING">
+ WITH PARENT VALUE <%= @parent_value %> WITH VALUE <%= value %>
"""
end
diff --git a/test/phoenix_live_view/heex_extension_test.exs b/test/phoenix_live_view/heex_extension_test.exs
index be7da6dafa..050bffe8f2 100644
--- a/test/phoenix_live_view/heex_extension_test.exs
+++ b/test/phoenix_live_view/heex_extension_test.exs
@@ -25,76 +25,85 @@ defmodule Phoenix.LiveView.HEExExtensionTest do
test "renders live engine with live engine to string" do
assert Phoenix.View.render_to_string(View, "live_with_live.html", @assigns) ==
- "pre: pre\nlive: inner\npost: post"
+ "pre: pre\nlive: inner\npost: post"
end
test "renders live engine with comprehension to string" do
assigns = Map.put(@assigns, :points, [])
assert Phoenix.View.render_to_string(View, "live_with_comprehension.html", assigns) ==
- "pre: pre\n\npost: post"
+ "pre: pre\n\npost: post"
assigns = Map.put(@assigns, :points, [%{x: 1, y: 2}, %{x: 3, y: 4}])
assert Phoenix.View.render_to_string(View, "live_with_comprehension.html", assigns) ==
- "pre: pre\n\n x: 1\n live: inner\n y: 2\n\n x: 3\n live: inner\n y: 4\n\npost: post"
+ "pre: pre\n\n x: 1\n live: inner\n y: 2\n\n x: 3\n live: inner\n y: 4\n\npost: post"
end
test "renders live engine as is" do
assert %Rendered{static: ["live: ", ""], dynamic: ["inner"]} =
- Phoenix.View.render(View, "inner_live.html", @assigns) |> expand_rendered(true)
+ Phoenix.View.render(View, "inner_live.html", @assigns) |> expand_rendered(true)
end
test "renders live engine with nested live view" do
assert %Rendered{
- static: ["pre: ", "\n", "\npost: ", ""],
- dynamic: [
- "pre",
- %Rendered{dynamic: ["inner"], static: ["live: ", ""]},
- "post"
- ]
- } =
- Phoenix.View.render(View, "live_with_live.html", @assigns) |> expand_rendered(true)
+ static: ["pre: ", "\n", "\npost: ", ""],
+ dynamic: [
+ "pre",
+ %Rendered{dynamic: ["inner"], static: ["live: ", ""]},
+ "post"
+ ]
+ } =
+ Phoenix.View.render(View, "live_with_live.html", @assigns) |> expand_rendered(true)
end
test "renders live engine with nested dead view" do
assert %Rendered{
- static: ["pre: ", "\n", "\npost: ", ""],
- dynamic: ["pre", ["dead: ", "inner"], "post"]
- } =
- Phoenix.View.render(View, "live_with_dead.html", @assigns) |> expand_rendered(true)
+ static: ["pre: ", "\n", "\npost: ", ""],
+ dynamic: ["pre", ["dead: ", "inner"], "post"]
+ } =
+ Phoenix.View.render(View, "live_with_dead.html", @assigns) |> expand_rendered(true)
end
test "renders dead engine with nested live view" do
assert Phoenix.View.render(View, "dead_with_live.html", @assigns) ==
- {:safe, ["pre: ", "pre", "\n", ["live: ", "inner", ""], "\npost: ", "post"]}
+ {:safe, ["pre: ", "pre", "\n", ["live: ", "inner", ""], "\npost: ", "post"]}
end
test "renders dead engine with function component" do
assert %Rendered{
- static: ["pre: ", "\n", "\npost: ", ""],
- dynamic: ["pre", %Rendered{dynamic: ["the value"], static: ["COMPONENT:", ""]}, "post"]
- } =
- Phoenix.View.render(View, "dead_with_function_component.html", @assigns) |> expand_rendered(true)
+ static: ["pre: ", "\n", "\npost: ", ""],
+ dynamic: [
+ "pre",
+ %Rendered{dynamic: ["the value"], static: ["COMPONENT:", ""]},
+ "post"
+ ]
+ } =
+ Phoenix.View.render(View, "dead_with_function_component.html", @assigns)
+ |> expand_rendered(true)
end
test "renders dead engine with function component with inner content" do
assert %Rendered{
- static: ["pre: ", "\n", "\npost: ", ""],
- dynamic: [
- "pre",
- %Rendered{
- dynamic: [
- "the value",
- %Rendered{dynamic: [], static: ["\n The inner content\n"]}
- ],
- static: ["COMPONENT:", ", Content: ", ""]
- },
- "post"
- ]
- } =
- Phoenix.View.render(View, "dead_with_function_component_with_inner_content.html", @assigns)
- |> expand_rendered(true)
+ static: ["pre: ", "\n", "\npost: ", ""],
+ dynamic: [
+ "pre",
+ %Rendered{
+ dynamic: [
+ "the value",
+ %Rendered{dynamic: [], static: ["\n The inner content\n"]}
+ ],
+ static: ["COMPONENT:", ", Content: ", ""]
+ },
+ "post"
+ ]
+ } =
+ Phoenix.View.render(
+ View,
+ "dead_with_function_component_with_inner_content.html",
+ @assigns
+ )
+ |> expand_rendered(true)
end
defp expand_dynamic(dynamic, track_changes?) do
diff --git a/test/phoenix_live_view/html_engine_test.exs b/test/phoenix_live_view/html_engine_test.exs
index a1fc8d7cee..afe8ef08b0 100644
--- a/test/phoenix_live_view/html_engine_test.exs
+++ b/test/phoenix_live_view/html_engine_test.exs
@@ -768,46 +768,35 @@ defmodule Phoenix.LiveView.HTMLEngineTest do
describe "named slots" do
def function_component_with_single_slot(assigns) do
~H"""
- BEFORE SLOT
- <%= render_slot(@sample) %>
- AFTER SLOT
+ BEFORE SLOT <%= render_slot(@sample) %> AFTER SLOT
"""
end
def function_component_with_slots(assigns) do
~H"""
- BEFORE HEADER
- <%= render_slot(@header) %>
- TEXT
- <%= render_slot(@footer) %>
- AFTER FOOTER
+ BEFORE HEADER <%= render_slot(@header) %> TEXT <%= render_slot(@footer) %> AFTER FOOTER
"""
end
def function_component_with_slots_and_default(assigns) do
~H"""
- BEFORE HEADER
- <%= render_slot(@header) %>
- TEXT:<%= render_slot(@inner_block) %>:TEXT
- <%= render_slot(@footer) %>
- AFTER FOOTER
+ BEFORE HEADER <%= render_slot(@header) %> TEXT:<%= render_slot(@inner_block) %>:TEXT
+ <%= render_slot(@footer) %> AFTER FOOTER
"""
end
def function_component_with_slots_and_args(assigns) do
~H"""
- BEFORE SLOT
- <%= render_slot(@sample, 1) %>
- AFTER SLOT
+ BEFORE SLOT <%= render_slot(@sample, 1) %> AFTER SLOT
"""
end
def function_component_with_slot_attrs(assigns) do
~H"""
<%= for entry <- @sample do %>
- <%= entry.a %>
- <%= render_slot(entry) %>
- <%= entry.b %>
+ <%= entry.a %>
+ <%= render_slot(entry) %>
+ <%= entry.b %>
<% end %>
"""
end
@@ -829,11 +818,15 @@ defmodule Phoenix.LiveView.HTMLEngineTest do
end
def render_slot_name(assigns) do
- ~H"<%= for entry <- @sample do %>[<%= entry.__slot__ %>]<% end %>"
+ ~H"<%= for entry <- @sample do %>
+ [<%= entry.__slot__ %>]
+<% end %>"
end
def render_inner_block_slot_name(assigns) do
- ~H"<%= for entry <- @inner_block do %>[<%= entry.__slot__ %>]<% end %>"
+ ~H"<%= for entry <- @inner_block do %>
+ [<%= entry.__slot__ %>]
+<% end %>"
end
test "single slot" do
@@ -2061,7 +2054,11 @@ defmodule Phoenix.LiveView.HTMLEngineTest do
def slot_if_self_close(assigns) do
~H"""
-
<%= @value %>-<%= for slot <- @slot do %><%= slot.val %>-<% end %>
+
+ <%= @value %>-<%= for slot <- @slot do %>
+ <%= slot.val %>-
+ <% end %>
+
"""
end
diff --git a/test/phoenix_live_view/integrations/elements_test.exs b/test/phoenix_live_view/integrations/elements_test.exs
index 814b3a6333..46ebef761e 100644
--- a/test/phoenix_live_view/integrations/elements_test.exs
+++ b/test/phoenix_live_view/integrations/elements_test.exs
@@ -39,6 +39,7 @@ defmodule Phoenix.LiveView.ElementsTest do
assert has_element?(view, "#scoped-render")
assert has_element?(view, "div", "This is a div")
assert has_element?(view, "#scoped-render", ~r/^This is a div$/)
+ assert has_element?(view, "span", "Normalize whitespace")
refute has_element?(view, "#unknown")
refute has_element?(view, "div", "no matching text")
diff --git a/test/phoenix_live_view/integrations/navigation_test.exs b/test/phoenix_live_view/integrations/navigation_test.exs
index 93173971d1..1a15c8dc5e 100644
--- a/test/phoenix_live_view/integrations/navigation_test.exs
+++ b/test/phoenix_live_view/integrations/navigation_test.exs
@@ -178,8 +178,11 @@ defmodule Phoenix.LiveView.NavigationTest do
assert str =~ "The temp is"
end
- assert {:ok, thermo_live3, _html} = live_redirect(thermo_live2, to: "/thermo-live-session/nested-thermo")
- assert {:ok, _thermo_live4, _html} = live_redirect(thermo_live3, to: "/thermo-live-session/nested-thermo")
+ assert {:ok, thermo_live3, _html} =
+ live_redirect(thermo_live2, to: "/thermo-live-session/nested-thermo")
+
+ assert {:ok, _thermo_live4, _html} =
+ live_redirect(thermo_live3, to: "/thermo-live-session/nested-thermo")
end
test "refused with mismatched live session", %{conn: conn} do
diff --git a/test/phoenix_live_view/integrations/start_async_test.exs b/test/phoenix_live_view/integrations/start_async_test.exs
index 2d4a43f86d..6d781bf4d2 100644
--- a/test/phoenix_live_view/integrations/start_async_test.exs
+++ b/test/phoenix_live_view/integrations/start_async_test.exs
@@ -80,19 +80,19 @@ defmodule Phoenix.LiveView.StartAsyncTest do
test "navigate", %{conn: conn} do
{:ok, lv, _html} = live(conn, "/start_async?test=navigate")
- assert_redirect lv, "/start_async?test=ok"
+ assert_redirect(lv, "/start_async?test=ok")
end
test "patch", %{conn: conn} do
{:ok, lv, _html} = live(conn, "/start_async?test=patch")
- assert_patch lv, "/start_async?test=ok"
+ assert_patch(lv, "/start_async?test=ok")
end
test "redirect", %{conn: conn} do
{:ok, lv, _html} = live(conn, "/start_async?test=redirect")
- assert_redirect lv, "/not_found"
+ assert_redirect(lv, "/not_found")
end
test "put_flash", %{conn: conn} do
@@ -166,25 +166,25 @@ defmodule Phoenix.LiveView.StartAsyncTest do
test "navigate", %{conn: conn} do
{:ok, lv, _html} = live(conn, "/start_async?test=lc_navigate")
- assert_redirect lv, "/start_async?test=ok"
+ assert_redirect(lv, "/start_async?test=ok")
end
test "patch", %{conn: conn} do
{:ok, lv, _html} = live(conn, "/start_async?test=lc_patch")
- assert_patch lv, "/start_async?test=ok"
+ assert_patch(lv, "/start_async?test=ok")
end
test "redirect", %{conn: conn} do
{:ok, lv, _html} = live(conn, "/start_async?test=lc_redirect")
- assert_redirect lv, "/not_found"
+ assert_redirect(lv, "/not_found")
end
test "navigate with flash", %{conn: conn} do
{:ok, lv, _html} = live(conn, "/start_async?test=lc_navigate_flash")
- flash = assert_redirect lv, "/start_async?test=ok"
+ flash = assert_redirect(lv, "/start_async?test=ok")
assert %{"info" => "hello"} = flash
end
end
diff --git a/test/phoenix_live_view/test/dom_test.exs b/test/phoenix_live_view/test/dom_test.exs
index a9b27f0c66..9341da8d8e 100644
--- a/test/phoenix_live_view/test/dom_test.exs
+++ b/test/phoenix_live_view/test/dom_test.exs
@@ -132,7 +132,8 @@ defmodule Phoenix.LiveViewTest.DOMTest do
"""
- {new_html, _removed_cids} = DOM.patch_id("phx-458", DOM.parse(html), DOM.parse(inner_html), [])
+ {new_html, _removed_cids} =
+ DOM.patch_id("phx-458", DOM.parse(html), DOM.parse(inner_html), [])
new_html = DOM.to_html(new_html)
@@ -161,7 +162,8 @@ defmodule Phoenix.LiveViewTest.DOMTest do
"""
- {new_html, _removed_cids} = DOM.patch_id("phx-458", DOM.parse(html), DOM.parse(inner_html), [])
+ {new_html, _removed_cids} =
+ DOM.patch_id("phx-458", DOM.parse(html), DOM.parse(inner_html), [])
new_html = DOM.to_html(new_html)
@@ -189,7 +191,8 @@ defmodule Phoenix.LiveViewTest.DOMTest do
"""
- {new_html, _removed_cids} = DOM.patch_id("phx-458", DOM.parse(html), DOM.parse(inner_html), [])
+ {new_html, _removed_cids} =
+ DOM.patch_id("phx-458", DOM.parse(html), DOM.parse(inner_html), [])
new_html = DOM.to_html(new_html)
@@ -216,7 +219,8 @@ defmodule Phoenix.LiveViewTest.DOMTest do
"""
- {new_html, _removed_cids} = DOM.patch_id("phx-458", DOM.parse(html), DOM.parse(inner_html), [])
+ {new_html, _removed_cids} =
+ DOM.patch_id("phx-458", DOM.parse(html), DOM.parse(inner_html), [])
new_html = DOM.to_html(new_html)
diff --git a/test/support/e2e/issues/issue_3026.ex b/test/support/e2e/issues/issue_3026.ex
index 57ca159fed..271b656fd0 100644
--- a/test/support/e2e/issues/issue_3026.ex
+++ b/test/support/e2e/issues/issue_3026.ex
@@ -10,7 +10,6 @@ defmodule Phoenix.LiveViewTest.E2E.Issue3026Live do
~H"""
Example form
-
<.form for={to_form(%{})} phx-change="validate" phx-submit="submit">
diff --git a/test/support/e2e/issues/issue_3040.ex b/test/support/e2e/issues/issue_3040.ex
index 6031acd46f..3cd01a1e2b 100644
--- a/test/support/e2e/issues/issue_3040.ex
+++ b/test/support/e2e/issues/issue_3040.ex
@@ -31,7 +31,7 @@ defmodule Phoenix.LiveViewTest.E2E.Issue3040Live do
<%= style() %>
- <.link patch={"/issues/3040?modal=true"}>Add new
+ <.link patch="/issues/3040?modal=true">Add new
<.modal :if={@modal_open} id="my-modal" show on_cancel={JS.patch("/issues/3040")}>
<.form for={%{}} phx-submit="submit">
diff --git a/test/support/e2e/issues/issue_3047.ex b/test/support/e2e/issues/issue_3047.ex
index 2fc78a2ec8..3c9e0e7dd6 100644
--- a/test/support/e2e/issues/issue_3047.ex
+++ b/test/support/e2e/issues/issue_3047.ex
@@ -3,14 +3,17 @@ defmodule Phoenix.LiveViewTest.E2E.Issue3047ALive do
def render("live.html", assigns) do
~H"""
- <%= apply(Phoenix.LiveViewTest.E2E.Layout, :render, ["live.html", Map.put(assigns, :inner_content, [])]) %>
+ <%= apply(Phoenix.LiveViewTest.E2E.Layout, :render, [
+ "live.html",
+ Map.put(assigns, :inner_content, [])
+ ]) %>
- <%# basic render_* %>
This is a spanThis is a span
- This is a span
- This is a span
+
+ This is a span
+
+
+ This is a span
+ This is a span
- This is a span
- This is a span
+
+ This is a span
+
+
+ This is a span
+ This is a span
- This is a span
- This is a span
- This is a span
+
+ This is a span
+
+
+ This is a span
+
+
+ This is a span
+ This is a span
- This is a span
- This is a span
- This is a span
+
+ This is a span
+
+
+ This is a span
+
+
+ This is a span
+
-
+
This is a span
- This is a span
- This is a span
+
+ This is a span
+
+
+ This is a span
+
- <%# link handling %>
No href linkRegular LinkRegular Link
<.link navigate="/example" id="live-redirect-a">Live redirect
<.link navigate="/example" id="live-redirect-replace-a" replace>Live redirect
- <%# unrelated phx-click does not disable patching %>
- <.link patch="/elements?from=uri" id="live-patch-a" phx-click={JS.dispatch("noop")}>Live patch
+ <.link patch="/elements?from=uri" id="live-patch-a" phx-click={JS.dispatch("noop")}>
+ Live patch
+
-
-
-
-
-
+
+
+
+
+
- <%# hooks %>
SectionSection
- <%# forms %>
Change
-
-
- <%# @page_title assign is unique %>
-
+
"""
end
@@ -198,7 +273,12 @@ defmodule Phoenix.LiveViewTest.ElementsComponent do
<%= @event %>
-
+
"""
end
diff --git a/test/support/live_views/events.ex b/test/support/live_views/events.ex
index 2d82de7827..9e5f0302f0 100644
--- a/test/support/live_views/events.ex
+++ b/test/support/live_views/events.ex
@@ -93,7 +93,8 @@ defmodule Phoenix.LiveViewTest.EventsInComponentMultiJSLive do
id="push-to-self"
phx-click={
JS.push("inc", target: "#child_1", value: %{inc: 1})
- |> JS.push("inc", target: "#child_1", value: %{inc: 10})}
+ |> JS.push("inc", target: "#child_1", value: %{inc: 10})
+ }
>
Both to self
@@ -118,8 +119,7 @@ defmodule Phoenix.LiveViewTest.EventsInComponentMultiJSLive do
def render(assigns) do
~H"""
<.live_component module={Child} id={:child_1} />
- <.live_component module={Child} id={:child_2} />
- root count: <%= @count %>
+ <.live_component module={Child} id={:child_2} /> root count: <%= @count %>
"""
end
@@ -153,7 +153,7 @@ defmodule Phoenix.LiveViewTest.EventsInMountLive do
end
def render(assigns) do
- ~H"<%= live_render @socket, Child, id: :child_live %>"
+ ~H"<%= live_render(@socket, Child, id: :child_live) %>"
end
def mount(_params, _session, socket) do
@@ -175,15 +175,11 @@ defmodule Phoenix.LiveViewTest.EventsInComponentLive do
def render(assigns) do
~H"""
"""
end
diff --git a/test/support/live_views/params.ex b/test/support/live_views/params.ex
index 99bb94652e..0d2795ce9f 100644
--- a/test/support/live_views/params.ex
+++ b/test/support/live_views/params.ex
@@ -3,9 +3,7 @@ defmodule Phoenix.LiveViewTest.ParamCounterLive do
def render(assigns) do
~H"""
- The value is: <%= @val %>
- mount: <%= inspect(@mount_params) %>
- params: <%= inspect(@params) %>
+ The value is: <%= @val %> mount: <%= inspect(@mount_params) %> params: <%= inspect(@params) %>
"""
end
@@ -73,9 +71,9 @@ defmodule Phoenix.LiveViewTest.ActionLive do
def render(assigns) do
~H"""
- Live action: <%= inspect @live_action %>
- Mount action: <%= inspect @mount_action %>
- Params: <%= inspect @params %>
+ Live action: <%= inspect(@live_action) %> Mount action: <%= inspect(@mount_action) %> Params: <%= inspect(
+ @params
+ ) %>
"""
end
diff --git a/test/support/live_views/reload_live.ex b/test/support/live_views/reload_live.ex
index 2e7d99cc8d..ed21c0ae88 100644
--- a/test/support/live_views/reload_live.ex
+++ b/test/support/live_views/reload_live.ex
@@ -9,12 +9,12 @@ defmodule Phoenix.LiveViewTest.ReloadLive do
case Application.fetch_env(:phoenix_live_view, :vsn) do
{:ok, 1} ->
~H"""
-
Version 1
+
Version 1
"""
{:ok, 2} ->
~H"""
-
Version 2
+
Version 2
"""
end
end
diff --git a/test/support/live_views/update.ex b/test/support/live_views/update.ex
index 8dcce11e02..40a4be7436 100644
--- a/test/support/live_views/update.ex
+++ b/test/support/live_views/update.ex
@@ -19,7 +19,10 @@ defmodule Phoenix.LiveViewTest.ShuffleLive do
~H"""
<%= for zone <- @time_zones do %>