Hide the bills month pulse and AI prompts on an empty page

Merged
GA
2mo ago
+31-5

Problem

With no bills, the Bills overview still rendered the month pulse as a card of nothing ("–", "left to pay", "$0.00 paid", "0 bills") and the three AI prompt chips ("What's due before my next paycheck?" and the rest) above the empty state. On a phone that put "No bills yet" about 500px down the page, and the chips started a chat about bills that don't exist.

Change

  • The month pulse and the AI prompt chips render only when the page has a bill row: overdue, this month (paid rows included), after this month, or dormant. These are the four lists whose absence already shows the empty state, so the view now computes that once and uses it for both checks.
  • Detected suggestions alone don't bring them back. A suggestion isn't a bill yet, and the pulse can't total it, so a page with only "Possible new bills" shows the strip without the pulse or chips.
  • A page with any bill row renders as before.

Screenshots

Empty page with transaction history, before and after (1440 and 375, light and dark):

Before: a pulse card of dashes and zeros and three AI prompt chips sit above No bills yet After: the header, the view switcher and the No bills yet empty state

Empty page with no transaction history, before and after:

Before: the same pulse and chips above the no-history empty state After: only the header, the view switcher and the no-history empty state

Validation

  • New controller test: an empty page shows the empty state with no pulse and no chips, while AI is available (the header's "Review with AI" is there, so the chips are missing for want of bills), and a page with only a suggestion still shows neither. It replaces "index renders an empty state with no bills", whose assertion is its first step. With the new condition removed from the view, it fails.
  • "AI chips and the review button need both consent and a provider" now seeds a bill, since the chips need a bill row.
  • bin/rails test: 10429 runs, 1 error, ReportsControllerTest#test_a_disposal_carried_in_a_third_currency…, which fails on main today as well (see Notes).
  • DISABLE_PARALLELIZATION=true bin/rails test:system: 180 runs, 1 error, DeclareAndPayBillTest. It only fails locally, where it types a US-format date into a day-first Chrome date field; #3885's first commit fixes it.
  • RuboCop, erb_lint and Brakeman are clean. No JavaScript changed.

Notes

  • ci / test_unit is red on main and every PR on the 1st and 2nd of the month: the "third currency" test in reports_controller_test.rb creates an EUR→GBP rate that exchange_rates.yml already has. #3902 fixes it; it's unrelated to this change.

Summary by CodeRabbit

  • Bug Fixes
    • The bills page now displays the month pulse and AI prompts only when bill rows are present. The empty state remains consistent when no bill rows exist, including when a suggested bill is present.
    • The empty state can still show the AI review button when a provider is available. With bill rows present, AI suggestions and the review button appear only when consent and provider settings are enabled.