analytics/test/plausible_web/live/choose_plan_test.exs

807 lines
32 KiB
Elixir
Raw Normal View History

Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
defmodule PlausibleWeb.Live.ChoosePlanTest do
use PlausibleWeb.ConnCase, async: true
import Phoenix.LiveViewTest
import Plausible.Test.Support.HTML
Refactor enterprise plan upgrade and change-plan actions (#3397) * rename enterprise?/1 function * change link text to Upgrade when subscription deleted * extract paddle_button and paddle_script components * create a new upgrade-to-enterprise-plan page * extract upgrade_link component * rename function * link to enterprise plan upgrade page from settings ...if the user has an enterprise plan configured * fetch enterprise plan price on the new page * add change_enterprise_plan functionality on the new page * render existing change_enterprise_plan_contact_us.html ...when subscribed to latest configured enterprise plan * rename vars and extract resumable? fn * remove dead billing route * small test refactor: extract convenience fn * add tests for... ...restricting paused and past_due subscription access to the new enterprise plan page. 1. redirect to /settings from the controller action 2. hiding the change-plan link from the user settings * implement redirect to /settings * hide the enterprise upgrade/change-plan link * add tests for a deleted enterprise subscription * plug in the new controller action and delete dead code * optimize for dark mode * fix compile warning * credo fix * display N/A instead of crash when price nil * change subscription.status type to Ecto.Enum Also, create a new `Subscription.Status` module that exposes macros to return the used atom values (prevent typos at compiletime). * fix bug (@conn not available anymore) * use Routes.billing_path where applicable * add a status() type * silence credo * refactor suggestion from review Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Remove the __using__ macro from Subscription.Status ... instead be explicit about requires and aliases and also order the use, import, require, and alias clauses according to https://github.com/christopheradams/elixir_style_guide#module-attribute-ordering * drop the virtual Enteprise 'price_per_interval' field * apply review suggestion to make the code more DRY * use dot syntax to fetch current user in new controller actions * fix formatting --------- Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2023-10-10 20:35:17 +03:00
require Plausible.Billing.Subscription.Status
alias Plausible.{Repo, Billing.Subscription}
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
@v1_10k_yearly_plan_id "572810"
@v4_growth_200k_yearly_plan_id "857081"
@v4_business_5m_monthly_plan_id "857111"
@v3_business_10k_monthly_plan_id "857481"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
@monthly_interval_button ~s/label[phx-click="set_interval"][phx-value-interval="monthly"]/
@yearly_interval_button ~s/label[phx-click="set_interval"][phx-value-interval="yearly"]/
@interval_button_active_class "bg-indigo-600 text-white"
@slider_input ~s/input[name="slider"]/
@slider_value "#slider-value"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
@growth_plan_box "#growth-plan-box"
@growth_price_tag_amount "#growth-price-tag-amount"
@growth_price_tag_interval "#growth-price-tag-interval"
@growth_highlight_pill "#{@growth_plan_box} #highlight-pill"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
@growth_checkout_button "#growth-checkout"
@business_plan_box "#business-plan-box"
@business_price_tag_amount "#business-price-tag-amount"
@business_price_tag_interval "#business-price-tag-interval"
@business_highlight_pill "#{@business_plan_box} #highlight-pill"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
@business_checkout_button "#business-checkout"
@enterprise_plan_box "#enterprise-plan-box"
@slider_volumes ["10k", "100k", "200k", "500k", "1M", "2M", "5M", "10M", "10M+"]
describe "for a legacy trial (user registered before business tiers release)" do
setup %{conn: conn} do
Limit grandfathering to *active* subscribers and trials (#3524) * refactor asserting plan generation in plans_test.exs * stop grandfathering old expired trials For users who registered before the business tiers release, we want to offer a chance to subscribe to a grandfathered plan. However, if they let their trial expire and don't subscribe in the next 10 days, they'll lose that opportunity. * stop grandfathering expired subscriptions * remove default title and icon from Generic.notice * fix bug with dismissable notice classList is null when dismissable_id is not given * alias Plausible.Auth.User * Refactor Generic.notice component Make it easy to apply different colors * move subscription_cancelled_notice across the app And remove from user settings > subscription box. Also, include a note about losing grandfathered status when letting the subscription expire. * allow full width in Generic.notice * use Generic.notice for subscription_past_due_notice * use Generic.notice for subscription_paused_notice * prevent two notices clashing into each other with gap-y-2 * define attrs for phx components * optimize for light mode * make subscription cancelled notice dismissable but if it's dismiss, show it in the place where it was before in the account settings > subscription box * make function private * replace function doc with regular comment to avoid compile warning * use array for classnames Co-authored-by: Vinicius Brasil <vini@hey.com> * fix typos in function doc --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-11-16 18:40:50 +03:00
user = insert(:user, trial_expiry_date: ~D[2023-11-24])
{:ok, conn: conn} = log_in(%{conn: conn, user: user})
{:ok, conn: conn, user: user}
end
test "renders v3 plan benefits, but no grandfathering notice", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
growth_box = text_of_element(doc, @growth_plan_box)
business_box = text_of_element(doc, @business_plan_box)
assert growth_box =~ "Unlimited team members"
assert growth_box =~ "Up to 50 sites"
assert growth_box =~ "Intuitive, fast and privacy-friendly dashboard"
assert growth_box =~ "Email/Slack reports"
assert growth_box =~ "Google Analytics import"
assert growth_box =~ "Goals and custom events"
assert growth_box =~ "Stats API (600 requests per hour)"
assert growth_box =~ "Custom Properties"
assert business_box =~ "Everything in Growth"
assert business_box =~ "Funnels"
assert business_box =~ "Ecommerce revenue attribution"
assert business_box =~ "Priority support"
refute growth_box =~ "Your subscription has been grandfathered"
end
end
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
describe "for a user with no subscription" do
setup [:create_user, :log_in]
test "displays basic page content", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
assert doc =~ "Upgrade your account"
assert doc =~ "You have used"
assert doc =~ "<b>0</b>"
assert doc =~ "billable pageviews in the last 30 days"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert doc =~ "Questions?"
assert doc =~ "What happens if I go over my page views limit?"
assert doc =~ "Enterprise"
assert doc =~ "+ VAT if applicable"
end
test "displays plan benefits", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
growth_box = text_of_element(doc, @growth_plan_box)
business_box = text_of_element(doc, @business_plan_box)
enterprise_box = text_of_element(doc, @enterprise_plan_box)
assert growth_box =~ "Up to 3 team members"
assert growth_box =~ "Up to 10 sites"
assert growth_box =~ "Intuitive, fast and privacy-friendly dashboard"
assert growth_box =~ "Email/Slack reports"
assert growth_box =~ "Google Analytics import"
assert growth_box =~ "Goals and custom events"
assert business_box =~ "Everything in Growth"
assert business_box =~ "Up to 10 team members"
assert business_box =~ "Up to 50 sites"
assert business_box =~ "Stats API (600 requests per hour)"
assert business_box =~ "Custom Properties"
assert business_box =~ "Funnels"
assert business_box =~ "Ecommerce revenue attribution"
assert business_box =~ "Priority support"
refute business_box =~ "Goals and custom events"
assert enterprise_box =~ "Everything in Business"
assert enterprise_box =~ "10+ team members"
assert enterprise_box =~ "50+ sites"
assert enterprise_box =~ "600+ Stats API requests per hour"
assert enterprise_box =~ "Sites API access for"
assert enterprise_box =~ "Technical onboarding"
assert text_of_attr(find(doc, "#{@enterprise_plan_box} p a"), "href") =~
"https://plausible.io/white-label-web-analytics"
end
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
test "default billing interval is monthly, and can switch to yearly", %{conn: conn} do
{:ok, lv, doc} = get_liveview(conn)
assert class_of_element(doc, @monthly_interval_button) =~ @interval_button_active_class
refute class_of_element(doc, @yearly_interval_button) =~ @interval_button_active_class
doc = element(lv, @yearly_interval_button) |> render_click()
refute class_of_element(doc, @monthly_interval_button) =~ @interval_button_active_class
assert class_of_element(doc, @yearly_interval_button) =~ @interval_button_active_class
end
test "default pageview limit is 10k", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
assert text_of_element(doc, @slider_value) == "10k"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @growth_price_tag_amount) == "€10"
assert text_of_element(doc, @business_price_tag_amount) == "€90"
end
test "pageview slider changes selected volume and prices shown", %{conn: conn} do
{:ok, lv, _doc} = get_liveview(conn)
doc = set_slider(lv, "100k")
assert text_of_element(doc, @slider_value) == "100k"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @growth_price_tag_amount) == "€20"
assert text_of_element(doc, @business_price_tag_amount) == "€100"
doc = set_slider(lv, "200k")
assert text_of_element(doc, @slider_value) == "200k"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @growth_price_tag_amount) == "€30"
assert text_of_element(doc, @business_price_tag_amount) == "€110"
doc = set_slider(lv, "500k")
assert text_of_element(doc, @slider_value) == "500k"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @growth_price_tag_amount) == "€40"
assert text_of_element(doc, @business_price_tag_amount) == "€120"
doc = set_slider(lv, "1M")
assert text_of_element(doc, @slider_value) == "1M"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @growth_price_tag_amount) == "€50"
assert text_of_element(doc, @business_price_tag_amount) == "€130"
doc = set_slider(lv, "2M")
assert text_of_element(doc, @slider_value) == "2M"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @growth_price_tag_amount) == "€60"
assert text_of_element(doc, @business_price_tag_amount) == "€140"
doc = set_slider(lv, "5M")
assert text_of_element(doc, @slider_value) == "5M"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @growth_price_tag_amount) == "€70"
assert text_of_element(doc, @business_price_tag_amount) == "€150"
doc = set_slider(lv, "10M")
assert text_of_element(doc, @slider_value) == "10M"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @growth_price_tag_amount) == "€80"
assert text_of_element(doc, @business_price_tag_amount) == "€160"
end
test "renders contact links for business and growth tiers when enterprise-level volume selected",
%{
conn: conn
} do
{:ok, lv, _doc} = get_liveview(conn)
doc = set_slider(lv, "10M+")
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, "#growth-custom-price") =~ "Custom"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @growth_plan_box) =~ "Contact us"
assert text_of_element(doc, "#business-custom-price") =~ "Custom"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @business_plan_box) =~ "Contact us"
doc = set_slider(lv, "10M")
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
refute text_of_element(doc, "#growth-custom-price") =~ "Custom"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
refute text_of_element(doc, @growth_plan_box) =~ "Contact us"
refute text_of_element(doc, "#business-custom-price") =~ "Custom"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
refute text_of_element(doc, @business_plan_box) =~ "Contact us"
end
test "switching billing interval changes business and growth prices", %{conn: conn} do
{:ok, lv, doc} = get_liveview(conn)
assert text_of_element(doc, @growth_price_tag_amount) == "€10"
assert text_of_element(doc, @growth_price_tag_interval) == "/month"
assert text_of_element(doc, @business_price_tag_amount) == "€90"
assert text_of_element(doc, @business_price_tag_interval) == "/month"
doc = element(lv, @yearly_interval_button) |> render_click()
assert text_of_element(doc, @growth_price_tag_amount) == "€100"
assert text_of_element(doc, @growth_price_tag_interval) == "/year"
assert text_of_element(doc, @business_price_tag_amount) == "€900"
assert text_of_element(doc, @business_price_tag_interval) == "/year"
end
test "checkout buttons are 'paddle buttons' with dynamic onclick attribute", %{
conn: conn,
user: user
} do
{:ok, lv, _doc} = get_liveview(conn)
set_slider(lv, "200k")
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
doc = element(lv, @yearly_interval_button) |> render_click()
assert %{
"disableLogout" => true,
"email" => user.email,
"passthrough" => user.id,
"product" => @v4_growth_200k_yearly_plan_id,
"success" => Routes.billing_path(PlausibleWeb.Endpoint, :upgrade_success),
"theme" => "none"
} == get_paddle_checkout_params(find(doc, @growth_checkout_button))
set_slider(lv, "5M")
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
doc = element(lv, @monthly_interval_button) |> render_click()
assert get_paddle_checkout_params(find(doc, @business_checkout_button))["product"] ==
@v4_business_5m_monthly_plan_id
end
test "warns about losing access to a feature", %{conn: conn, user: user} do
site = insert(:site, members: [user])
Plausible.Props.allow(site, ["author"])
{:ok, _lv, doc} = get_liveview(conn)
assert text_of_attr(find(doc, @growth_checkout_button), "onclick") =~
"if (confirm(\"This plan does not support Custom Properties, which you are currently using. Please note that by subscribing to this plan you will lose access to this feature.\")) {Paddle.Checkout.open"
end
test "recommends Growth tier when no premium features were used", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
assert text_of_element(doc, @growth_plan_box) =~ "Recommended"
refute text_of_element(doc, @business_plan_box) =~ "Recommended"
end
test "recommends Business tier when Revenue Goals were used during trial", %{
conn: conn,
user: user
} do
site = insert(:site, members: [user])
insert(:goal, site: site, currency: :USD, event_name: "Purchase")
{:ok, _lv, doc} = get_liveview(conn)
assert text_of_element(doc, @business_plan_box) =~ "Recommended"
refute text_of_element(doc, @growth_plan_box) =~ "Recommended"
end
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end
describe "for a user with a v4 growth subscription plan" do
setup [:create_user, :log_in, :subscribe_v4_growth]
test "displays basic page content", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
assert doc =~ "Change subscription plan"
assert doc =~ "Questions?"
refute doc =~ "What happens if I go over my page views limit?"
end
test "displays plan benefits", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
growth_box = text_of_element(doc, @growth_plan_box)
business_box = text_of_element(doc, @business_plan_box)
enterprise_box = text_of_element(doc, @enterprise_plan_box)
assert growth_box =~ "Up to 3 team members"
assert growth_box =~ "Up to 10 sites"
assert growth_box =~ "Intuitive, fast and privacy-friendly dashboard"
assert growth_box =~ "Email/Slack reports"
assert growth_box =~ "Google Analytics import"
assert growth_box =~ "Goals and custom events"
assert business_box =~ "Everything in Growth"
assert business_box =~ "Up to 10 team members"
assert business_box =~ "Up to 50 sites"
assert business_box =~ "Stats API (600 requests per hour)"
assert business_box =~ "Custom Properties"
assert business_box =~ "Funnels"
assert business_box =~ "Ecommerce revenue attribution"
assert business_box =~ "Priority support"
refute business_box =~ "Goals and custom events"
assert enterprise_box =~ "Everything in Business"
assert enterprise_box =~ "10+ team members"
assert enterprise_box =~ "50+ sites"
assert enterprise_box =~ "600+ Stats API requests per hour"
assert enterprise_box =~ "Sites API access for"
assert enterprise_box =~ "Technical onboarding"
assert text_of_attr(find(doc, "#{@enterprise_plan_box} p a"), "href") =~
"https://plausible.io/white-label-web-analytics"
end
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
test "displays usage", %{conn: conn, user: user} do
site = insert(:site, members: [user])
populate_stats(site, [
build(:pageview),
build(:pageview)
])
{:ok, _lv, doc} = get_liveview(conn)
assert doc =~ "You have used"
assert doc =~ "<b>2</b>"
assert doc =~ "billable pageviews in the last 30 days"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end
test "gets default selected interval from current subscription plan", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
assert class_of_element(doc, @yearly_interval_button) =~ @interval_button_active_class
end
test "gets default pageview limit from current subscription plan", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
assert text_of_element(doc, @slider_value) == "200k"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end
test "pageview slider changes selected volume", %{conn: conn} do
{:ok, lv, _doc} = get_liveview(conn)
doc = set_slider(lv, "100k")
assert text_of_element(doc, @slider_value) == "100k"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
doc = set_slider(lv, "10k")
assert text_of_element(doc, @slider_value) == "10k"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end
test "makes it clear that the user is currently on a growth tier", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
class = class_of_element(doc, @growth_plan_box)
assert class =~ "ring-2"
assert class =~ "ring-indigo-600"
assert text_of_element(doc, @growth_highlight_pill) == "Current"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end
test "checkout button text and click-disabling CSS classes are dynamic", %{conn: conn} do
{:ok, lv, doc} = get_liveview(conn)
assert text_of_element(doc, @growth_checkout_button) == "Currently on this plan"
assert class_of_element(doc, @growth_checkout_button) =~ "pointer-events-none bg-gray-400"
assert text_of_element(doc, @business_checkout_button) == "Upgrade to Business"
doc = element(lv, @monthly_interval_button) |> render_click()
assert text_of_element(doc, @growth_checkout_button) == "Change billing interval"
assert text_of_element(doc, @business_checkout_button) == "Upgrade to Business"
doc = set_slider(lv, "1M")
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @growth_checkout_button) == "Upgrade"
assert text_of_element(doc, @business_checkout_button) == "Upgrade to Business"
doc = set_slider(lv, "100k")
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @growth_checkout_button) == "Downgrade"
assert text_of_element(doc, @business_checkout_button) == "Upgrade to Business"
end
test "checkout buttons are dynamic links to /billing/change-plan/preview/<plan_id>", %{
conn: conn
} do
{:ok, lv, doc} = get_liveview(conn)
growth_checkout_button = find(doc, @growth_checkout_button)
assert text_of_attr(growth_checkout_button, "onclick") =~
"if (true) {window.location = '#{Routes.billing_path(conn, :change_plan_preview, @v4_growth_200k_yearly_plan_id)}'}"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
set_slider(lv, "5M")
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
doc = element(lv, @monthly_interval_button) |> render_click()
business_checkout_button = find(doc, @business_checkout_button)
assert text_of_attr(business_checkout_button, "onclick") =~
"if (true) {window.location = '#{Routes.billing_path(conn, :change_plan_preview, @v4_business_5m_monthly_plan_id)}'}"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end
end
describe "for a user with a v4 business subscription plan" do
setup [:create_user, :log_in, :subscribe_v4_business]
test "gets default pageview limit from current subscription plan", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
assert text_of_element(doc, @slider_value) == "5M"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end
test "makes it clear that the user is currently on a business tier", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
class = class_of_element(doc, @business_plan_box)
assert class =~ "ring-2"
assert class =~ "ring-indigo-600"
assert text_of_element(doc, @business_highlight_pill) == "Current"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end
test "checkout button text and click-disabling CSS classes are dynamic", %{conn: conn} do
{:ok, lv, doc} = get_liveview(conn)
assert text_of_element(doc, @business_checkout_button) == "Currently on this plan"
assert class_of_element(doc, @business_checkout_button) =~ "pointer-events-none bg-gray-400"
assert text_of_element(doc, @growth_checkout_button) == "Downgrade to Growth"
doc = element(lv, @yearly_interval_button) |> render_click()
assert text_of_element(doc, @business_checkout_button) == "Change billing interval"
assert text_of_element(doc, @growth_checkout_button) == "Downgrade to Growth"
doc = set_slider(lv, "10M")
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @business_checkout_button) == "Upgrade"
assert text_of_element(doc, @growth_checkout_button) == "Downgrade to Growth"
doc = set_slider(lv, "100k")
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @business_checkout_button) == "Downgrade"
assert text_of_element(doc, @growth_checkout_button) == "Downgrade to Growth"
end
test "checkout is disabled when team member usage exceeds rendered plan limit", %{
conn: conn,
user: user
} do
insert(:site,
memberships: [
build(:site_membership, user: user, role: :owner),
build(:site_membership, user: build(:user)),
build(:site_membership, user: build(:user)),
build(:site_membership, user: build(:user)),
build(:site_membership, user: build(:user))
]
)
{:ok, _lv, doc} = get_liveview(conn)
assert text_of_element(doc, @growth_plan_box) =~ "Your usage exceeds this plan"
assert class_of_element(doc, @growth_checkout_button) =~ "pointer-events-none"
end
test "checkout is disabled when sites usage exceeds rendered plan limit", %{
conn: conn,
user: user
} do
for _ <- 1..11, do: insert(:site, members: [user])
{:ok, _lv, doc} = get_liveview(conn)
assert text_of_element(doc, @growth_plan_box) =~ "Your usage exceeds this plan"
assert class_of_element(doc, @growth_checkout_button) =~ "pointer-events-none"
end
test "warns about losing access to a feature", %{conn: conn, user: user} do
site = insert(:site, members: [user])
Plausible.Props.allow(site, ["author"])
insert(:goal, currency: :USD, site: site, event_name: "Purchase")
insert(:api_key, user: user)
{:ok, _lv, doc} = get_liveview(conn)
assert text_of_attr(find(doc, @growth_checkout_button), "onclick") =~
"if (confirm(\"This plan does not support Custom Properties, Revenue Goals and Stats API, which you are currently using. Please note that by subscribing to this plan you will lose access to these features.\")) {window.location = "
end
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end
describe "for a user with a v3 business (unlimited team members) subscription plan" do
setup [:create_user, :log_in]
setup %{user: user} = context do
create_subscription_for(user, paddle_plan_id: @v3_business_10k_monthly_plan_id)
{:ok, context}
end
test "displays plan benefits", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
growth_box = text_of_element(doc, @growth_plan_box)
business_box = text_of_element(doc, @business_plan_box)
enterprise_box = text_of_element(doc, @enterprise_plan_box)
assert growth_box =~ "Up to 3 team members"
assert growth_box =~ "Up to 10 sites"
assert growth_box =~ "Intuitive, fast and privacy-friendly dashboard"
assert growth_box =~ "Email/Slack reports"
assert growth_box =~ "Google Analytics import"
assert growth_box =~ "Goals and custom events"
assert business_box =~ "Everything in Growth"
assert business_box =~ "Unlimited team members"
assert business_box =~ "Up to 50 sites"
assert business_box =~ "Stats API (600 requests per hour)"
assert business_box =~ "Custom Properties"
assert business_box =~ "Funnels"
assert business_box =~ "Ecommerce revenue attribution"
assert business_box =~ "Priority support"
refute business_box =~ "Goals and custom events"
assert enterprise_box =~ "Everything in Business"
assert enterprise_box =~ "50+ sites"
assert enterprise_box =~ "600+ Stats API requests per hour"
assert enterprise_box =~ "Sites API access for"
assert enterprise_box =~ "Technical onboarding"
refute enterprise_box =~ "team members"
assert text_of_attr(find(doc, "#{@enterprise_plan_box} p a"), "href") =~
"https://plausible.io/white-label-web-analytics"
end
end
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
describe "for a user with a past_due subscription" do
setup [:create_user, :log_in, :create_past_due_subscription]
test "renders failed payment notice and link to update billing details", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
assert doc =~ "There was a problem with your latest payment"
assert doc =~ "https://update.billing.details"
end
test "checkout buttons are disabled + notice about billing details (unless plan owned already)",
%{conn: conn} do
{:ok, lv, doc} = get_liveview(conn)
assert class_of_element(doc, @growth_checkout_button) =~ "pointer-events-none bg-gray-400"
assert text_of_element(doc, @growth_checkout_button) =~ "Currently on this plan"
refute element_exists?(doc, "#{@growth_checkout_button} + p")
assert class_of_element(doc, @business_checkout_button) =~ "pointer-events-none bg-gray-400"
assert text_of_element(doc, "#{@business_checkout_button} + p") =~
"Please update your billing details first"
doc = set_slider(lv, "1M")
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert class_of_element(doc, @growth_checkout_button) =~ "pointer-events-none bg-gray-400"
assert text_of_element(doc, "#{@growth_checkout_button} + p") =~
"Please update your billing details first"
end
end
describe "for a user with a paused subscription" do
setup [:create_user, :log_in, :create_paused_subscription]
test "renders subscription paused notice and link to update billing details", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
assert doc =~ "Your subscription is paused due to failed payments"
assert doc =~ "https://update.billing.details"
end
test "checkout buttons are disabled + notice about billing details when plan not owned already",
%{conn: conn} do
{:ok, lv, doc} = get_liveview(conn)
assert class_of_element(doc, @growth_checkout_button) =~ "pointer-events-none bg-gray-400"
assert text_of_element(doc, @growth_checkout_button) =~ "Currently on this plan"
refute element_exists?(doc, "#{@growth_checkout_button} + p")
assert class_of_element(doc, @business_checkout_button) =~ "pointer-events-none bg-gray-400"
assert text_of_element(doc, "#{@business_checkout_button} + p") =~
"Please update your billing details first"
doc = set_slider(lv, "1M")
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert class_of_element(doc, @growth_checkout_button) =~ "pointer-events-none bg-gray-400"
assert text_of_element(doc, "#{@growth_checkout_button} + p") =~
"Please update your billing details first"
end
end
describe "for a user with a cancelled subscription" do
setup [:create_user, :log_in, :create_cancelled_subscription]
test "checkout buttons are paddle buttons", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
assert text_of_attr(find(doc, @growth_checkout_button), "onclick") =~ "Paddle.Checkout.open"
assert text_of_attr(find(doc, @business_checkout_button), "onclick") =~
"Paddle.Checkout.open"
end
test "currently owned tier is highlighted if stats are still unlocked", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
assert text_of_element(doc, @growth_highlight_pill) == "Current"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end
test "can subscribe again to the currently owned (but cancelled) plan", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
refute class_of_element(doc, @growth_checkout_button) =~ "pointer-events-none"
end
test "highlights recommended tier if subscription expired and no days are paid for anymore",
%{conn: conn, user: user} do
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
user.subscription
|> Subscription.changeset(%{next_bill_date: Timex.shift(Timex.now(), months: -2)})
|> Repo.update()
{:ok, _lv, doc} = get_liveview(conn)
assert text_of_element(doc, @growth_highlight_pill) == "Recommended"
refute text_of_element(doc, @business_highlight_pill) == "Recommended"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end
end
describe "for a grandfathered user" do
setup [:create_user, :log_in]
setup %{user: user} = context do
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
create_subscription_for(user, paddle_plan_id: @v1_10k_yearly_plan_id)
{:ok, context}
end
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
test "on a v1 plan, Growth tiers are available at 20M, 50M, 50M+, but Business tiers are not",
%{conn: conn} do
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
{:ok, lv, _doc} = get_liveview(conn)
doc = set_slider(lv, 8)
assert text_of_element(doc, @slider_value) == "20M"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
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) == "50M"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @business_plan_box) =~ "Contact us"
assert text_of_element(doc, @growth_price_tag_amount) == "€1,000"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @growth_price_tag_interval) == "/year"
doc = set_slider(lv, 10)
assert text_of_element(doc, @slider_value) == "50M+"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
assert text_of_element(doc, @business_plan_box) =~ "Contact us"
assert text_of_element(doc, @growth_plan_box) =~ "Contact us"
doc = set_slider(lv, 7)
assert text_of_element(doc, @slider_value) == "10M"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
refute text_of_element(doc, @business_plan_box) =~ "Contact us"
refute 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)
assert growth_box =~ "Your subscription has been grandfathered"
refute growth_box =~ "Intuitive, fast and privacy-friendly dashboard"
end
test "displays business and enterprise plan benefits", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
business_box = text_of_element(doc, @business_plan_box)
enterprise_box = text_of_element(doc, @enterprise_plan_box)
assert business_box =~ "Everything in Growth"
assert business_box =~ "Funnels"
assert business_box =~ "Ecommerce revenue attribution"
assert business_box =~ "Priority support"
refute business_box =~ "Goals and custom events"
refute business_box =~ "Unlimited team members"
refute business_box =~ "Up to 50 sites"
refute business_box =~ "Stats API (600 requests per hour)"
refute business_box =~ "Custom Properties"
assert enterprise_box =~ "Everything in Business"
assert enterprise_box =~ "50+ sites"
assert enterprise_box =~ "600+ Stats API requests per hour"
assert enterprise_box =~ "Sites API access for"
assert enterprise_box =~ "Technical onboarding"
assert text_of_attr(find(doc, "#{@enterprise_plan_box} p a"), "href") =~
"https://plausible.io/white-label-web-analytics"
refute enterprise_box =~ "10+ team members"
refute enterprise_box =~ "Unlimited team members"
end
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end
describe "for a free_10k subscription" do
setup [:create_user, :log_in, :subscribe_free_10k]
test "recommends growth tier when no premium features used", %{conn: conn} do
{:ok, _lv, doc} = get_liveview(conn)
assert element_exists?(doc, @growth_highlight_pill)
refute element_exists?(doc, @business_highlight_pill)
end
test "recommends Business tier when premium features used", %{conn: conn, user: user} do
site = insert(:site, members: [user])
insert(:goal, currency: :USD, site: site, event_name: "Purchase")
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
{:ok, _lv, doc} = get_liveview(conn)
assert text_of_element(doc, @business_plan_box) =~ "Recommended"
refute text_of_element(doc, @growth_plan_box) =~ "Recommended"
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end
test "renders Paddle upgrade buttons", %{conn: conn, user: user} do
{:ok, lv, _doc} = get_liveview(conn)
set_slider(lv, "200k")
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
doc = element(lv, @yearly_interval_button) |> render_click()
assert %{
"disableLogout" => true,
"email" => user.email,
"passthrough" => user.id,
"product" => @v4_growth_200k_yearly_plan_id,
"success" => Routes.billing_path(PlausibleWeb.Endpoint, :upgrade_success),
"theme" => "none"
} == get_paddle_checkout_params(find(doc, @growth_checkout_button))
end
end
defp subscribe_v4_growth(%{user: user}) do
create_subscription_for(user, paddle_plan_id: @v4_growth_200k_yearly_plan_id)
end
defp subscribe_v4_business(%{user: user}) do
create_subscription_for(user, paddle_plan_id: @v4_business_5m_monthly_plan_id)
end
defp create_past_due_subscription(%{user: user}) do
create_subscription_for(user,
paddle_plan_id: @v4_growth_200k_yearly_plan_id,
Refactor enterprise plan upgrade and change-plan actions (#3397) * rename enterprise?/1 function * change link text to Upgrade when subscription deleted * extract paddle_button and paddle_script components * create a new upgrade-to-enterprise-plan page * extract upgrade_link component * rename function * link to enterprise plan upgrade page from settings ...if the user has an enterprise plan configured * fetch enterprise plan price on the new page * add change_enterprise_plan functionality on the new page * render existing change_enterprise_plan_contact_us.html ...when subscribed to latest configured enterprise plan * rename vars and extract resumable? fn * remove dead billing route * small test refactor: extract convenience fn * add tests for... ...restricting paused and past_due subscription access to the new enterprise plan page. 1. redirect to /settings from the controller action 2. hiding the change-plan link from the user settings * implement redirect to /settings * hide the enterprise upgrade/change-plan link * add tests for a deleted enterprise subscription * plug in the new controller action and delete dead code * optimize for dark mode * fix compile warning * credo fix * display N/A instead of crash when price nil * change subscription.status type to Ecto.Enum Also, create a new `Subscription.Status` module that exposes macros to return the used atom values (prevent typos at compiletime). * fix bug (@conn not available anymore) * use Routes.billing_path where applicable * add a status() type * silence credo * refactor suggestion from review Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Remove the __using__ macro from Subscription.Status ... instead be explicit about requires and aliases and also order the use, import, require, and alias clauses according to https://github.com/christopheradams/elixir_style_guide#module-attribute-ordering * drop the virtual Enteprise 'price_per_interval' field * apply review suggestion to make the code more DRY * use dot syntax to fetch current user in new controller actions * fix formatting --------- Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2023-10-10 20:35:17 +03:00
status: Subscription.Status.past_due(),
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
update_url: "https://update.billing.details"
)
end
defp create_paused_subscription(%{user: user}) do
create_subscription_for(user,
paddle_plan_id: @v4_growth_200k_yearly_plan_id,
Refactor enterprise plan upgrade and change-plan actions (#3397) * rename enterprise?/1 function * change link text to Upgrade when subscription deleted * extract paddle_button and paddle_script components * create a new upgrade-to-enterprise-plan page * extract upgrade_link component * rename function * link to enterprise plan upgrade page from settings ...if the user has an enterprise plan configured * fetch enterprise plan price on the new page * add change_enterprise_plan functionality on the new page * render existing change_enterprise_plan_contact_us.html ...when subscribed to latest configured enterprise plan * rename vars and extract resumable? fn * remove dead billing route * small test refactor: extract convenience fn * add tests for... ...restricting paused and past_due subscription access to the new enterprise plan page. 1. redirect to /settings from the controller action 2. hiding the change-plan link from the user settings * implement redirect to /settings * hide the enterprise upgrade/change-plan link * add tests for a deleted enterprise subscription * plug in the new controller action and delete dead code * optimize for dark mode * fix compile warning * credo fix * display N/A instead of crash when price nil * change subscription.status type to Ecto.Enum Also, create a new `Subscription.Status` module that exposes macros to return the used atom values (prevent typos at compiletime). * fix bug (@conn not available anymore) * use Routes.billing_path where applicable * add a status() type * silence credo * refactor suggestion from review Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Remove the __using__ macro from Subscription.Status ... instead be explicit about requires and aliases and also order the use, import, require, and alias clauses according to https://github.com/christopheradams/elixir_style_guide#module-attribute-ordering * drop the virtual Enteprise 'price_per_interval' field * apply review suggestion to make the code more DRY * use dot syntax to fetch current user in new controller actions * fix formatting --------- Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2023-10-10 20:35:17 +03:00
status: Subscription.Status.paused(),
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
update_url: "https://update.billing.details"
)
end
defp create_cancelled_subscription(%{user: user}) do
create_subscription_for(user,
paddle_plan_id: @v4_growth_200k_yearly_plan_id,
Refactor enterprise plan upgrade and change-plan actions (#3397) * rename enterprise?/1 function * change link text to Upgrade when subscription deleted * extract paddle_button and paddle_script components * create a new upgrade-to-enterprise-plan page * extract upgrade_link component * rename function * link to enterprise plan upgrade page from settings ...if the user has an enterprise plan configured * fetch enterprise plan price on the new page * add change_enterprise_plan functionality on the new page * render existing change_enterprise_plan_contact_us.html ...when subscribed to latest configured enterprise plan * rename vars and extract resumable? fn * remove dead billing route * small test refactor: extract convenience fn * add tests for... ...restricting paused and past_due subscription access to the new enterprise plan page. 1. redirect to /settings from the controller action 2. hiding the change-plan link from the user settings * implement redirect to /settings * hide the enterprise upgrade/change-plan link * add tests for a deleted enterprise subscription * plug in the new controller action and delete dead code * optimize for dark mode * fix compile warning * credo fix * display N/A instead of crash when price nil * change subscription.status type to Ecto.Enum Also, create a new `Subscription.Status` module that exposes macros to return the used atom values (prevent typos at compiletime). * fix bug (@conn not available anymore) * use Routes.billing_path where applicable * add a status() type * silence credo * refactor suggestion from review Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Remove the __using__ macro from Subscription.Status ... instead be explicit about requires and aliases and also order the use, import, require, and alias clauses according to https://github.com/christopheradams/elixir_style_guide#module-attribute-ordering * drop the virtual Enteprise 'price_per_interval' field * apply review suggestion to make the code more DRY * use dot syntax to fetch current user in new controller actions * fix formatting --------- Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2023-10-10 20:35:17 +03:00
status: Subscription.Status.deleted()
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
)
end
defp create_subscription_for(user, subscription_options) do
insert(:subscription, Keyword.put(subscription_options, :user, user))
{:ok, user: Plausible.Users.with_subscription(user)}
end
defp subscribe_free_10k(%{user: user}) do
Plausible.Billing.Subscription.free(%{user_id: user.id})
|> Repo.insert!()
{:ok, user: user}
end
defp get_liveview(conn) do
conn = assign(conn, :live_module, PlausibleWeb.Live.ChoosePlan)
Refactor enterprise plan upgrade and change-plan actions (#3397) * rename enterprise?/1 function * change link text to Upgrade when subscription deleted * extract paddle_button and paddle_script components * create a new upgrade-to-enterprise-plan page * extract upgrade_link component * rename function * link to enterprise plan upgrade page from settings ...if the user has an enterprise plan configured * fetch enterprise plan price on the new page * add change_enterprise_plan functionality on the new page * render existing change_enterprise_plan_contact_us.html ...when subscribed to latest configured enterprise plan * rename vars and extract resumable? fn * remove dead billing route * small test refactor: extract convenience fn * add tests for... ...restricting paused and past_due subscription access to the new enterprise plan page. 1. redirect to /settings from the controller action 2. hiding the change-plan link from the user settings * implement redirect to /settings * hide the enterprise upgrade/change-plan link * add tests for a deleted enterprise subscription * plug in the new controller action and delete dead code * optimize for dark mode * fix compile warning * credo fix * display N/A instead of crash when price nil * change subscription.status type to Ecto.Enum Also, create a new `Subscription.Status` module that exposes macros to return the used atom values (prevent typos at compiletime). * fix bug (@conn not available anymore) * use Routes.billing_path where applicable * add a status() type * silence credo * refactor suggestion from review Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Remove the __using__ macro from Subscription.Status ... instead be explicit about requires and aliases and also order the use, import, require, and alias clauses according to https://github.com/christopheradams/elixir_style_guide#module-attribute-ordering * drop the virtual Enteprise 'price_per_interval' field * apply review suggestion to make the code more DRY * use dot syntax to fetch current user in new controller actions * fix formatting --------- Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2023-10-10 20:35:17 +03:00
{:ok, _lv, _doc} = live(conn, Routes.billing_path(conn, :choose_plan))
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end
defp get_paddle_checkout_params(element) do
with onclick <- text_of_attr(element, "onclick"),
[[_, checkout_params_str]] <- Regex.scan(~r/Paddle\.Checkout\.open\((.*?)\)/, onclick),
{:ok, checkout_params} <- Jason.decode(checkout_params_str) do
checkout_params
end
end
defp set_slider(lv, volume) when is_binary(volume) do
index = Enum.find_index(@slider_volumes, &(&1 == volume))
set_slider(lv, index)
end
defp set_slider(lv, index) do
lv
|> element(@slider_input)
|> render_change(%{slider: index})
end
Use Phoenix LiveView for the upgrade page (#3382) * add a new upgrade page liveview behind a FF * Create plans_v4.json file * Add the upgrade page UI template and some basic functionalities * different content based on subscription plan existing or not * pageview slider * monthly/yearly switch * fix tests * split into 2 separate functions * rename variables * implement volume slider + read default interval/volume from plan * organize choose-plan.ex better * remove unused vars from tests * make monthly_cost and yearly_cost nil by default The actual prices for all plans are stored in Paddle. We don't need to keep the duplicates in the JSON files. * add fetch_prices/1 to PaddleApi * make v4 business ID's differ from growth ones * render actual price information from plans ...and make the prices in both growth and business plan boxes change dynamically when the pageview slider or interval is changed. * highlight current subscription plan box * add test describe block for business tier subscription * connect to live socket only on the specific LV page using focus.html * only wrap the input slider inside the form * little readability improvement * add v4 team_member_limits (after rebase with master) * extract monthly_quota_box function in user_settings When the business_tier FF is enabled, this section is different and links to the new upgrade page. * document subscription statuses * change _notice.html.eex to .heex * extract subscription status notice components * add failed payment notices to upgrade page * create class_of_element/2 convenience function for testing * add cancel_subscription mix task * implement checkout buttons * mix format * get all available plans with prices through plans.ex * use more suitable function for fetching usage * avoid double db lookups on mount * rename variable * separate functions for getting plan by product_id vs subscription * separate subscription status docs into context module * consider cancelled subscriptions * default volume by usage if no subscription plan * add enterprise-level volume option to slider * optimize for darkmode * UI improvements * display 2 months free notice for yearly billing * VAT excluded notice * note about having a business subscription in user settings * make the page pop and fit plans on screen on first render * optimize for mobile and remove background containers * change default price tag to simply 'N/A' * fix tests * Change Paddle.js integration to use JavaScript directly * rename many variables * allow users on v1 and v2 plan subscribe to 20M and 50M tiers * add a test for two months free label * make it work with a free_10k subscription * small test improvement and formatting * change other upgrade link in user settings if FF enabled * dialyzer * fix typo * add test for free_10k user * silence credo * mix format * credo - add moduledoc * credo - another moduledoc * handle calls to sentry on the api level * refactor getting regular subscription plan for LiveView * post review code style tweaks * remove unused aliases * credo - add @moduledoc false to Subscriptions * crash in cancel_subscription task when Repo update fails * readability improvements (review suggestions) * add comment about 'external_resource' module attr --------- Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-10-03 13:36:22 +03:00
end