The personal finance app for everyone (by everyone)
Ruby
Hide the bills month pulse and AI prompts on an empty page (#3905)
Guillem Arias Fauste70c47b38ae27
diff --git a/app/views/bills/index.html.erb b/app/views/bills/index.html.erbindex fd2efc8f68..a6314f4921 100644--- a/app/views/bills/index.html.erb+++ b/app/views/bills/index.html.erb@@ -16,9 +16,16 @@</div><% end %>- <%= render "bills/month_pulse" %>+ <% bill_rows_empty = [ @overdue, @month_rows, @later, @dormant ].all?(&:empty?) %>- <%= render "bills/ai_prompts", prompts: %w[due_before_paycheck subscriptions_up monthly_subscriptions] %>+ <%# With no bill rows the pulse is a card of dashes and zeros, and the+ prompts would start a chat about bills that don't exist. Suggestions+ don't count: they aren't bills yet, and the pulse can't total them. %>+ <% unless bill_rows_empty %>+ <%= render "bills/month_pulse" %>++ <%= render "bills/ai_prompts", prompts: %w[due_before_paycheck subscriptions_up monthly_subscriptions] %>+ <% end %><%# Changes worth knowing about, ranked by whether you can still do anything.Everything stays on the page: the quieter half collapses rather than@@ -113,7 +120,7 @@<%= render "recurring_transactions/suggested_series", suggested: @suggested_series %><% end %>- <% if [ @overdue, @month_rows, @later, @dormant ].all?(&:empty?) %>+ <% if bill_rows_empty %><% if @suggested_series.none? %><div class="bg-container rounded-xl shadow-border-xs p-4"><%= render DS::EmptyState.new(diff --git a/test/controllers/bills_controller_test.rb b/test/controllers/bills_controller_test.rbindex d6ad9543f3..6f7dca78be 100644--- a/test/controllers/bills_controller_test.rb+++ b/test/controllers/bills_controller_test.rb@@ -1173,11 +1173,28 @@ class BillsControllerTest < ActionDispatch::IntegrationTestassert_response :not_foundend- test "index renders an empty state with no bills" do- get bills_url+ test "a page without bill rows shows the empty state, not the month pulse or the AI prompts" do+ Provider::Registry.stubs(:preferred_llm_provider).returns(Object.new)+ get bills_urlassert_response :successassert_match I18n.t("bills.index.empty.title"), response.body+ # AI is available, so the prompts are missing for want of bills.+ assert_match I18n.t("bills.index.review_with_ai"), response.body+ assert_no_match I18n.t("bills.month_pulse.left_to_pay"), response.body+ assert_no_match "due before my next paycheck", response.body+ assert_no_match I18n.t("bills.ai_prompts.subscriptions_up"), response.body+ assert_no_match I18n.t("bills.ai_prompts.monthly_subscriptions"), response.body++ # A suggestion isn't a bill yet, so it doesn't bring them back.+ create_suggested(name: "Riverside Climbing Gym", account: accounts(:depository))+ get bills_url+ assert_response :success+ assert_match "Riverside Climbing Gym", response.body+ assert_no_match I18n.t("bills.month_pulse.left_to_pay"), response.body+ assert_no_match "due before my next paycheck", response.body+ assert_no_match I18n.t("bills.ai_prompts.subscriptions_up"), response.body+ assert_no_match I18n.t("bills.ai_prompts.monthly_subscriptions"), response.bodyend# A cancellation date does not stop the schedule, so the same bill can read@@ -1517,6 +1534,8 @@ class BillsControllerTest < ActionDispatch::IntegrationTestendtest "AI chips and the review button need both consent and a provider" do+ # The chips only render over bill rows.+ create_bill(name: "Power Co", amount: 80)Provider::Registry.stubs(:preferred_llm_provider).returns(Object.new)get bills_urlassert_response :success