diff --git a/lib/phoenix_test/live.ex b/lib/phoenix_test/live.ex index f9d650cd..f89787d1 100644 --- a/lib/phoenix_test/live.ex +++ b/lib/phoenix_test/live.ex @@ -16,7 +16,8 @@ defmodule PhoenixTest.Live do def build(conn) do {:ok, view, _html} = live(conn) - %__MODULE__{view: view, conn: conn, current_path: conn.request_path} + current_path = conn.request_path <> "?" <> conn.query_string + %__MODULE__{view: view, conn: conn, current_path: current_path} end def render_page_title(%{view: view}) do diff --git a/test/phoenix_test/assertions_test.exs b/test/phoenix_test/assertions_test.exs index 361ce3c9..4105eb83 100644 --- a/test/phoenix_test/assertions_test.exs +++ b/test/phoenix_test/assertions_test.exs @@ -592,6 +592,20 @@ defmodule PhoenixTest.AssertionsTest do |> assert_path("/live/index") end + test "asserts correct path with regular navigation (from Live)", %{conn: conn} do + conn + |> visit("/live/index") + |> click_link("Navigate to non-liveview") + |> assert_path("/page/index") + end + + test "asserts correct query params with regular navigation (from Live)", %{conn: conn} do + conn + |> visit("/live/index") + |> click_link("Navigate to non-liveview") + |> assert_path("/page/index", query_params: %{foo: "bar", details: true}) + end + test "asserts correct path with Live navigation", %{conn: conn} do conn |> visit("/live/index") @@ -599,6 +613,13 @@ defmodule PhoenixTest.AssertionsTest do |> assert_path("/live/page_2") end + test "asserts correct query params with Live navigation", %{conn: conn} do + conn + |> visit("/live/index") + |> click_link("Navigate link") + |> assert_path("/live/page_2", query_params: %{foo: "bar", details: true}) + end + test "asserts correct path with Live patching", %{conn: conn} do conn |> visit("/live/index") diff --git a/test/support/index_live.ex b/test/support/index_live.ex index 66a5ab81..66825c1d 100644 --- a/test/support/index_live.ex +++ b/test/support/index_live.ex @@ -6,9 +6,9 @@ defmodule PhoenixTest.IndexLive do ~H"""