Skip to content

Commit fa09b73

Browse files
authored
Fix postgrex disconnection during async tests (#5926)
1 parent 85d9e59 commit fa09b73

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

test/plausible_web/live/change_domain_test.exs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ defmodule PlausibleWeb.Live.ChangeDomainTest do
2020
[{192, 168, 1, 2}]
2121
end)
2222

23+
# Stub detection by default to prevent async task race conditions
24+
# Tests that need specific detection results can override this stub
25+
stub_detection_result(%{
26+
"v1Detected" => false,
27+
"gtmLikely" => false,
28+
"wordpressLikely" => false,
29+
"wordpressPlugin" => false
30+
})
31+
2332
:ok
2433
end
2534
end
@@ -74,15 +83,6 @@ defmodule PlausibleWeb.Live.ChangeDomainTest do
7483
end
7584

7685
test "successful form submission updates database", %{conn: conn, site: site} do
77-
on_ee do
78-
stub_detection_result(%{
79-
"v1Detected" => false,
80-
"gtmLikely" => false,
81-
"wordpressLikely" => false,
82-
"wordpressPlugin" => false
83-
})
84-
end
85-
8686
original_domain = site.domain
8787
new_domain = "new.#{site.domain}"
8888
{:ok, lv, _html} = live(conn, "/#{site.domain}/change-domain")
@@ -91,6 +91,10 @@ defmodule PlausibleWeb.Live.ChangeDomainTest do
9191
|> element("form")
9292
|> render_submit(%{site: %{domain: new_domain}})
9393

94+
on_ee do
95+
render_async(lv, 500)
96+
end
97+
9498
site = Repo.reload!(site)
9599
assert site.domain == new_domain
96100
assert site.domain_changed_from == original_domain

0 commit comments

Comments
 (0)