Skip to content

Commit

Permalink
Use pattern matching to extract process id from view
Browse files Browse the repository at this point in the history
  • Loading branch information
dersmon committed Jan 15, 2024
1 parent a4b8afe commit 31c5c10
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions server/test/field_hub_web/live/project_show_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ defmodule FieldHubWeb.ProjectShowLiveTest do
end

test "authorized user can see monitoring page", %{conn: conn} do
{:ok, view, html_on_mount} = live(conn, "/ui/projects/show/#{@project}")
{:ok, %{pid: pid} = view, html_on_mount} = live(conn, "/ui/projects/show/#{@project}")

pid = view.pid
:erlang.trace(view.pid, true, [:receive])
:erlang.trace(pid, true, [:receive])

assert html_on_mount =~ "<h1>Project <i>#{@project}</i></h1>"
assert html_on_mount =~ "No supervisor found in project document."
Expand All @@ -163,9 +162,7 @@ defmodule FieldHubWeb.ProjectShowLiveTest do
end

test "user can trigger issue evaluation", %{conn: conn} do
{:ok, view, _html_on_mount} = live(conn, "/ui/projects/show/#{@project}")

pid = view.pid
{:ok, %{pid: pid} = view, _html_on_mount} = live(conn, "/ui/projects/show/#{@project}")

:erlang.trace(pid, true, [:receive])

Expand Down Expand Up @@ -416,12 +413,12 @@ defmodule FieldHubWeb.ProjectShowLiveTest do
end

test "file index cache can be deleted through the interface", %{conn: conn} do
{:ok, view, _html_on_mount} = live(conn, "/ui/projects/show/#{@project}")
{:ok, %{pid: pid} = view, _html_on_mount} = live(conn, "/ui/projects/show/#{@project}")

# We wait until the overview task has completed and the result is received by the view process, because the
# overview evaluation will create a cached index.
:erlang.trace(view.pid, true, [:receive])
assert_receive {:trace, _, :receive, {_ref, {:overview_task, _stats}}}
:erlang.trace(pid, true, [:receive])
assert_receive {:trace, ^pid, :receive, {_ref, {:overview_task, _stats}}}

assert {:ok, %{"o26" => _value}} = Cachex.get(@index_cache_name, @project)

Expand Down

0 comments on commit 31c5c10

Please sign in to comment.