diff --git a/lib/plausible_web/components/billing/billing.ex b/lib/plausible_web/components/billing/billing.ex index d3126bd2d..299064d2f 100644 --- a/lib/plausible_web/components/billing/billing.ex +++ b/lib/plausible_web/components/billing/billing.ex @@ -16,12 +16,12 @@ defmodule PlausibleWeb.Components.Billing do def render_monthly_pageview_usage(assigns) do ~H""" -
+

Monthly pageviews usage

    <.billing_cycle_tab - name="Ongoing cycle" + name="Upcoming cycle" tab={:current_cycle} date_range={@usage.current_cycle.date_range} with_separator={true} @@ -30,7 +30,6 @@ defmodule PlausibleWeb.Components.Billing do name="Last cycle" tab={:last_cycle} date_range={@usage.last_cycle.date_range} - disabled={@usage.last_cycle.total == 0 && @usage.penultimate_cycle.total == 0} with_separator={true} /> <.billing_cycle_tab diff --git a/test/plausible_web/controllers/auth_controller_test.exs b/test/plausible_web/controllers/auth_controller_test.exs index 32383f44f..73b5138d3 100644 --- a/test/plausible_web/controllers/auth_controller_test.exs +++ b/test/plausible_web/controllers/auth_controller_test.exs @@ -938,9 +938,6 @@ defmodule PlausibleWeb.AuthControllerTest do doc = get(conn, "/settings") |> html_response(200) - assert text_of_attr(find(doc, "#monthly_pageview_usage_container"), "x-data") == - "{ tab: 'current_cycle' }" - assert class_of_element(doc, "#billing_cycle_tab_penultimate_cycle button") =~ "pointer-events-none" @@ -948,72 +945,20 @@ defmodule PlausibleWeb.AuthControllerTest do end @tag :ee_only - test "penultimate and last cycles are both disabled if there's no usage", %{ + test "last cycle tab is selected by default", %{ conn: conn, user: user } do - site = insert(:site, members: [user]) - - populate_stats(site, [ - build(:event, name: "pageview", timestamp: Timex.shift(Timex.now(), days: -5)) - ]) - - last_bill_date = Timex.shift(Timex.today(), days: -10) - insert(:subscription, paddle_plan_id: @v4_plan_id, user: user, - last_bill_date: last_bill_date + last_bill_date: Timex.shift(Timex.today(), days: -1) ) doc = get(conn, "/settings") |> html_response(200) assert text_of_attr(find(doc, "#monthly_pageview_usage_container"), "x-data") == - "{ tab: 'current_cycle' }" - - assert class_of_element(doc, "#billing_cycle_tab_last_cycle button") =~ - "pointer-events-none" - - assert text_of_element(doc, "#billing_cycle_tab_last_cycle") =~ "Not available" - - assert class_of_element(doc, "#billing_cycle_tab_penultimate_cycle button") =~ - "pointer-events-none" - - assert text_of_element(doc, "#billing_cycle_tab_penultimate_cycle") =~ "Not available" - end - - @tag :ee_only - test "when last cycle usage is 0, it's still not disabled if penultimate cycle has usage", %{ - conn: conn, - user: user - } do - site = insert(:site, members: [user]) - - populate_stats(site, [ - build(:event, name: "pageview", timestamp: Timex.shift(Timex.now(), days: -5)), - build(:event, name: "pageview", timestamp: Timex.shift(Timex.now(), days: -50)) - ]) - - last_bill_date = Timex.shift(Timex.today(), days: -10) - - insert(:subscription, - paddle_plan_id: @v4_plan_id, - user: user, - last_bill_date: last_bill_date - ) - - doc = get(conn, "/settings") |> html_response(200) - - assert text_of_attr(find(doc, "#monthly_pageview_usage_container"), "x-data") == - "{ tab: 'current_cycle' }" - - refute class_of_element(doc, "#billing_cycle_tab_last_cycle") =~ "pointer-events-none" - refute text_of_element(doc, "#billing_cycle_tab_last_cycle") =~ "Not available" - - refute class_of_element(doc, "#billing_cycle_tab_penultimate_cycle") =~ - "pointer-events-none" - - refute text_of_element(doc, "#billing_cycle_tab_penultimate_cycle") =~ "Not available" + "{ tab: 'last_cycle' }" end @tag :ee_only