From 985886beff2af69c8d4eb32d2e425b883a8d176c Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Thu, 7 May 2026 14:11:05 +0300 Subject: [PATCH 1/4] Add non-catch-all version of dashboard route --- lib/plausible_web/router.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.ex index 613929d534c1..4fac6d95cbcd 100644 --- a/lib/plausible_web/router.ex +++ b/lib/plausible_web/router.ex @@ -734,6 +734,7 @@ defmodule PlausibleWeb.Router do put "/:domain/settings", SiteController, :update_settings get "/:domain/export", StatsController, :csv_export + get "/:domain", StatsController, :stats get "/:domain/*path", StatsController, :stats end end From 817fde9b4cdcb9f2c2bb6b8ffa00d5ce35eccff1 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Thu, 7 May 2026 14:27:46 +0300 Subject: [PATCH 2/4] Remove trailing slash from test assertions --- test/plausible_web/components/billing/billing_test.exs | 8 ++++---- .../controllers/invitation_controller_test.exs | 3 ++- test/plausible_web/controllers/site_controller_test.exs | 2 +- test/plausible_web/live/customer_support/sites_test.exs | 5 ++++- test/plausible_web/live/customer_support/teams_test.exs | 2 +- test/plausible_web/live/verification_test.exs | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/test/plausible_web/components/billing/billing_test.exs b/test/plausible_web/components/billing/billing_test.exs index 93ee24f79c3a..400af2c0721a 100644 --- a/test/plausible_web/components/billing/billing_test.exs +++ b/test/plausible_web/components/billing/billing_test.exs @@ -330,7 +330,7 @@ defmodule PlausibleWeb.Components.BillingTest do ) assert element_exists?(html, "[data-test-id='total-pageviews-dashboard-link']") - assert html =~ "/my-site.example.com/?period=custom" + assert html =~ "/my-site.example.com?period=custom" end test "renders no total link when no domain is provided" do @@ -354,8 +354,8 @@ defmodule PlausibleWeb.Components.BillingTest do html = render_monthly_pageview_usage(usage, 10_000) - assert html =~ "/example.com/?period=custom" - assert html =~ "/app.example.com/?period=custom" + assert html =~ "/example.com?period=custom" + assert html =~ "/app.example.com?period=custom" end test "dashboard links include the billing cycle date range" do @@ -367,7 +367,7 @@ defmodule PlausibleWeb.Components.BillingTest do ) assert html =~ - "/my-site.example.com/?period=custom&from=2024-01-01&to=2024-01-31" + "/my-site.example.com?period=custom&from=2024-01-01&to=2024-01-31" end end diff --git a/test/plausible_web/controllers/invitation_controller_test.exs b/test/plausible_web/controllers/invitation_controller_test.exs index ad3440f0fa0e..9076dbf435a9 100644 --- a/test/plausible_web/controllers/invitation_controller_test.exs +++ b/test/plausible_web/controllers/invitation_controller_test.exs @@ -140,7 +140,8 @@ defmodule PlausibleWeb.Site.InvitationControllerTest do conn = post(conn, "/sites/invitations/#{transfer.transfer_id}/accept") - assert redirected_to(conn, 302) == "/#{URI.encode_www_form(site.domain)}/" + assert redirected_to(conn, 302) == + Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain) assert Phoenix.Flash.get(conn.assigns.flash, :success) =~ "You now have access to" diff --git a/test/plausible_web/controllers/site_controller_test.exs b/test/plausible_web/controllers/site_controller_test.exs index 7f227bdbce89..e603dceb6249 100644 --- a/test/plausible_web/controllers/site_controller_test.exs +++ b/test/plausible_web/controllers/site_controller_test.exs @@ -638,7 +638,7 @@ defmodule PlausibleWeb.SiteControllerTest do } }) - assert redirected_to(conn) == "/example.com/" + assert redirected_to(conn) == "/example.com" end end diff --git a/test/plausible_web/live/customer_support/sites_test.exs b/test/plausible_web/live/customer_support/sites_test.exs index 66e49f38434f..e64771090143 100644 --- a/test/plausible_web/live/customer_support/sites_test.exs +++ b/test/plausible_web/live/customer_support/sites_test.exs @@ -28,7 +28,10 @@ defmodule PlausibleWeb.Live.CustomerSupport.SitesTest do ~s|a[href$="#{URI.encode_www_form(site.domain)}/settings/general"]| ) - assert element_exists?(html, ~s|a[href="/#{URI.encode_www_form(site.domain)}/"]|) + assert element_exists?( + html, + ~s|a[href="#{Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain)}"]| + ) end test "404", %{conn: conn} do diff --git a/test/plausible_web/live/customer_support/teams_test.exs b/test/plausible_web/live/customer_support/teams_test.exs index fb273ca570d9..196979266e51 100644 --- a/test/plausible_web/live/customer_support/teams_test.exs +++ b/test/plausible_web/live/customer_support/teams_test.exs @@ -178,7 +178,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.TeamsTest do html = render(lv) text = text(html) - assert element_exists?(html, ~s|a[href="/primary.example.com%2Ftest/"]|) + assert element_exists?(html, ~s|a[href="/primary.example.com%2Ftest"]|) assert element_exists?(html, ~s|a[href="/primary.example.com%2Ftest/settings/general"]|) assert text =~ "primary.example.com/test" diff --git a/test/plausible_web/live/verification_test.exs b/test/plausible_web/live/verification_test.exs index 959af2645bd8..a8708e259494 100644 --- a/test/plausible_web/live/verification_test.exs +++ b/test/plausible_web/live/verification_test.exs @@ -195,7 +195,7 @@ defmodule PlausibleWeb.Live.VerificationTest do build(:pageview) ]) - assert_redirect(lv, "/#{URI.encode_www_form(site.domain)}/") + assert_redirect(lv, Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain)) end @tag :ce_build_only From 8dec3ab7089799a51a91cf3596b44b8b969d01c2 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Thu, 7 May 2026 14:51:04 +0300 Subject: [PATCH 3/4] Fix more test assertions --- .../controllers/invitation_controller_test.exs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/plausible_web/controllers/invitation_controller_test.exs b/test/plausible_web/controllers/invitation_controller_test.exs index 9076dbf435a9..319afa46f46e 100644 --- a/test/plausible_web/controllers/invitation_controller_test.exs +++ b/test/plausible_web/controllers/invitation_controller_test.exs @@ -20,7 +20,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest do assert Phoenix.Flash.get(conn.assigns.flash, :success) == "You now have access to #{site.domain}" - assert redirected_to(conn) == "/#{URI.encode_www_form(site.domain)}/" + assert redirected_to(conn) == Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain) refute Repo.exists?(from(i in Plausible.Teams.Invitation, where: i.email == ^user.email)) @@ -53,7 +53,7 @@ defmodule PlausibleWeb.Site.InvitationControllerTest do invitation = invite_guest(site, user.email, role: :editor, inviter: owner) c1 = post(conn, "/sites/invitations/#{invitation.invitation_id}/accept") - assert redirected_to(c1) == "/#{URI.encode_www_form(site.domain)}/" + assert redirected_to(c1) == Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain) assert Phoenix.Flash.get(c1.assigns.flash, :success) == "You now have access to #{site.domain}" @@ -78,7 +78,8 @@ defmodule PlausibleWeb.Site.InvitationControllerTest do conn = post(conn, "/sites/invitations/#{transfer.transfer_id}/accept") - assert redirected_to(conn, 302) == "/#{URI.encode_www_form(site.domain)}/" + assert redirected_to(conn, 302) == + Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain) assert Phoenix.Flash.get(conn.assigns.flash, :success) =~ "You now have access to" @@ -209,7 +210,8 @@ defmodule PlausibleWeb.Site.InvitationControllerTest do "/sites/invitations/#{transfer.transfer_id}/accept?skip_site_members_transfer=true" ) - assert redirected_to(conn, 302) == "/#{URI.encode_www_form(site.domain)}/" + assert redirected_to(conn, 302) == + Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain) assert Phoenix.Flash.get(conn.assigns.flash, :success) =~ "You now have access to" From 9c42eb713365154ddd55feb3480b5f37ecd420b4 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Thu, 7 May 2026 14:55:19 +0300 Subject: [PATCH 4/4] Fix more assertions --- test/plausible_web/live/verification_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/plausible_web/live/verification_test.exs b/test/plausible_web/live/verification_test.exs index a8708e259494..4580e932e96b 100644 --- a/test/plausible_web/live/verification_test.exs +++ b/test/plausible_web/live/verification_test.exs @@ -207,7 +207,7 @@ defmodule PlausibleWeb.Live.VerificationTest do populate_stats(site, [build(:pageview)]) - assert_redirect(lv, "/#{URI.encode_www_form(site.domain)}/") + assert_redirect(lv, Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain)) end for {installation_type_param, expected_text, saved_installation_type} <- [