+
+ <.code_snippet text={render_snippet(@tracker_script_configuration_form.data)} rows={6} />
-
- Paste this snippet into the
<head>
- section of your site. See our
- <.styled_link href="https://plausible.io/docs/integration-guides" new_tab={true}>
- installation guides.
-
- Once done, click the button below to verify your installation.
+
+ Need help?
+ <.styled_link href="https://plausible.io/docs/plausible-script">
+ Read our docs
+
+
- <.copy_snippet_box tracker_script_configuration={@tracker_script_configuration_form.data} />
- <.h2 class="mt-8 text-sm font-medium">Optional measurements
- <.script_config_control
- field={@tracker_script_configuration_form[:outbound_links]}
- label="Outbound links"
- tooltip="Automatically track clicks on external links. These count towards your billable pageviews."
- learn_more="https://plausible.io/docs/outbound-link-click-tracking"
- />
- <.script_config_control
- field={@tracker_script_configuration_form[:file_downloads]}
- label="File downloads"
- tooltip="Automatically track file downloads. These count towards your billable pageviews."
- learn_more="https://plausible.io/docs/file-downloads-tracking"
- />
- <.script_config_control
- field={@tracker_script_configuration_form[:form_submissions]}
- label="Form submissions"
- tooltip="Automatically track form submissions. These count towards your billable pageviews."
- learn_more="https://plausible.io/docs/form-submissions-tracking"
- />
+
"""
end
@@ -92,28 +102,17 @@ defmodule PlausibleWeb.Live.Installation.Instructions do
def wordpress_instructions(assigns) do
~H"""
- <.title class="mt-4">
- WordPress installation
-
-
-
-
- We've detected your website is using WordPress. Here's how to integrate Plausible:
-
-
- Using Wordpress? Here's how to integrate Plausible:
-
-
- <.focus_list>
- <:item>
- <.styled_link href="https://plausible.io/wordpress-analytics-plugin" new_tab={true}>
- Install our WordPress plugin
+
+ Instructions
+ <.steps_list>
+ <:step>
+ <.styled_link href="https://plausible.io/wordpress-analytics-plugin">
+ Install our WordPress plugin.
-
- <:item>
- After activating our plugin, click the button below to verify your installation.
-
-
+
+ <:step>Activate the plugin.
+ <:step>Click 'I've installed it' to verify your installation.
+
"""
end
@@ -123,75 +122,40 @@ defmodule PlausibleWeb.Live.Installation.Instructions do
def gtm_instructions(assigns) do
~H"""
- <.title class="mt-4">
- Tag Manager installation
-
-
- <.gtm_instructions_content
- recommended_installation_type={@recommended_installation_type}
- tracker_script_configuration={@tracker_script_configuration_form.data}
- />
-
- """
- end
-
- attr :recommended_installation_type, :string, required: true
- attr :tracker_script_configuration, TrackerScriptConfiguration, required: true
-
- def gtm_instructions_content(assigns) do
- ~H"""
-
- We've detected your website is using Google Tag Manager. Here's how to integrate Plausible:
-
-
- Using Google Tag Manager? Here's how to integrate Plausible:
-
-
- <.gtm_instructions_content_inner tracker_script_configuration={@tracker_script_configuration} />
+
+
Instructions
+ <.steps_list>
+ <:step>
+
+ Copy your Script ID.
+ <.code_snippet text={@tracker_script_configuration_form.data.id} rows={1} />
+
+
+ <:step>
+ <.styled_link href="https://plausible.io/gtm-template">
+ Install the Plausible template in GTM.
+
+
+ <:step>Paste your Script ID into the template.
+ <:step>Click 'I've installed it' to verify your installation.
+
"""
end
- def gtm_instructions_content_inner(assigns) do
- ~H"""
- <.copyable_readonly_text_area
- id="script-config-id"
- text={@tracker_script_configuration.id}
- rows={1}
- />
- <.focus_list>
- <:item>
- Copy your site's Script ID from above
-
-
- <:item>
- <.styled_link href="https://plausible.io/gtm-template" new_tab={true}>
- Install the Plausible template in GTM
-
-
-
- <:item>
- Paste your Script ID into the template
-
-
- """
- end
-
def npm_instructions(assigns) do
~H"""
- <.title class="my-4">
- NPM installation
-
- <.focus_list>
- <:item>
- <.styled_link href="https://www.npmjs.com/package/@plausible-analytics/tracker" new_tab={true}>
- Install @plausible-analytics/tracker NPM package
-
-
- <:item>
- Once done, click the button below to verify your installation.
-
-
+
+ Instructions
+ <.steps_list>
+ <:step>
+ <.styled_link href="https://www.npmjs.com/package/@plausible-analytics/tracker">
+ Install @plausible-analytics/tracker NPM package
+
+
+ <:step>Click 'I've installed it' to verify your installation.
+
+
"""
end
@@ -252,11 +216,62 @@ defmodule PlausibleWeb.Live.Installation.Instructions do
"""
end
- def copy_snippet_box(assigns) do
- assigns = assign(assigns, :text, render_snippet(assigns.tracker_script_configuration))
+ slot :step, required: true
+
+ defp steps_list(assigns) do
+ ~H"""
+
+
+
+
+ {idx + 1}
+
+
+ {render_slot(step)}
+
+
+
+ """
+ end
+
+ attr :text, :string, required: true
+ attr :rows, :integer, default: 6
+ defp code_snippet(assigns) do
~H"""
- <.copyable_readonly_text_area id="snippet" text={@text} rows={6} resizable={true} />
+
+
+
+ <.button
+ type="button"
+ theme="secondary"
+ size="xs"
+ mt?={false}
+ class="absolute top-1.5 right-1.5 shadow-xs"
+ x-on:click="copyAll()"
+ >
+
+ Copy
+
+
+ Copied!
+
+
+
"""
end
diff --git a/lib/plausible_web/live/onboarding_layout_context.ex b/lib/plausible_web/live/onboarding_layout_context.ex
new file mode 100644
index 000000000000..b0d0ce21c83f
--- /dev/null
+++ b/lib/plausible_web/live/onboarding_layout_context.ex
@@ -0,0 +1,19 @@
+defmodule PlausibleWeb.Live.OnboardingLayoutContext do
+ @moduledoc false
+
+ import Phoenix.Component
+
+ alias PlausibleWeb.Flows
+
+ def on_mount(_arg, params, _session, socket) do
+ socket =
+ assign(socket,
+ hide_trial_badge?: params["flow"] == Flows.register(),
+ hide_footer?: true,
+ disable_global_notices?: true,
+ white_bg?: true
+ )
+
+ {:cont, socket, layout: {PlausibleWeb.LayoutView, :onboarding}}
+ end
+end
diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.ex
index f9c16cf88faa..812b308967ac 100644
--- a/lib/plausible_web/router.ex
+++ b/lib/plausible_web/router.ex
@@ -598,10 +598,16 @@ defmodule PlausibleWeb.Router do
scope alias: Live, assigns: %{connect_live_socket: true} do
pipe_through [:app_layout, PlausibleWeb.RequireAccountPlug]
- scope assigns: %{
- dogfood_page_path: "/:website/installation"
- } do
- live "/:domain/installation", Installation, :installation, as: :site
+ live_session :onboarding, on_mount: PlausibleWeb.Live.OnboardingLayoutContext do
+ scope assigns: %{
+ dogfood_page_path: "/:website/installation"
+ } do
+ live "/:domain/installation",
+ Installation,
+ :installation,
+ as: :site,
+ container: {:div, class: "flex-1 flex flex-col"}
+ end
end
scope assigns: %{
diff --git a/lib/plausible_web/templates/layout/_header.html.heex b/lib/plausible_web/templates/layout/_header.html.heex
index d1a93f7a3fc3..2f40ecb8c9dc 100644
--- a/lib/plausible_web/templates/layout/_header.html.heex
+++ b/lib/plausible_web/templates/layout/_header.html.heex
@@ -26,7 +26,8 @@
:if={
ee?() and Plausible.Teams.on_trial?(@conn.assigns[:current_team]) and
(not Plausible.Teams.setup?(@conn.assigns[:current_team]) or
- @conn.assigns[:current_team_role] in Plausible.Billing.allowed_roles())
+ @conn.assigns[:current_team_role] in Plausible.Billing.allowed_roles()) and
+ !assigns[:hide_trial_badge?]
}
class="hidden sm:block"
>
diff --git a/lib/plausible_web/templates/layout/app.html.heex b/lib/plausible_web/templates/layout/app.html.heex
index 8029096dfcd5..1973ca36ff9e 100644
--- a/lib/plausible_web/templates/layout/app.html.heex
+++ b/lib/plausible_web/templates/layout/app.html.heex
@@ -30,7 +30,11 @@
<% end %>
-
+
{Map.get(assigns, :inner_layout) || @inner_content}
diff --git a/lib/plausible_web/templates/layout/onboarding.html.heex b/lib/plausible_web/templates/layout/onboarding.html.heex
new file mode 100644
index 000000000000..967c20c5a1be
--- /dev/null
+++ b/lib/plausible_web/templates/layout/onboarding.html.heex
@@ -0,0 +1,28 @@
+
+
+
+
{@heading}
+
+ {@subtitle}
+
+
+ {@inner_content}
+
+
+
diff --git a/lib/plausible_web/templates/site/new.html.heex b/lib/plausible_web/templates/site/new.html.heex
index abb4ed0bccbf..1f4ad3805300 100644
--- a/lib/plausible_web/templates/site/new.html.heex
+++ b/lib/plausible_web/templates/site/new.html.heex
@@ -1,11 +1,5 @@
-
-
-<.focus_box>
- <:title>
- Add website info
-
-
- <.form :let={f} for={@changeset} action={@form_submit_url}>
+
+ <.form :let={f} class="flex flex-col gap-y-8" for={@changeset} action={@form_submit_url}>
-
- <.input
- help_text="Just the naked domain or subdomain without 'www', 'https' etc."
- type="text"
- placeholder="example.com"
- field={f[:domain]}
- label="Domain"
- disabled={@site_limit_exceeded?}
- />
-
-
- <.input
- type="select"
- help_text="To make sure we agree on what 'today' means"
- field={f[:timezone]}
- id="tz-select"
- value="Etc/Greenwich"
- disabled={@site_limit_exceeded?}
- label="Reporting timezone"
- options={Plausible.Timezones.options()}
- />
-
-
- <.button
- disabled={@site_limit_exceeded?}
- type="submit"
- class="w-full disabled:cursor-not-allowed"
- >
- Install Plausible
-
+
+ <.button_link theme="ghost" href={Routes.site_path(@conn, :index)} mt?={false}>
+ {if @flow == PlausibleWeb.Flows.provisioning(), do: "Back to sites", else: "Skip"}
+
+ <.button
+ disabled={@site_limit_exceeded?}
+ type="submit"
+ mt?={false}
+ class="disabled:cursor-not-allowed"
+ >
+ Add site
+
+
-
+
diff --git a/test/plausible/site/domain_test.exs b/test/plausible/site/domain_test.exs
index 98a0135738d5..089af3f6c26f 100644
--- a/test/plausible/site/domain_test.exs
+++ b/test/plausible/site/domain_test.exs
@@ -19,7 +19,7 @@ defmodule Plausible.Site.DomainTest do
site2 = insert(:site)
assert {:error, changeset} = Domain.change(site2, "new-domain.example.com")
assert {error_message, _} = changeset.errors[:domain]
- assert error_message =~ "This domain cannot be registered"
+ assert error_message =~ "This domain is already registered"
end
test "domain is also guaranteed unique against existing domain_changed_from entries" do
@@ -33,7 +33,7 @@ defmodule Plausible.Site.DomainTest do
assert {:error, %{errors: [{:domain, {^error, _}}]}} =
Domain.change(site2, site1.domain_changed_from)
- assert error =~ "This domain cannot be registered"
+ assert error =~ "This domain is already registered"
end
test "a single site's domain can be changed back and forth" do
@@ -72,7 +72,7 @@ defmodule Plausible.Site.DomainTest do
assert {:error, changeset} = Domain.change(Repo.reload!(site2), "one.example.com")
assert {error_message, _} = changeset.errors[:domain]
- assert error_message =~ "This domain cannot be registered"
+ assert error_message =~ "This domain is already registered"
end
test "change info is cleared when the grace period expires" do
@@ -112,7 +112,7 @@ defmodule Plausible.Site.DomainTest do
test "new domain gets validated" do
site = build(:site)
changeset = Site.update_changeset(site, %{domain: " "})
- assert {"can't be blank", _} = changeset.errors[:domain]
+ assert {"Please enter a domain or subdomain", _} = changeset.errors[:domain]
changeset = Site.update_changeset(site, %{domain: "?#[]"})
assert {"must not contain URI reserved characters" <> _, _} = changeset.errors[:domain]
diff --git a/test/plausible_web/components/flow_progress_test.exs b/test/plausible_web/components/flow_progress_test.exs
index 383612e1eb9a..63bf85b5310f 100644
--- a/test/plausible_web/components/flow_progress_test.exs
+++ b/test/plausible_web/components/flow_progress_test.exs
@@ -30,8 +30,9 @@ defmodule PlausibleWeb.Components.FlowProgressTest do
current_step: "Add site info"
)
- assert text_of_element(rendered, "#flow-progress") ==
- "1 Add site info 2 Install Plausible 3 Verify installation"
+ assert_dot_labels(rendered, ["Add site info", "Install Plausible"])
+
+ assert_current_step(rendered, "Add site info")
end
test "invitation" do
@@ -41,8 +42,8 @@ defmodule PlausibleWeb.Components.FlowProgressTest do
current_step: "Register"
)
- assert text_of_element(rendered, "#flow-progress") ==
- "1 Register 2 Activate account"
+ assert_dot_labels(rendered, ["Register", "Activate account"])
+ assert_current_step(rendered, "Register")
end
test "provisioning" do
@@ -52,8 +53,9 @@ defmodule PlausibleWeb.Components.FlowProgressTest do
current_step: "Add site info"
)
- assert text_of_element(rendered, "#flow-progress") ==
- "1 Add site info 2 Install Plausible 3 Verify installation"
+ assert_dot_labels(rendered, ["Add site info", "Install Plausible"])
+
+ assert_current_step(rendered, "Add site info")
end
test "review" do
@@ -63,8 +65,8 @@ defmodule PlausibleWeb.Components.FlowProgressTest do
current_step: "Install Plausible"
)
- assert text_of_element(rendered, "#flow-progress") ==
- "1 Install Plausible 2 Verify installation"
+ assert_dot_labels(rendered, ["Install Plausible"])
+ assert_current_step(rendered, "Install Plausible")
end
test "domain_change" do
@@ -74,7 +76,28 @@ defmodule PlausibleWeb.Components.FlowProgressTest do
current_step: "Set up new domain"
)
- assert text_of_element(rendered, "#flow-progress") ==
- "1 Set up new domain 2 Install Plausible 3 Verify installation"
+ assert_dot_labels(rendered, ["Set up new domain", "Install Plausible"])
+
+ assert_current_step(rendered, "Set up new domain")
+ end
+
+ defp assert_dot_labels(rendered, expected_labels) do
+ labels =
+ rendered
+ |> LazyHTML.from_fragment()
+ |> LazyHTML.query("#flow-progress [aria-label]")
+ |> LazyHTML.attribute("aria-label")
+
+ assert labels == expected_labels
+ end
+
+ defp assert_current_step(rendered, expected_label) do
+ current =
+ rendered
+ |> LazyHTML.from_fragment()
+ |> LazyHTML.query(~s(#flow-progress [aria-current="step"]))
+
+ assert Enum.count(current) == 1
+ assert LazyHTML.attribute(current, "aria-label") == [expected_label]
end
end
diff --git a/test/plausible_web/controllers/api/external_sites_controller_sites_crud_api_test.exs b/test/plausible_web/controllers/api/external_sites_controller_sites_crud_api_test.exs
index 458804f3b0db..c45522c59d59 100644
--- a/test/plausible_web/controllers/api/external_sites_controller_sites_crud_api_test.exs
+++ b/test/plausible_web/controllers/api/external_sites_controller_sites_crud_api_test.exs
@@ -288,7 +288,7 @@ defmodule PlausibleWeb.Api.ExternalSitesControllerSitesCrudApiTest do
conn = post(conn, "/api/v1/sites", %{})
assert json_response(conn, 400) == %{
- "error" => "domain: can't be blank"
+ "error" => "domain: Please enter a domain or subdomain"
}
end
diff --git a/test/plausible_web/controllers/site_controller_test.exs b/test/plausible_web/controllers/site_controller_test.exs
index 8c66b55e5e8a..3cee62dc30c2 100644
--- a/test/plausible_web/controllers/site_controller_test.exs
+++ b/test/plausible_web/controllers/site_controller_test.exs
@@ -22,7 +22,7 @@ defmodule PlausibleWeb.SiteControllerTest do
test "shows the site form", %{conn: conn} do
conn = get(conn, "/sites/new")
- assert html_response(conn, 200) =~ "Add website info"
+ assert html_response(conn, 200) =~ "Add a website"
end
test "shows onboarding steps regardless of sites provisioned", %{conn: conn1, user: user} do
@@ -379,7 +379,7 @@ defmodule PlausibleWeb.SiteControllerTest do
}
})
- assert html_response(conn, 200) =~ htmlize_quotes("can't be blank")
+ assert html_response(conn, 200) =~ "Please enter a domain or subdomain"
end
test "fails to create site when not allowed to in selected team", %{conn: conn, user: user} do
@@ -529,7 +529,7 @@ defmodule PlausibleWeb.SiteControllerTest do
}
})
- assert html_response(conn, 200) =~ htmlize_quotes("can't be blank")
+ assert html_response(conn, 200) =~ "Please enter a domain or subdomain"
end
test "only alphanumeric characters and slash allowed in domain", %{conn: conn} do
@@ -570,7 +570,7 @@ defmodule PlausibleWeb.SiteControllerTest do
})
assert html_response(conn, 200) =~
- "This domain cannot be registered. Perhaps one of your colleagues registered it?"
+ "This domain is already registered. Ask the owner for access"
if ee?() do
assert html_response(conn, 200) =~ "support@plausible.io"
@@ -593,7 +593,7 @@ defmodule PlausibleWeb.SiteControllerTest do
})
assert html_response(conn, 200) =~
- "This domain cannot be registered. Perhaps one of your colleagues registered it?"
+ "This domain is already registered. Ask the owner for access"
if ee?() do
assert html_response(conn, 200) =~ "support@plausible.io"
@@ -660,7 +660,7 @@ defmodule PlausibleWeb.SiteControllerTest do
})
assert html_response(conn, 200) =~
- "This domain cannot be registered. Perhaps one of your colleagues registered it?"
+ "This domain is already registered. Ask the owner for access"
end
end
end
diff --git a/test/plausible_web/live/change_domain_test.exs b/test/plausible_web/live/change_domain_test.exs
index 84f902d3b4c8..ee0b76ed5b19 100644
--- a/test/plausible_web/live/change_domain_test.exs
+++ b/test/plausible_web/live/change_domain_test.exs
@@ -55,7 +55,7 @@ defmodule PlausibleWeb.Live.ChangeDomainTest do
|> element("form")
|> render_submit(%{site: %{domain: another_site.domain}})
- assert html =~ "This domain cannot be registered"
+ assert html =~ "This domain is already registered"
site = Repo.reload!(site)
assert site.domain != another_site.domain
@@ -93,7 +93,7 @@ defmodule PlausibleWeb.Live.ChangeDomainTest do
|> element("form")
|> render_submit(%{site: %{domain: "foo.example.com"}})
- assert html =~ "This domain cannot be registered"
+ assert html =~ "This domain is already registered"
site = Repo.reload!(site)
assert site.domain != "foo.example.com"
@@ -204,7 +204,7 @@ defmodule PlausibleWeb.Live.ChangeDomainTest do
|> element("form")
|> render_submit(%{site: %{domain: ""}})
- assert html =~ htmlize_quotes("can't be blank")
+ assert html =~ "Please enter a domain or subdomain"
end
test "form validation shows error for invalid domain format", %{conn: conn, site: site} do
diff --git a/test/plausible_web/live/components/verification_banner_test.exs b/test/plausible_web/live/components/verification_banner_test.exs
index dbd289ddb6b0..4c2d9d5ab4a0 100644
--- a/test/plausible_web/live/components/verification_banner_test.exs
+++ b/test/plausible_web/live/components/verification_banner_test.exs
@@ -67,7 +67,7 @@ defmodule PlausibleWeb.Live.Components.VerificationBannerTest do
assert element_exists?(
html,
- ~s|#recommendation a[href="/example.com/installation?flow="]|
+ ~s|#recommendation a[href="/example.com/installation?flow=&return_to=dashboard"]|
)
refute element_exists?(html, @super_admin_report)
@@ -218,7 +218,7 @@ defmodule PlausibleWeb.Live.Components.VerificationBannerTest do
assert element_exists?(
html,
- ~s|a[href="/example.com/installation?flow=review"]|
+ ~s|a[href="/example.com/installation?flow=review&return_to=dashboard"]|
)
assert html =~ "Review installation"
diff --git a/test/plausible_web/live/installation_test.exs b/test/plausible_web/live/installation_test.exs
index 794b6ec09f4d..227cf76387c1 100644
--- a/test/plausible_web/live/installation_test.exs
+++ b/test/plausible_web/live/installation_test.exs
@@ -9,17 +9,9 @@ defmodule PlausibleWeb.Live.InstallationTest do
@migration_guide_link "https://plausible.io/docs/script-update-guide"
on_ee do
- @manual_button_text "Verify Script installation"
- @wordpress_button_text "Verify WordPress installation"
- @gtm_button_text "Verify Tag Manager installation"
- @npm_button_text "Verify NPM installation"
+ @submit_button_text "I've installed it"
else
- @shared_button_text "Proceed to dashboard"
-
- @manual_button_text @shared_button_text
- @wordpress_button_text @shared_button_text
- @gtm_button_text @shared_button_text
- @npm_button_text @shared_button_text
+ @submit_button_text "Proceed to dashboard"
end
setup [:create_user, :log_in, :create_site]
@@ -57,7 +49,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _} = get_lv(conn, site)
html = render_async(lv, 500)
- assert text(html) =~ @wordpress_button_text
+ assert text(html) =~ @submit_button_text
end
@tag :ee_only
@@ -71,7 +63,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _} = get_lv(conn, site, "?type=wordpress")
html = render_async(lv, 500)
- assert text(html) =~ @wordpress_button_text
+ assert text(html) =~ @submit_button_text
end
@tag :ee_only
@@ -85,7 +77,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _} = get_lv(conn, site, "?type=gtm")
html = render_async(lv, 500)
- assert text(html) =~ @gtm_button_text
+ assert text(html) =~ @submit_button_text
end
@tag :ee_only
@@ -99,7 +91,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _} = get_lv(conn, site, "?type=npm")
html = render_async(lv, 500)
- assert text(html) =~ @npm_button_text
+ assert text(html) =~ @submit_button_text
end
@tag :ee_only
@@ -113,7 +105,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _} = get_lv(conn, site, "?type=manual")
html = render_async(lv, 500)
- assert text(html) =~ @manual_button_text
+ assert text(html) =~ @submit_button_text
end
on_ee do
@@ -124,28 +116,28 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _html} = get_lv(conn, site, "?type=manual")
html = render_async(lv, 500)
- assert html =~ @manual_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
lv
|> element("a[href*=\"type=wordpress\"]")
|> render_click()
html = render(lv)
- assert html =~ @wordpress_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
lv
|> element("a[href*=\"type=gtm\"]")
|> render_click()
html = render(lv)
- assert html =~ @gtm_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
lv
|> element("a[href*=\"type=npm\"]")
|> render_click()
html = render(lv)
- assert html =~ @npm_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
end
else
test "allows switching between installation tabs (CE)", %{conn: conn, site: site} do
@@ -153,7 +145,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
html = render_async(lv, 500)
assert html =~ "window.plausible"
- assert html =~ @shared_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
lv
|> element("a[href*=\"type=wordpress\"]")
@@ -161,7 +153,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
html = render(lv)
assert html =~ "https://plausible.io/wordpress-analytics-plugin"
- assert html =~ @shared_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
lv
|> element("a[href*=\"type=npm\"]")
@@ -169,7 +161,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
html = render(lv)
assert html =~ "@plausible-analytics/tracker"
- assert html =~ @shared_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
end
end
@@ -183,7 +175,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
assert eventually(fn ->
html = render(lv)
- {html =~ @manual_button_text, html}
+ {html =~ htmlize_quotes(@submit_button_text), html}
end)
html = render(lv)
@@ -202,7 +194,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _html} = get_lv(conn, site, "?type=manual&flow=review")
html = render_async(lv, 500)
- assert html =~ @manual_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
assert html =~ "Optional measurements"
assert html =~ "Outbound links"
assert html =~ "File downloads"
@@ -218,7 +210,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _html} = get_lv(conn, site, "?type=manual&flow=review")
html = render_async(lv, 500)
- assert html =~ @manual_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
assert html =~ "Advanced options"
assert html =~ "Manual tagging"
assert html =~ "404 error pages"
@@ -239,7 +231,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _html} = get_lv(conn, site, "?type=manual&flow=review")
html = render_async(lv, 500)
- assert html =~ @manual_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
config = TrackerScriptConfiguration |> Plausible.Repo.get_by!(site_id: site.id)
assert config.outbound_links == true
@@ -264,12 +256,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
end
on_ee do
- for {type, expected_text} <- [
- {"manual", @manual_button_text},
- {"wordpress", @wordpress_button_text},
- {"gtm", @gtm_button_text},
- {"npm", @npm_button_text}
- ] do
+ for type <- ["manual", "wordpress", "gtm", "npm"] do
test "submitting form with #{type} redirects to the dashboard with the verification banner (EE)",
%{
conn: conn,
@@ -281,7 +268,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _html} = get_lv(conn, site, "?type=#{unquote(type)}")
html = render_async(lv, 500)
- assert html =~ unquote(expected_text)
+ assert html =~ htmlize_quotes(@submit_button_text)
lv
|> element("form[phx-submit='submit']")
@@ -335,7 +322,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _html} = get_lv(conn, site, "?type=manual")
html = render_async(lv, 500)
- assert html =~ @manual_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
# Test with all options disabled
lv
@@ -367,7 +354,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _html} = get_lv(conn, site, "?type=manual&flow=review")
html = render_async(lv, 500)
- assert html =~ @manual_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
lv
|> element("form[phx-submit='submit']")
@@ -396,14 +383,14 @@ defmodule PlausibleWeb.Live.InstallationTest do
end
@tag :ee_only
- test "detected WordPress installation shows special message", %{conn: conn, site: site} do
+ test "detected WordPress installation preselects WordPress tab", %{conn: conn, site: site} do
stub_dns()
stub_detection_wordpress()
{lv, _} = get_lv(conn, site)
html = render_async(lv, 500)
- assert text(html) =~ "We've detected your website is using WordPress"
+ assert text(html) =~ "Install our WordPress plugin"
end
@tag :ee_only
@@ -427,21 +414,21 @@ defmodule PlausibleWeb.Live.InstallationTest do
html = render_async(lv, 500)
- refute text(html) =~ "We've detected your website is using WordPress"
- assert text(html) =~ @manual_button_text
+ refute text(html) =~ "Install our WordPress plugin"
+ assert text(html) =~ @submit_button_text
end
@tag :ee_only
- test "detected GTM installation shows special message", %{conn: conn, site: site} do
+ test "detected GTM installation preselects Tag Manager tab", %{conn: conn, site: site} do
stub_dns()
stub_detection_gtm()
{lv, _} = get_lv(conn, site)
html = render_async(lv, 500)
- assert html =~ @gtm_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
- assert text(html) =~ "We've detected your website is using Google Tag Manager"
+ assert text(html) =~ "Install the Plausible template in GTM"
end
@tag :ee_only
@@ -459,7 +446,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _} = get_lv(conn, site)
html = render_async(lv, 500)
- assert html =~ @npm_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
end
@tag :ee_only
@@ -498,7 +485,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _} = get_lv(conn, site, "?type=wordpress")
html = render_async(lv, 500)
- assert html =~ @wordpress_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
refute element_exists?(html, "a[href='#{@migration_guide_link}']")
end
@@ -515,7 +502,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
assert eventually(fn ->
html = render(lv)
# Should default to manual installation when detection returns {:error, _}
- {html =~ @manual_button_text, html}
+ {html =~ htmlize_quotes(@submit_button_text), html}
end)
end)
end
@@ -533,7 +520,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
html = render_async(lv, 500)
# Should default to manual installation when detection returns {:error, _}
- assert html =~ @manual_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
end)
end
end
@@ -560,7 +547,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _} = get_lv(conn, site)
html = render_async(lv, 500)
- assert html =~ @manual_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
end
test "allows editor access to installation page", %{conn: conn, user: user} do
@@ -575,7 +562,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _} = get_lv(conn, site)
html = render_async(lv, 500)
- assert html =~ @manual_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
end
end
@@ -593,7 +580,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _} = get_lv(conn, site, "?type=invalid")
html = render_async(lv, 500)
- assert html =~ @manual_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
end
test "falls back to provisioning flow when invalid flow parameter supplied", %{
@@ -608,7 +595,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _} = get_lv(conn, site, "?flow=invalid")
html = render_async(lv, 500)
- assert html =~ @manual_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
end
end
@@ -628,7 +615,80 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _} = get_lv(conn, site)
html = render_async(lv, 500)
- assert html =~ @gtm_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
+ end
+ end
+
+ describe "secondary action" do
+ @tag :ee_only
+ test "offers Skip to /sites in the register flow", %{conn: conn, site: site} do
+ stub_dns()
+ stub_detection_manual()
+
+ {lv, _} = get_lv(conn, site, "?flow=register")
+
+ html = render_async(lv, 500)
+
+ assert text_of_element(html, ~s|a[href="/sites"]|) == "Skip"
+ end
+
+ @tag :ee_only
+ test "offers Back to sites in the provisioning flow", %{conn: conn, site: site} do
+ stub_dns()
+ stub_detection_manual()
+
+ {lv, _} = get_lv(conn, site, "?flow=provisioning")
+
+ html = render_async(lv, 500)
+
+ assert text_of_element(html, ~s|a[href="/sites"]|) == "Back to sites"
+ end
+
+ @tag :ee_only
+ test "offers Back to settings in the review flow", %{conn: conn, site: site} do
+ stub_dns()
+ stub_detection_manual()
+
+ {lv, _} = get_lv(conn, site, "?flow=review")
+
+ html = render_async(lv, 500)
+
+ href = Routes.site_path(PlausibleWeb.Endpoint, :settings_general, site.domain)
+
+ assert text_of_element(html, ~s|a[href="#{href}"]|) == "Back to settings"
+ end
+
+ @tag :ee_only
+ test "offers Back to dashboard, keeping verification on, when return_to=dashboard", %{
+ conn: conn,
+ site: site
+ } do
+ stub_dns()
+ stub_detection_manual()
+
+ {lv, _} = get_lv(conn, site, "?flow=provisioning&return_to=dashboard")
+
+ html = render_async(lv, 500)
+
+ href =
+ Routes.stats_path(PlausibleWeb.Endpoint, :stats, site.domain,
+ verify_installation: true,
+ flow: "provisioning"
+ )
+
+ assert text_of_element(html, ~s|a[href="#{href}"]|) == "Back to dashboard"
+ end
+
+ @tag :ee_only
+ test "falls back to Skip when the flow is unrecognised", %{conn: conn, site: site} do
+ stub_dns()
+ stub_detection_manual()
+
+ {lv, _} = get_lv(conn, site, "?flow=")
+
+ html = render_async(lv, 500)
+
+ assert text_of_element(html, ~s|a[href="/sites"]|) == "Skip"
end
end
@@ -652,7 +712,7 @@ defmodule PlausibleWeb.Live.InstallationTest do
{lv, _} = get_lv(conn, site, "?flow=review")
html = render_async(lv, 500)
- assert html =~ @wordpress_button_text
+ assert html =~ htmlize_quotes(@submit_button_text)
end
end