Skip to content

Commit b46e2c3

Browse files
committed
fix e2e tests
1 parent 2cc66b7 commit b46e2c3

5 files changed

Lines changed: 37 additions & 24 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ node_modules/
3434
/priv/static/dev/
3535

3636
devtools_*
37+
38+
screenshots/

lib/live_debugger_web/components/navbar.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,14 @@ defmodule LiveDebuggerWeb.Components.Navbar do
109109
Component for displaying the connection status of a LiveView.
110110
When button is clicked, it will trigger a `find-successor` event with the PID of the LiveView.
111111
"""
112+
attr(:id, :string, required: true)
112113
attr(:connected?, :boolean, required: true, doc: "Whether LiveView is connected.")
113114
attr(:pid, :string, required: true, doc: "The PID of the LiveView.")
114115
attr(:rest, :global)
115116

116117
def connected(assigns) do
117118
~H"""
118-
<div class="flex items-center gap-1 text-xs text-primary">
119+
<div id={@id} class="flex items-center gap-1 text-xs text-primary">
119120
<.status_icon connected?={@connected?} />
120121
<%= if @connected? do %>
121122
<span class="font-medium">Monitored PID </span>

lib/live_debugger_web/endpoint.ex

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,31 @@ defmodule LiveDebuggerWeb.Endpoint do
1818
plug(Plug.Static, from: {:phoenix, "priv/static"}, at: "/assets/phoenix")
1919
plug(Plug.Static, from: {:phoenix_live_view, "priv/static"}, at: "/assets/phoenix_live_view")
2020

21-
if LiveDebugger.Env.dev?() do
22-
plug(Plug.Static,
23-
at: "/assets/live_debugger",
24-
from: {:live_debugger, "priv/static/dev"},
25-
gzip: false
26-
)
27-
28-
socket("/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket)
29-
plug(Phoenix.LiveReloader)
30-
plug(Phoenix.CodeReloader)
31-
else
32-
plug(Plug.Static,
33-
at: "/assets/live_debugger",
34-
from: {:live_debugger, "priv/static"},
35-
gzip: false
36-
)
21+
cond do
22+
LiveDebugger.Env.dev?() ->
23+
plug(Plug.Static,
24+
at: "/assets/live_debugger",
25+
from: {:live_debugger, "priv/static/dev"},
26+
gzip: false
27+
)
28+
29+
socket("/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket)
30+
plug(Phoenix.LiveReloader)
31+
plug(Phoenix.CodeReloader)
32+
33+
LiveDebugger.Env.test?() ->
34+
plug(Plug.Static,
35+
at: "/assets/live_debugger",
36+
from: {:live_debugger, "priv/static/dev"},
37+
gzip: false
38+
)
39+
40+
true ->
41+
plug(Plug.Static,
42+
at: "/assets/live_debugger",
43+
from: {:live_debugger, "priv/static"},
44+
gzip: false
45+
)
3746
end
3847

3948
plug(Plug.Session, @session_options)

lib/live_debugger_web/live/channel_dashboard_live.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ defmodule LiveDebuggerWeb.ChannelDashboardLive do
3636
<Navbar.live_debugger_logo_icon />
3737
<Navbar.connected
3838
:if={@lv_process.ok?}
39+
id="navbar-connected"
3940
connected?={@lv_process.result.alive?}
4041
pid={Parsers.pid_to_string(@lv_process.result.pid)}
4142
/>

test/live_debugger/channel_dashboard_test.exs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ defmodule LiveDebugger.ChannelDashboardTest do
286286
end
287287

288288
@sessions 2
289-
feature "when user navigates in debugged app, debugger reloads properly", %{
289+
feature "when user navigates in debugged app, it causes dead view mode", %{
290290
sessions: [dev_app, debugger]
291291
} do
292292
LiveDebugger.GenServers.CallbackTracingServer.ping!()
@@ -306,17 +306,17 @@ defmodule LiveDebugger.ChannelDashboardTest do
306306
Process.sleep(500)
307307

308308
debugger
309-
|> find(css("#info"))
310-
|> assert_text("LiveDebuggerDev.LiveViews.Side")
309+
|> find(css("#navbar-connected"))
310+
|> assert_text("Disconnected")
311311

312-
dev_app
313-
|> click(link("Nested"))
312+
debugger
313+
|> click(css("button", text: "Continue"))
314314

315-
Process.sleep(500)
315+
Process.sleep(1000)
316316

317317
debugger
318318
|> find(css("#info"))
319-
|> assert_text("LiveDebuggerDev.LiveViews.Nested")
319+
|> assert_text("LiveDebuggerDev.LiveViews.Side")
320320
end
321321

322322
defp first_link(), do: css("#live-sessions a.live-view-link", count: 1)

0 commit comments

Comments
 (0)