diff --git a/test/plausible_web/live/change_domain_test.exs b/test/plausible_web/live/change_domain_test.exs index 6cca9907da..9b7ac6b1b0 100644 --- a/test/plausible_web/live/change_domain_test.exs +++ b/test/plausible_web/live/change_domain_test.exs @@ -20,6 +20,15 @@ defmodule PlausibleWeb.Live.ChangeDomainTest do [{192, 168, 1, 2}] end) + # Stub detection by default to prevent async task race conditions + # Tests that need specific detection results can override this stub + stub_detection_result(%{ + "v1Detected" => false, + "gtmLikely" => false, + "wordpressLikely" => false, + "wordpressPlugin" => false + }) + :ok end end @@ -74,15 +83,6 @@ defmodule PlausibleWeb.Live.ChangeDomainTest do end test "successful form submission updates database", %{conn: conn, site: site} do - on_ee do - stub_detection_result(%{ - "v1Detected" => false, - "gtmLikely" => false, - "wordpressLikely" => false, - "wordpressPlugin" => false - }) - end - original_domain = site.domain new_domain = "new.#{site.domain}" {:ok, lv, _html} = live(conn, "/#{site.domain}/change-domain") @@ -91,6 +91,10 @@ defmodule PlausibleWeb.Live.ChangeDomainTest do |> element("form") |> render_submit(%{site: %{domain: new_domain}}) + on_ee do + render_async(lv, 500) + end + site = Repo.reload!(site) assert site.domain == new_domain assert site.domain_changed_from == original_domain