Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Improve subscription settings layout (#6076)

Sanne de Vries93ce68c206eb
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 41015ed37b..4f63d54292 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
### Changed
- Keybind hints are hidden on smaller screens
+- Subscription settings page design is updated
### Fixed
diff --git a/lib/plausible_web/components/billing/billing.ex b/lib/plausible_web/components/billing/billing.ex
index 61c13a2b24..56f8113139 100644
--- a/lib/plausible_web/components/billing/billing.ex
+++ b/lib/plausible_web/components/billing/billing.ex
@@ -5,7 +5,7 @@ defmodule PlausibleWeb.Components.Billing do
use Plausible
require Plausible.Billing.Subscription.Status
- alias Plausible.Billing.{Subscription, Subscriptions, Plan, Plans, EnterprisePlan}
+ alias Plausible.Billing.{Plan, Plans, EnterprisePlan}
attr :site, Plausible.Site, required: false, default: nil
attr :current_user, Plausible.Auth.User, required: true
@@ -58,9 +58,8 @@ defmodule PlausibleWeb.Components.Billing do
def render_monthly_pageview_usage(assigns) do
~H"""
- <article id="monthly_pageview_usage_container" x-data="{ tab: 'last_cycle' }" class="mt-8">
- <.title>Monthly pageviews usage</.title>
- <div class="mt-4 mb-4">
+ <article id="monthly_pageview_usage_container" x-data="{ tab: 'last_cycle' }">
+ <div class="mb-4">
<ol class="divide-y divide-gray-300 dark:divide-gray-600 rounded-md border dark:border-gray-600 md:flex md:flex-row-reverse md:divide-y-0 md:overflow-hidden">
<.billing_cycle_tab
name="Upcoming cycle"
@@ -290,30 +289,6 @@ defmodule PlausibleWeb.Components.Billing do
end
end
- def monthly_quota_box(assigns) do
- ~H"""
- <div
- id="monthly-quota-box"
- class="w-full flex-1 h-32 px-2 py-4 text-center bg-gray-100 rounded-sm dark:bg-gray-800 w-max-md"
- >
- <h4 class="font-black dark:text-gray-100">Monthly quota</h4>
- <div class="py-2 text-xl font-medium dark:text-gray-100">
- {PlausibleWeb.AuthView.subscription_quota(@subscription, format: :long)}
- </div>
- <.styled_link
- :if={
- not (Plausible.Teams.Billing.enterprise_configured?(@team) &&
- Subscriptions.halted?(@subscription))
- }
- id="#upgrade-or-change-plan-link"
- href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}
- >
- {change_plan_or_upgrade_text(@subscription)}
- </.styled_link>
- </div>
- """
- end
-
def present_enterprise_plan(assigns) do
~H"""
<ul class="w-full py-4">
@@ -413,25 +388,6 @@ defmodule PlausibleWeb.Components.Billing do
end
end
- def upgrade_link(assigns) do
- ~H"""
- <.button_link
- id="upgrade-link-2"
- href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}
- mt?={false}
- >
- Upgrade
- </.button_link>
- """
- end
-
- defp change_plan_or_upgrade_text(nil), do: "Upgrade"
-
- defp change_plan_or_upgrade_text(%Subscription{status: Subscription.Status.deleted()}),
- do: "Upgrade"
-
- defp change_plan_or_upgrade_text(_subscription), do: "Change plan"
-
attr :link_class, :string, default: ""
attr :current_team, :any, required: true
attr :current_user, :atom, required: true
diff --git a/lib/plausible_web/components/billing/notice.ex b/lib/plausible_web/components/billing/notice.ex
index a899a4d5e7..c36465679c 100644
--- a/lib/plausible_web/components/billing/notice.ex
+++ b/lib/plausible_web/components/billing/notice.ex
@@ -123,7 +123,6 @@ defmodule PlausibleWeb.Components.Billing.Notice do
dismissable_id={Plausible.Billing.cancelled_subscription_notice_dismiss_id(@subscription.id)}
title={Plausible.Billing.subscription_cancelled_notice_title()}
theme={:red}
- class="shadow-md dark:shadow-none"
>
<.subscription_cancelled_notice_body subscription={@subscription} />
</.notice>
@@ -144,7 +143,7 @@ defmodule PlausibleWeb.Components.Billing.Notice do
<.notice
title={Plausible.Billing.subscription_cancelled_notice_title()}
theme={:red}
- class="shadow-md dark:shadow-none"
+ show_icon={false}
>
<.subscription_cancelled_notice_body subscription={@subscription} />
</.notice>
@@ -172,10 +171,7 @@ defmodule PlausibleWeb.Components.Billing.Notice do
) do
~H"""
<aside class={@class}>
- <.notice
- title={Plausible.Billing.subscription_past_due_notice_title()}
- class="shadow-md dark:shadow-none"
- >
+ <.notice title={Plausible.Billing.subscription_past_due_notice_title()}>
There was a problem with your latest payment. Please update your payment information to keep using Plausible.<.link
href={@subscription.update_url}
class="whitespace-nowrap font-semibold"
@@ -198,7 +194,6 @@ defmodule PlausibleWeb.Components.Billing.Notice do
<.notice
title={Plausible.Billing.subscription_paused_notice_title()}
theme={:red}
- class="shadow-md dark:shadow-none"
>
Your subscription is paused due to failed payments. Please provide valid payment details to keep using Plausible.<.link
href={@subscription.update_url}
@@ -472,7 +467,11 @@ defmodule PlausibleWeb.Components.Billing.Notice do
<p class="text-pretty">
Upgrade to a monthly or yearly plan to continue accessing your sites.
</p>
- <.button_link href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)} mt?={false}>
+ <.button_link
+ id="upgrade-or-change-plan-link"
+ href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}
+ mt?={false}
+ >
Choose a plan
</.button_link>
</div>
diff --git a/lib/plausible_web/components/generic.ex b/lib/plausible_web/components/generic.ex
index 2e5e35cbf5..8e59bf373a 100644
--- a/lib/plausible_web/components/generic.ex
+++ b/lib/plausible_web/components/generic.ex
@@ -1261,7 +1261,7 @@ defmodule PlausibleWeb.Components.Generic do
end
attr(:class, :string, default: "")
- attr(:color, :atom, default: :gray, values: [:gray, :indigo, :yellow, :green])
+ attr(:color, :atom, default: :gray, values: [:gray, :indigo, :yellow, :green, :red])
attr(:rest, :global)
slot(:inner_block, required: true)
@@ -1297,4 +1297,8 @@ defmodule PlausibleWeb.Components.Generic do
defp get_pill_color_classes(:green) do
"bg-green-100/70 text-green-800 dark:bg-green-900/40 dark:text-green-300"
end
+
+ defp get_pill_color_classes(:red) do
+ "bg-red-100/60 text-red-700 dark:bg-red-800/40 dark:text-red-300"
+ end
end
diff --git a/lib/plausible_web/templates/settings/subscription.html.heex b/lib/plausible_web/templates/settings/subscription.html.heex
index 3d8b45f878..303c5fac7f 100644
--- a/lib/plausible_web/templates/settings/subscription.html.heex
+++ b/lib/plausible_web/templates/settings/subscription.html.heex
@@ -1,109 +1,142 @@
<.settings_tiles>
- <.tile docs="billing">
- <:title>
- <a id="subscription">Subscription</a>
- </:title>
- <:subtitle>
- Manage your plan.
- </:subtitle>
- <div :if={@subscription} class="w-full inline-flex gap-x-4 justify-end items-center mt-4 mb-4">
- <span
- :if={Plausible.Billing.Plans.business_tier?(@subscription)}
- class={[
- "w-max px-2.5 py-0.5 rounded-md text-sm font-bold leading-5 text-indigo-600 bg-blue-100 dark:text-yellow-200 dark:border dark:bg-inherit dark:border-yellow-200"
- ]}
- >
- Business
- </span>
- <span class={[
- "w-max px-2.5 py-0.5 rounded-md text-sm font-bold leading-5",
- subscription_colors(@subscription.status)
- ]}>
- {present_subscription_status(@subscription.status)}
- </span>
- </div>
-
- <PlausibleWeb.Components.Billing.Notice.subscription_cancelled
- subscription={@subscription}
- dismissable={false}
- />
-
- <div class="flex flex-col gap-4 my-4 items-center justify-between sm:flex-row sm:items-start">
- <PlausibleWeb.Components.Billing.monthly_quota_box
- team={@current_team}
- subscription={@subscription}
- />
- <div class="w-full flex-1 h-32 px-2 py-4 text-center bg-gray-100 rounded-sm dark:bg-gray-800">
- <h4 class="font-black dark:text-gray-100">Next bill amount</h4>
- <%= if Plausible.Billing.Subscription.Status.in?(@subscription, [Plausible.Billing.Subscription.Status.active(), Plausible.Billing.Subscription.Status.past_due()]) do %>
- <div class="py-2 text-xl font-medium dark:text-gray-100">
- {PlausibleWeb.BillingView.present_currency(@subscription.currency_code)}{@subscription.next_bill_amount}
+ <%= if is_nil(@current_team) || Plausible.Teams.on_trial?(@current_team) do %>
+ <.tile docs="trial-to-paid">
+ <:title>Current plan</:title>
+ <div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
+ <div class="flex flex-col gap-1">
+ <div class="flex items-center gap-2">
+ <span class="text-sm font-semibold dark:text-gray-100">Free trial</span>
+ <.pill :if={@current_team} color={:yellow}>
+ {Plausible.Teams.trial_days_left(@current_team)} days left
+ </.pill>
</div>
- <.styled_link :if={@subscription.update_url} href={@subscription.update_url}>
- Update billing info
- </.styled_link>
- <% else %>
- <div class="py-2 text-xl font-medium dark:text-gray-100">---</div>
- <% end %>
+ <p
+ :if={is_nil(@current_team)}
+ class="text-sm text-gray-600 dark:text-gray-400"
+ >
+ Your 30-day trial will start when you add your first site
+ </p>
+ </div>
+ <.button_link
+ href={Routes.billing_path(@conn, :choose_plan)}
+ mt?={false}
+ id="upgrade-or-change-plan-link"
+ >
+ {trial_button_label(@current_team)}
+ </.button_link>
</div>
- <div class="w-full flex-1 h-32 px-2 py-4 text-center bg-gray-100 rounded-sm dark:bg-gray-800">
- <h4 class="font-black dark:text-gray-100">Next bill date</h4>
-
- <%= if @subscription && @subscription.next_bill_date && Plausible.Billing.Subscription.Status.in?(@subscription, [Plausible.Billing.Subscription.Status.active(), Plausible.Billing.Subscription.Status.past_due()]) do %>
- <div class="py-2 text-xl font-medium dark:text-gray-100">
- {Calendar.strftime(@subscription.next_bill_date, "%b %-d, %Y")}
+ </.tile>
+ <% else %>
+ <.tile docs="billing">
+ <:title>Current plan</:title>
+ <%= if @subscription do %>
+ <div class="flex flex-col gap-5">
+ <PlausibleWeb.Components.Billing.Notice.subscription_cancelled
+ subscription={@subscription}
+ dismissable={false}
+ />
+ <div class="flex flex-col sm:flex-row justify-between items-start gap-4">
+ <div class="flex flex-col gap-1">
+ <div class="flex items-center gap-2 flex-wrap">
+ <span class="text-sm font-semibold dark:text-gray-100">
+ {present_plan_name(Plausible.Billing.Plans.get_subscription_plan(@subscription))}
+ </span>
+ <.pill color={subscription_pill_color(@subscription.status)}>
+ {present_subscription_status(@subscription.status)}
+ </.pill>
+ </div>
+ <p class="text-sm text-gray-600 dark:text-gray-400">
+ Up to {PlausibleWeb.AuthView.subscription_quota(@subscription)} monthly pageviews
+ </p>
+ <%= if @subscription.next_bill_amount && @subscription.next_bill_date do %>
+ <p class="text-sm text-gray-600 dark:text-gray-400">
+ {PlausibleWeb.BillingView.present_currency(@subscription.currency_code)}{@subscription.next_bill_amount} / {present_subscription_interval(
+ @subscription
+ )} • Renews on {Calendar.strftime(@subscription.next_bill_date, "%b %-d, %Y")}
+ </p>
+ <% end %>
+ </div>
+ <div class="flex gap-2">
+ <.button_link
+ :if={
+ @subscription &&
+ Plausible.Billing.Subscriptions.resumable?(@subscription) &&
+ @subscription.update_url
+ }
+ theme="secondary"
+ href={@subscription.update_url}
+ mt?={false}
+ id="billing-details-link"
+ >
+ Billing details
+ </.button_link>
+ <.button_link
+ :if={
+ not (Plausible.Teams.Billing.enterprise_configured?(@current_team) &&
+ Plausible.Billing.Subscriptions.halted?(@subscription))
+ }
+ href={Routes.billing_path(@conn, :choose_plan)}
+ mt?={false}
+ id="upgrade-or-change-plan-link"
+ >
+ {change_plan_button_label(@subscription)}
+ </.button_link>
+ </div>
</div>
- <span class="text-gray-600 dark:text-gray-400">
- ({subscription_interval(@subscription)} billing)
- </span>
- <% else %>
- <div class="py-2 text-xl font-medium dark:text-gray-100">---</div>
- <% end %>
- </div>
- </div>
+ </div>
+ <% else %>
+ <PlausibleWeb.Components.Billing.Notice.usage_notification
+ type={:trial_ended}
+ team={@current_team}
+ />
+ <% end %>
+ </.tile>
+ <% end %>
+
+ <.tile docs="subscription-plans">
+ <:title>
+ <a id="subscription">Monthly usage</a>
+ </:title>
<PlausibleWeb.Components.Billing.render_monthly_pageview_usage
usage={@pageview_usage}
limit={@pageview_limit}
/>
+ </.tile>
- <article class="mt-8">
- <.title>Sites & team members usage</.title>
- <PlausibleWeb.Components.Billing.usage_and_limits_table>
- <PlausibleWeb.Components.Billing.usage_and_limits_row
- id="site-usage-row"
- title="Owned sites"
- usage={@site_usage}
- limit={@site_limit}
- />
- <PlausibleWeb.Components.Billing.usage_and_limits_row
- id="team-member-usage-row"
- title="Team members"
- usage={@team_member_usage}
- limit={@team_member_limit}
- />
- </PlausibleWeb.Components.Billing.usage_and_limits_table>
- </article>
+ <.tile docs="subscription-plans">
+ <:title>Site and team usage</:title>
- <%= cond do %>
- <% Plausible.Billing.Subscriptions.resumable?(@subscription) && @subscription.cancel_url -> %>
- <div class="mt-8">
- <.button_link theme="danger" href={@subscription.cancel_url}>
- Cancel my subscription
- </.button_link>
- <%= if Application.get_env(:plausible, :environment) == "dev" do %>
- <a
- href={@subscription.update_url}
- class="ml-2 font-medium rounded-md px-3.5 py-2.5 text-sm shadow-xs border border-gray-300 dark:border-gray-500 text-yellow-600 dark:text-yellow-400 bg-white dark:bg-gray-900"
- >
- [DEV ONLY] Change subscription status
- </a>
- <% end %>
- </div>
- <% true -> %>
- <div class="mt-8">
- <PlausibleWeb.Components.Billing.upgrade_link />
- </div>
- <% end %>
+ <PlausibleWeb.Components.Billing.usage_and_limits_table>
+ <PlausibleWeb.Components.Billing.usage_and_limits_row
+ id="site-usage-row"
+ title="Owned sites"
+ usage={@site_usage}
+ limit={@site_limit}
+ />
+ <PlausibleWeb.Components.Billing.usage_and_limits_row
+ id="team-member-usage-row"
+ title="Team members"
+ usage={@team_member_usage}
+ limit={@team_member_limit}
+ />
+ </PlausibleWeb.Components.Billing.usage_and_limits_table>
</.tile>
</.settings_tiles>
+
+<%= if Plausible.Billing.Subscriptions.resumable?(@subscription) && @subscription.cancel_url do %>
+ <div class="flex gap-2">
+ <.button_link theme="danger" href={@subscription.cancel_url}>
+ Cancel plan
+ </.button_link>
+ <%= if Application.get_env(:plausible, :environment) == "dev" do %>
+ <.button_link
+ href={@subscription.update_url}
+ theme="secondary"
+ class="text-yellow-600 dark:text-yellow-400"
+ >
+ [DEV ONLY] Change status
+ </.button_link>
+ <% end %>
+ </div>
+<% end %>
diff --git a/lib/plausible_web/views/settings_view.ex b/lib/plausible_web/views/settings_view.ex
index 2aea5f271d..167115a359 100644
--- a/lib/plausible_web/views/settings_view.ex
+++ b/lib/plausible_web/views/settings_view.ex
@@ -4,12 +4,58 @@ defmodule PlausibleWeb.SettingsView do
use Plausible
require Plausible.Billing.Subscription.Status
- alias Plausible.Billing.{Plans, Subscription}
+ alias Plausible.Billing.{Plans, Subscription, Subscriptions}
+
+ def present_plan_name(%Plausible.Billing.Plan{kind: kind}),
+ do: kind |> to_string() |> String.capitalize()
+
+ def present_plan_name(%Plausible.Billing.EnterprisePlan{}), do: "Enterprise"
+ def present_plan_name(:free_10k), do: "Free"
+ def present_plan_name(_), do: "Plan"
def subscription_interval(subscription) do
Plans.subscription_interval(subscription)
end
+ def present_subscription_interval(subscription) do
+ case subscription_interval(subscription) do
+ "monthly" -> "month"
+ "yearly" -> "year"
+ interval -> interval
+ end
+ end
+
+ @spec present_subscription_status(Subscription.Status.status()) :: String.t()
+ def present_subscription_status(Subscription.Status.active()), do: "Active"
+ def present_subscription_status(Subscription.Status.past_due()), do: "Past due"
+ def present_subscription_status(Subscription.Status.deleted()), do: "Cancelled"
+ def present_subscription_status(Subscription.Status.paused()), do: "Paused"
+ def present_subscription_status(status), do: status
+
+ def subscription_pill_color(Subscription.Status.active()), do: :green
+ def subscription_pill_color(Subscription.Status.past_due()), do: :yellow
+ def subscription_pill_color(Subscription.Status.paused()), do: :red
+ def subscription_pill_color(Subscription.Status.deleted()), do: :red
+ def subscription_pill_color(_), do: :gray
+
+ def trial_button_label(team) do
+ if Plausible.Teams.Billing.enterprise_configured?(team) do
+ "Upgrade"
+ else
+ "Choose a plan →"
+ end
+ end
+
+ def change_plan_button_label(nil), do: "Upgrade"
+
+ def change_plan_button_label(subscription) do
+ if Subscriptions.resumable?(subscription) && subscription.cancel_url do
+ "Change plan"
+ else
+ "Upgrade"
+ end
+ end
+
def format_invoices(invoice_list) do
Enum.map(invoice_list, fn invoice ->
%{
@@ -20,18 +66,4 @@ defmodule PlausibleWeb.SettingsView do
}
end)
end
-
- @spec present_subscription_status(Subscription.Status.status()) :: String.t()
- def present_subscription_status(Subscription.Status.active()), do: "Active"
- def present_subscription_status(Subscription.Status.past_due()), do: "Past due"
- def present_subscription_status(Subscription.Status.deleted()), do: "Cancelled"
- def present_subscription_status(Subscription.Status.paused()), do: "Paused"
- def present_subscription_status(status), do: status
-
- @spec subscription_colors(Subscription.Status.status()) :: String.t()
- def subscription_colors(Subscription.Status.active()), do: "bg-green-100 text-green-800"
- def subscription_colors(Subscription.Status.past_due()), do: "bg-yellow-100 text-yellow-800"
- def subscription_colors(Subscription.Status.paused()), do: "bg-red-100 text-red-800"
- def subscription_colors(Subscription.Status.deleted()), do: "bg-red-100 text-red-800"
- def subscription_colors(_), do: ""
end
diff --git a/test/plausible_web/controllers/settings_controller_test.exs b/test/plausible_web/controllers/settings_controller_test.exs
index 6a912fd505..032d9dc4ef 100644
--- a/test/plausible_web/controllers/settings_controller_test.exs
+++ b/test/plausible_web/controllers/settings_controller_test.exs
@@ -25,24 +25,24 @@ defmodule PlausibleWeb.SettingsControllerTest do
test "shows subscription", %{conn: conn, user: user} do
subscribe_to_plan(user, "558018")
conn = get(conn, Routes.settings_path(conn, :subscription))
- assert html_response(conn, 200) =~ "10k pageviews"
- assert html_response(conn, 200) =~ "monthly billing"
+ assert html_response(conn, 200) =~ "10k monthly pageviews"
+ assert html_response(conn, 200) =~ "/ month"
end
@tag :ee_only
test "shows yearly subscription", %{conn: conn, user: user} do
subscribe_to_plan(user, "590752")
conn = get(conn, Routes.settings_path(conn, :subscription))
- assert html_response(conn, 200) =~ "100k pageviews"
- assert html_response(conn, 200) =~ "yearly billing"
+ assert html_response(conn, 200) =~ "100k monthly pageviews"
+ assert html_response(conn, 200) =~ "/ year"
end
@tag :ee_only
test "shows free subscription", %{conn: conn, user: user} do
subscribe_to_plan(user, "free_10k")
conn = get(conn, Routes.settings_path(conn, :subscription))
- assert html_response(conn, 200) =~ "10k pageviews"
- assert html_response(conn, 200) =~ "N/A billing"
+ assert html_response(conn, 200) =~ "10k monthly pageviews"
+ assert html_response(conn, 200) =~ "N/A"
end
@tag :ee_only
@@ -50,8 +50,8 @@ defmodule PlausibleWeb.SettingsControllerTest do
configure_enterprise_plan(user)
conn = get(conn, Routes.settings_path(conn, :subscription))
- assert html_response(conn, 200) =~ "20M pageviews"
- assert html_response(conn, 200) =~ "yearly billing"
+ assert html_response(conn, 200) =~ "20M monthly pageviews"
+ assert html_response(conn, 200) =~ "/ year"
end
@tag :ee_only
@@ -69,25 +69,44 @@ defmodule PlausibleWeb.SettingsControllerTest do
)
conn = get(conn, Routes.settings_path(conn, :subscription))
- assert html_response(conn, 200) =~ "20M pageviews"
- assert html_response(conn, 200) =~ "yearly billing"
+ assert html_response(conn, 200) =~ "20M monthly pageviews"
+ assert html_response(conn, 200) =~ "/ year"
end
@tag :ee_only
- test "renders two links to '/billing/choose-plan` with the text 'Upgrade'", %{conn: conn} do
+ test "shows trial state without days-left pill when user has no team yet", %{conn: conn} do
doc =
conn
|> get(Routes.settings_path(conn, :subscription))
|> html_response(200)
- upgrade_link_1 = find(doc, "#monthly-quota-box a")
- upgrade_link_2 = find(doc, "#upgrade-link-2")
+ upgrade_link = find(doc, "#upgrade-or-change-plan-link")
- assert text(upgrade_link_1) == "Upgrade"
- assert text_of_attr(upgrade_link_1, "href") == Routes.billing_path(conn, :choose_plan)
+ assert text(upgrade_link) =~ "Choose a plan"
+ assert text_of_attr(upgrade_link, "href") == Routes.billing_path(conn, :choose_plan)
+ assert doc =~ "Your 30-day trial will start when you add your first site"
+ refute doc =~ "days left"
+ end
+
+ @tag :ee_only
+ test "shows trial state with days-left pill when user is on trial", %{conn: conn, user: user} do
+ {:ok, team} = Plausible.Teams.get_or_create(user)
+
+ team
+ |> Ecto.Changeset.change(trial_expiry_date: Date.add(Date.utc_today(), 10))
+ |> Plausible.Repo.update!()
+
+ doc =
+ conn
+ |> get(Routes.settings_path(conn, :subscription))
+ |> html_response(200)
+
+ upgrade_link = find(doc, "#upgrade-or-change-plan-link")
- assert text(upgrade_link_2) == "Upgrade"
- assert text_of_attr(upgrade_link_2, "href") == Routes.billing_path(conn, :choose_plan)
+ assert text(upgrade_link) =~ "Choose a plan"
+ assert text_of_attr(upgrade_link, "href") == Routes.billing_path(conn, :choose_plan)
+ assert doc =~ "days left"
+ refute doc =~ "Your 30-day trial will start when you add your first site"
end
@tag :ee_only
@@ -102,15 +121,15 @@ defmodule PlausibleWeb.SettingsControllerTest do
|> get(Routes.settings_path(conn, :subscription))
|> html_response(200)
- refute element_exists?(doc, "#upgrade-link-2")
- assert doc =~ "Cancel my subscription"
+ assert doc =~ "Cancel plan"
- change_plan_link = find(doc, "#monthly-quota-box a")
+ change_plan_link = find(doc, "#upgrade-or-change-plan-link")
assert text(change_plan_link) == "Change plan"
assert text_of_attr(change_plan_link, "href") == Routes.billing_path(conn, :choose_plan)
end
+ @tag :ee_only
test "/billing/choose-plan link does not show up when enterprise subscription is past_due", %{
conn: conn,
user: user
@@ -125,6 +144,7 @@ defmodule PlausibleWeb.SettingsControllerTest do
refute element_exists?(doc, "#upgrade-or-change-plan-link")
end
+ @tag :ee_only
test "/billing/choose-plan link does not show up when enterprise subscription is paused", %{
conn: conn,
user: user
@@ -140,7 +160,7 @@ defmodule PlausibleWeb.SettingsControllerTest do
end
@tag :ee_only
- test "renders two links to '/billing/choose-plan' with the text 'Upgrade' for a configured enterprise plan",
+ test "renders a link to '/billing/choose-plan' with the text 'Upgrade' for a configured enterprise plan",
%{conn: conn, user: user} do
subscribe_to_enterprise_plan(user,
paddle_plan_id: @configured_enterprise_plan_paddle_plan_id,
@@ -154,18 +174,10 @@ defmodule PlausibleWeb.SettingsControllerTest do
|> get(Routes.settings_path(conn, :subscription))
|> html_response(200)
- upgrade_link_1 = find(doc, "#monthly-quota-box a")
- upgrade_link_2 = find(doc, "#upgrade-link-2")
-
- assert text(upgrade_link_1) == "Upgrade"
+ upgrade_link = find(doc, "#upgrade-or-change-plan-link")
- assert text_of_attr(upgrade_link_1, "href") ==
- Routes.billing_path(conn, :choose_plan)
-
- assert text(upgrade_link_2) == "Upgrade"
-
- assert text_of_attr(upgrade_link_2, "href") ==
- Routes.billing_path(conn, :choose_plan)
+ assert text(upgrade_link) == "Upgrade"
+ assert text_of_attr(upgrade_link, "href") == Routes.billing_path(conn, :choose_plan)
end
@tag :ee_only
@@ -178,10 +190,9 @@ defmodule PlausibleWeb.SettingsControllerTest do
|> get(Routes.settings_path(conn, :subscription))
|> html_response(200)
- refute element_exists?(doc, "#upgrade-link-2")
- assert doc =~ "Cancel my subscription"
+ assert doc =~ "Cancel plan"
- change_plan_link = find(doc, "#monthly-quota-box a")
+ change_plan_link = find(doc, "#upgrade-or-change-plan-link")
assert text(change_plan_link) == "Change plan"