Leon4gr45 commited on
Commit
6562cbf
·
verified ·
1 Parent(s): ed6bf5c

Delete test/plausible_web/live/sentry_context_test.exs with huggingface_hub

Browse files
test/plausible_web/live/sentry_context_test.exs DELETED
@@ -1,82 +0,0 @@
1
- defmodule PlausibleWeb.Live.SentryContextTest do
2
- use PlausibleWeb.ConnCase, async: true
3
- import Phoenix.LiveViewTest
4
-
5
- defmodule SampleLV do
6
- use PlausibleWeb, :live_view
7
-
8
- def mount(_params, %{"test" => test_pid}, socket) do
9
- socket = assign(socket, test_pid: test_pid)
10
- {:ok, socket}
11
- end
12
-
13
- def render(assigns) do
14
- ~H"""
15
- ok computer
16
- """
17
- end
18
-
19
- def handle_event("get_sentry_context", _params, socket) do
20
- context = Sentry.Context.get_all()
21
- send(socket.assigns.test_pid, {:context, context})
22
- {:noreply, socket}
23
- end
24
- end
25
-
26
- describe "sentry context" do
27
- test "basic shape", %{conn: conn} do
28
- context_hook(conn)
29
- assert_receive {:context, context}
30
-
31
- assert %{
32
- extra: %{},
33
- request: %{
34
- env: %{
35
- "REMOTE_ADDR" => "127.0.0.1",
36
- "REMOTE_PORT" => port,
37
- "SEVER_NAME" => "www.example.com"
38
- },
39
- url: :not_mounted_at_router
40
- },
41
- user: %{},
42
- tags: %{},
43
- breadcrumbs: []
44
- } = context
45
-
46
- assert is_integer(port)
47
- end
48
-
49
- test "user-agent is included", %{conn: conn} do
50
- conn
51
- |> put_req_header("user-agent", "Firefox")
52
- |> context_hook()
53
-
54
- assert_receive {:context, context}
55
- assert context.request.headers["User-Agent"] == "Firefox"
56
- end
57
- end
58
-
59
- describe "sentry context with logged in user" do
60
- setup [:create_user, :log_in]
61
-
62
- test "user_id is included", %{conn: conn, user: user} do
63
- context_hook(conn)
64
-
65
- assert_receive {:context, context}
66
- assert context.user.id == user.id
67
- end
68
- end
69
-
70
- defp context_hook(conn, extra_session \\ %{}) do
71
- lv = get_liveview(conn, extra_session)
72
- assert render(lv) =~ "ok computer"
73
- render_hook(lv, :get_sentry_context, %{})
74
- end
75
-
76
- defp get_liveview(conn, extra_session) do
77
- {:ok, lv, _html} =
78
- live_isolated(conn, SampleLV, session: Map.merge(%{"test" => self()}, extra_session))
79
-
80
- lv
81
- end
82
- end