mirror of
https://github.com/plausible/analytics.git
synced 2024-08-17 05:40:24 +03:00
Hide 20M and 50M legacy plans from the upgrade page (#4248)
* Stop showing 20M and 50M plans unless user is already on one * Add tests
This commit is contained in:
parent
e453d364d4
commit
db1e755b0e
@ -45,8 +45,8 @@ defmodule Plausible.Billing.Plans do
|
||||
is_nil(owned_plan) -> @plans_v4
|
||||
user.subscription && Subscriptions.expired?(user.subscription) -> @plans_v4
|
||||
owned_plan.kind == :business -> @plans_v4
|
||||
owned_plan.generation == 1 -> @plans_v1
|
||||
owned_plan.generation == 2 -> @plans_v2
|
||||
owned_plan.generation == 1 -> @plans_v1 |> drop_high_plans(owned_plan)
|
||||
owned_plan.generation == 2 -> @plans_v2 |> drop_high_plans(owned_plan)
|
||||
owned_plan.generation == 3 -> @plans_v3
|
||||
owned_plan.generation == 4 -> @plans_v4
|
||||
end
|
||||
@ -80,6 +80,14 @@ defmodule Plausible.Billing.Plans do
|
||||
Enum.group_by(plans, & &1.kind)
|
||||
end
|
||||
|
||||
@high_legacy_volumes [20_000_000, 50_000_000]
|
||||
defp drop_high_plans(plans, %Plan{monthly_pageview_limit: current_volume} = _owned) do
|
||||
plans
|
||||
|> Enum.reject(fn %Plan{monthly_pageview_limit: plan_volume} ->
|
||||
plan_volume in @high_legacy_volumes and current_volume < plan_volume
|
||||
end)
|
||||
end
|
||||
|
||||
@spec yearly_product_ids() :: [String.t()]
|
||||
@doc """
|
||||
List yearly plans product IDs.
|
||||
|
@ -8,6 +8,8 @@ defmodule PlausibleWeb.Live.ChoosePlanTest do
|
||||
alias Plausible.{Repo, Billing.Subscription}
|
||||
|
||||
@v1_10k_yearly_plan_id "572810"
|
||||
@v1_50m_yearly_plan_id "650653"
|
||||
@v2_20m_yearly_plan_id "653258"
|
||||
@v4_growth_10k_yearly_plan_id "857079"
|
||||
@v4_growth_200k_yearly_plan_id "857081"
|
||||
@v4_business_5m_monthly_plan_id "857111"
|
||||
@ -728,16 +730,13 @@ defmodule PlausibleWeb.Live.ChoosePlanTest do
|
||||
end
|
||||
end
|
||||
|
||||
describe "for a grandfathered user" do
|
||||
describe "for a grandfathered user with a high volume plan" do
|
||||
setup [:create_user, :create_site, :log_in]
|
||||
|
||||
setup %{user: user} = context do
|
||||
create_subscription_for(user, paddle_plan_id: @v1_10k_yearly_plan_id)
|
||||
{:ok, context}
|
||||
end
|
||||
test "on a 50M v1 plan, Growth tiers are available at 20M, 50M, 50M+, but Business tiers are not",
|
||||
%{conn: conn, user: user} do
|
||||
create_subscription_for(user, paddle_plan_id: @v1_50m_yearly_plan_id)
|
||||
|
||||
test "on a v1 plan, Growth tiers are available at 20M, 50M, 50M+, but Business tiers are not",
|
||||
%{conn: conn} do
|
||||
{:ok, lv, _doc} = get_liveview(conn)
|
||||
|
||||
doc = set_slider(lv, 8)
|
||||
@ -763,6 +762,42 @@ defmodule PlausibleWeb.Live.ChoosePlanTest do
|
||||
refute text_of_element(doc, @growth_plan_box) =~ "Contact us"
|
||||
end
|
||||
|
||||
test "on a 20M v2 plan, Growth tiers are available at 20M and 20M+, but not 50M",
|
||||
%{conn: conn, user: user} do
|
||||
create_subscription_for(user, paddle_plan_id: @v2_20m_yearly_plan_id)
|
||||
|
||||
{:ok, lv, _doc} = get_liveview(conn)
|
||||
|
||||
doc = set_slider(lv, 8)
|
||||
assert text_of_element(doc, @slider_value) == "20M"
|
||||
assert text_of_element(doc, @business_plan_box) =~ "Contact us"
|
||||
assert text_of_element(doc, @growth_price_tag_amount) == "€900"
|
||||
assert text_of_element(doc, @growth_price_tag_interval) == "/year"
|
||||
|
||||
doc = set_slider(lv, 9)
|
||||
assert text_of_element(doc, @slider_value) == "20M+"
|
||||
assert text_of_element(doc, @business_plan_box) =~ "Contact us"
|
||||
assert text_of_element(doc, @growth_plan_box) =~ "Contact us"
|
||||
end
|
||||
end
|
||||
|
||||
describe "for a grandfathered user on a v1 10k plan" do
|
||||
setup [:create_user, :create_site, :log_in]
|
||||
|
||||
setup %{user: user} = context do
|
||||
create_subscription_for(user, paddle_plan_id: @v1_10k_yearly_plan_id)
|
||||
{:ok, context}
|
||||
end
|
||||
|
||||
test "v1 20M and 50M Growth plans are not available",
|
||||
%{conn: conn} do
|
||||
{:ok, lv, _doc} = get_liveview(conn)
|
||||
|
||||
doc = set_slider(lv, 8)
|
||||
assert text_of_element(doc, @slider_value) == "10M+"
|
||||
assert text_of_element(doc, @growth_plan_box) =~ "Contact us"
|
||||
end
|
||||
|
||||
test "displays grandfathering notice in the Growth box instead of benefits", %{conn: conn} do
|
||||
{:ok, _lv, doc} = get_liveview(conn)
|
||||
growth_box = text_of_element(doc, @growth_plan_box)
|
||||
|
Loading…
Reference in New Issue
Block a user