Skip to content

Commit

Permalink
fix test that relied on push_patch to wrong live session
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffenDE committed Dec 4, 2024
1 parent 93627a3 commit 028f957
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/phoenix/live_dashboard/pages/processes_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ defmodule Phoenix.LiveDashboard.ProcessesLiveTest do
live |> element("button", @kill_process_label) |> render_click()
assert_received {:DOWN, ^ref, _, _, :killed}

return_path = processes_path(10, "", :message_queue_len, :desc)
return_path = processes_path("config", 10, "", :message_queue_len, :desc)
assert_patch(live, return_path, 1000)
end

Expand Down
26 changes: 22 additions & 4 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,28 @@ defmodule Phoenix.LiveDashboardTest.Router do
live_dashboard "/dashboard",
metrics: Phoenix.LiveDashboardTest.Telemetry

live_dashboard "/parent_cookie_domain",
request_logger_cookie_domain: :parent,
live_session_name: :cookie_dashboard
end

# we only really support one live dashboard per router,
# and some tests rely on correct redirect paths that wouldn't work with multiple dashboards;
# as a workaround we forward all non matching requests to a separate router
forward "/", Phoenix.LiveDashboardTest.RouterConfig
end

defmodule Phoenix.LiveDashboardTest.RouterConfig do
use Phoenix.Router
import Phoenix.LiveDashboard.Router

pipeline :browser do
plug :fetch_session
end

scope "/", ThisWontBeUsed, as: :this_wont_be_used do
pipe_through :browser

live_dashboard "/config",
live_socket_path: "/custom/live",
csp_nonce_assign_key: %{
Expand All @@ -100,10 +122,6 @@ defmodule Phoenix.LiveDashboardTest.Router do
metrics_history: {TestHistory, :test_data, []},
request_logger_cookie_domain: "my.domain",
live_session_name: :config_dashboard

live_dashboard "/parent_cookie_domain",
request_logger_cookie_domain: :parent,
live_session_name: :cookie_dashboard
end
end

Expand Down

0 comments on commit 028f957

Please sign in to comment.