Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Show a bill row's verb only when the bill needs you now (#3947)

Guillem Arias Fauste3832d6c42c7c
diff --git a/app/helpers/bills_helper.rb b/app/helpers/bills_helper.rb
index 0930018169..4f131a6b19 100644
--- a/app/helpers/bills_helper.rb
+++ b/app/helpers/bills_helper.rb
@@ -323,6 +323,39 @@ module BillsHelper
t("bills.attention.overdue", count: (Date.current - occurrence.effective_due_on).to_i)
end
+ # The icons for the verbs below. Pay renders as the portal link instead
+ # (recurring_transactions/_pay_link).
+ VERB_ICONS = { review_match: "git-compare", add_payment: "plus",
+ manage_payments: "receipt-text", find_payment: "search" }.freeze
+
+ # The row's one verb, or nil when the bill needs nothing from you now: it is
+ # settled, paused, not yet in its window, or on autopay and on schedule. The
+ # drawer is one tap away for everything else.
+ def bills_row_verb(occurrence, suggestion: nil)
+ series = occurrence.recurring_transaction
+ return nil unless series.active? && occurrence.scheduled?
+ return :review_match if suggestion.present?
+
+ state = occurrence.derived_state
+ return nil unless state.in?(%i[due overdue])
+ return :add_payment if occurrence.partially_paid?
+ # Overdue means the charge autopay promised never showed up, so from there
+ # it is chased like any other bill.
+ return nil if series.autopay? && state == :due
+
+ RecurringTransaction.valid_payment_url?(series.payment_url) ? :pay : :find_payment
+ end
+
+ # The drawer's verb. It always offers one, because the drawer is the only way
+ # to unlink a payment, reopen a cycle or record one by hand. Pay has its own
+ # button there.
+ def bills_drawer_verb(occurrence, suggestion: nil)
+ return :review_match if suggestion.present?
+ return :add_payment if occurrence.partially_paid?
+
+ occurrence.scheduled? ? :find_payment : :manage_payments
+ end
+
# The match score's own components, said in words.
#
# Deterministic: every phrase here corresponds to a key the matcher actually
diff --git a/app/views/bills/_occurrence.html.erb b/app/views/bills/_occurrence.html.erb
index 96b5705833..f6c16221bc 100644
--- a/app/views/bills/_occurrence.html.erb
+++ b/app/views/bills/_occurrence.html.erb
@@ -123,7 +123,12 @@
</div>
<% end %>
- <div class="shrink-0 flex items-center gap-2">
+ <%# The verb's slot. From @lg every row reserves it, verb or not, so the
+ amounts share one right edge. It fits the widest English verb, Review
+ match (about 130px). min-w rather than w, so a longer locale widens the
+ slot instead of overflowing it. Below @lg there is no verb: tapping the
+ row opens the drawer, which spells it out. %>
+ <div class="hidden @lg:flex shrink-0 min-w-36 justify-end">
<%= render "bills/row_action", occurrence: occurrence, suggestion: suggestion %>
</div>
</div>
diff --git a/app/views/bills/_row_action.html.erb b/app/views/bills/_row_action.html.erb
index a28fa4d0a4..763c3433b4 100644
--- a/app/views/bills/_row_action.html.erb
+++ b/app/views/bills/_row_action.html.erb
@@ -1,79 +1,27 @@
-<%# locals: (occurrence:, suggestion: nil, labelled: false) %>
-<% series = occurrence.recurring_transaction %>
+<%# locals: (occurrence:, suggestion: nil, drawer: false) %>
-<%# The row's one verb, chosen by what the bill actually needs.
+<%# The bill's one verb, picked by BillsHelper#bills_row_verb.
Every row used to carry the same "Details" button plus a pay action plus a
category badge, which at 375px added up to more than the row was wide: the
bill's own name collapsed to nothing and the page scrolled sideways. A row
- that needs nothing from you now shows nothing.
+ now offers a verb only when the bill needs you now, and only where it has
+ room for the words (the row's slot is hidden below @lg). On a phone the
+ subline already says why the row matters, and tapping it opens the drawer.
- Below md the verb is an icon, which DS::Buttonish already gives a 44px
- touch target via pointer-coarse. The labelled version lives in the bill's
- drawer, which is one tap away and has room for words.
+ `drawer: true` is what the drawer passes. There the verb comes from
+ bills_drawer_verb, is always present, and renders at full size. %>
+<% verb = drawer ? bills_drawer_verb(occurrence, suggestion: suggestion) : bills_row_verb(occurrence, suggestion: suggestion) %>
- `labelled: true` is what the drawer passes to get the full-width,
- spelled-out version of the same decision. %>
-
-<%
- action =
- if suggestion.present?
- { key: "review_match", icon: "git-compare" }
- elsif occurrence.partially_paid?
- { key: "add_payment", icon: "plus" }
- elsif !occurrence.scheduled?
- # Settled, skipped or missed. Nothing to chase, but unlinking a payment
- # and reopening a cycle live behind this door and nowhere else.
- { key: "manage_payments", icon: "receipt-text" }
- elsif series.autopay?
- nil
- elsif occurrence.derived_state.in?(%i[overdue due])
- # A due bill with a payment portal wants paying, not reconciling.
- RecurringTransaction.valid_payment_url?(series.payment_url) ? nil : { key: "find_payment", icon: "search" }
- end
-
- # A row that needs nothing stays silent; the drawer never does, or
- # unlinking, reopening and manual payment would be stranded.
- action ||= { key: "find_payment", icon: "search" } if labelled && occurrence.scheduled?
-%>
-
-<% if action.nil? %>
- <%# Nothing to resolve here, so the only thing worth offering is the portal
- when there is one. show_add stays false: a dashed "Add link" on every
- row is exactly the chrome this pass exists to remove. %>
- <%= render "recurring_transactions/pay_action",
- recurring_transaction: series, show_add: false, show_state: false %>
-<% elsif labelled %>
+<% if verb == :pay %>
+ <%= render "recurring_transactions/pay_link", recurring_transaction: occurrence.recurring_transaction %>
+<% elsif verb %>
<%= render DS::Link.new(
- text: t("bills.#{action[:key]}"),
- icon: action[:icon],
- variant: "primary",
+ text: t("bills.#{verb}"),
+ icon: BillsHelper::VERB_ICONS[verb],
+ variant: drawer ? "primary" : "outline",
+ size: drawer ? "md" : "sm",
href: recurring_occurrence_path(occurrence),
frame: :drawer
) %>
-<% else %>
- <%# Container-relative, not viewport-relative: the row's own list is the
- @container, because the app shell's sidebars mean a 1280px viewport can
- still leave this row about 420px to work with. A labelled verb needs
- roughly 500px of row before it stops eating the bill's name. %>
- <span class="hidden @lg:inline-flex">
- <%= render DS::Link.new(
- text: t("bills.#{action[:key]}"),
- icon: action[:icon],
- variant: "outline",
- size: "sm",
- href: recurring_occurrence_path(occurrence),
- frame: :drawer
- ) %>
- </span>
- <span class="@lg:hidden">
- <%= render DS::Link.new(
- icon: action[:icon],
- variant: "icon",
- href: recurring_occurrence_path(occurrence),
- frame: :drawer,
- title: t("bills.#{action[:key]}"),
- aria: { label: t("bills.#{action[:key]}") }
- ) %>
- </span>
<% end %>
diff --git a/app/views/bills/_summary.html.erb b/app/views/bills/_summary.html.erb
index fff19ece90..002fdbb1e2 100644
--- a/app/views/bills/_summary.html.erb
+++ b/app/views/bills/_summary.html.erb
@@ -79,13 +79,13 @@
</p>
<% end %>
- <%# The next step, spelled out. The row shows this as an icon on a phone;
- here there is room for the words. It is present on a settled occurrence
- too, because the drawer is the only route in the app to unlinking a
+ <%# The next step, spelled out. The row shows it only when the bill needs you
+ now, and never on a phone. Here it is always present, settled occurrences
+ included, because the drawer is the only route in the app to unlinking a
payment or reopening a cycle. %>
<div class="flex flex-wrap items-center gap-2 pt-1">
<% if current_occurrence %>
- <%= render "bills/row_action", occurrence: current_occurrence, suggestion: suggestion, labelled: true %>
+ <%= render "bills/row_action", occurrence: current_occurrence, suggestion: suggestion, drawer: true %>
<% end %>
<%# Pay and Add link keep a home here, so the portal never leaves Bills
diff --git a/app/views/recurring_transactions/_pay_action.html.erb b/app/views/recurring_transactions/_pay_action.html.erb
index 88ca9b2946..9e51fc0219 100644
--- a/app/views/recurring_transactions/_pay_action.html.erb
+++ b/app/views/recurring_transactions/_pay_action.html.erb
@@ -1,4 +1,4 @@
-<%# locals: (recurring_transaction:, show_add: true, show_state: true) %>
+<%# locals: (recurring_transaction:, show_add: true) %>
<%#
The row's primary action, which depends on state rather than being the same
@@ -17,24 +17,8 @@
<% if recurring_transaction.autopay? %>
<%# Autopay is information, not a task, so it never renders as a call to action. The
portal stays reachable when a link exists -- you still want to check a charge --
- but demoted to a quiet control rather than something demanding to be clicked.
-
- show_state: false is passed by surfaces that already say "Autopay" on the
- bill's own line. Repeating it in the action slot spends the row's one verb
- position on a state, so there it shrinks to the portal link alone. %>
- <% if has_link && !show_state %>
- <%# Deliberately NOT labelled "Pay": autopay means the charge is already
- handled, so the only thing left to offer is the door to the provider --
- for checking a charge, not for making one. The label says so. %>
- <%= render DS::Link.new(
- icon: "external-link",
- variant: "icon",
- href: recurring_transaction.payment_url,
- target: "_blank",
- title: t(".open_site"),
- aria: { label: t(".autopay_aria", name: recurring_transaction.display_name) }
- ) %>
- <% elsif has_link %>
+ but demoted to a quiet control rather than something demanding to be clicked. %>
+ <% if has_link %>
<%= render DS::Link.new(
text: t(".autopay"),
href: recurring_transaction.payment_url,
@@ -44,23 +28,14 @@
target: "_blank",
aria: { label: t(".autopay_aria", name: recurring_transaction.display_name) }
) %>
- <% elsif show_state %>
+ <% else %>
<span class="inline-flex items-center gap-1 px-2 py-1 text-sm text-secondary">
<%= icon "refresh-cw", size: "sm", color: "current" %>
<%= t(".autopay") %>
</span>
<% end %>
<% elsif has_link %>
- <%= render DS::Link.new(
- text: t(".pay"),
- href: recurring_transaction.payment_url,
- icon: "external-link",
- icon_position: :right,
- variant: "accent",
- size: "sm",
- target: "_blank",
- aria: { label: t(".pay_aria", name: recurring_transaction.display_name) }
- ) %>
+ <%= render "recurring_transactions/pay_link", recurring_transaction: recurring_transaction %>
<% elsif show_add %>
<%# Dashed outline reads as "nothing here yet", the same cue the split editor uses
for its add-another-split control. Suppressed on read-only forecasts, which
diff --git a/app/views/recurring_transactions/_pay_link.html.erb b/app/views/recurring_transactions/_pay_link.html.erb
new file mode 100644
index 0000000000..aadc329077
--- /dev/null
+++ b/app/views/recurring_transactions/_pay_link.html.erb
@@ -0,0 +1,14 @@
+<%# locals: (recurring_transaction:) %>
+
+<%# The portal as a call to action. Shared by the pay action and a bill row's
+ verb, which offers it for an autopay bill too once the bill is overdue. %>
+<%= render DS::Link.new(
+ text: t("recurring_transactions.pay_action.pay"),
+ href: recurring_transaction.payment_url,
+ icon: "external-link",
+ icon_position: :right,
+ variant: "accent",
+ size: "sm",
+ target: "_blank",
+ aria: { label: t("recurring_transactions.pay_action.pay_aria", name: recurring_transaction.display_name) }
+ ) %>
diff --git a/config/locales/views/recurring_transactions/ca.yml b/config/locales/views/recurring_transactions/ca.yml
index d6bc7d6e37..55d5c7359c 100644
--- a/config/locales/views/recurring_transactions/ca.yml
+++ b/config/locales/views/recurring_transactions/ca.yml
@@ -97,7 +97,6 @@ ca:
add_link_aria: Afegeix un enllaç de pagament per a %{name}
autopay: Domiciliat
autopay_aria: '%{name} es paga automàticament; obre el seu portal en una pestanya nova'
- open_site: Obre el web de la factura
new:
title: Afegeix una factura
income_title: Afegeix un ingrés
diff --git a/config/locales/views/recurring_transactions/en.yml b/config/locales/views/recurring_transactions/en.yml
index ab3adcddf7..0835674a50 100644
--- a/config/locales/views/recurring_transactions/en.yml
+++ b/config/locales/views/recurring_transactions/en.yml
@@ -51,7 +51,6 @@ en:
add_link_aria: "Add a payment link for %{name}"
autopay: Autopay
autopay_aria: "%{name} pays automatically, open its portal in a new tab"
- open_site: Open bill site
new:
title: Add a bill
income_title: Add income
diff --git a/config/locales/views/recurring_transactions/fr.yml b/config/locales/views/recurring_transactions/fr.yml
index 7328ff37bb..268e091ed1 100644
--- a/config/locales/views/recurring_transactions/fr.yml
+++ b/config/locales/views/recurring_transactions/fr.yml
@@ -155,7 +155,6 @@ fr:
add_link_aria: Ajouter un lien de paiement pour %{name}
autopay: Paiement automatique
autopay_aria: "%{name} est payée automatiquement, ouvrir son portail dans un nouvel onglet"
- open_site: Ouvrir le site de la facture
pay: Payer
pay_aria: Payer %{name} (ouvre un nouvel onglet)
pick_entry:
diff --git a/config/locales/views/recurring_transactions/pl.yml b/config/locales/views/recurring_transactions/pl.yml
index 0bb9f90e7f..c65ee0c60a 100644
--- a/config/locales/views/recurring_transactions/pl.yml
+++ b/config/locales/views/recurring_transactions/pl.yml
@@ -163,7 +163,6 @@ pl:
add_link_aria: Dodaj link do płatności dla %{name}
autopay: Autopłatność
autopay_aria: "%{name} płatne automatycznie, otwórz portal w nowej karcie"
- open_site: Otwórz stronę rachunku
pay: Zapłać
pay_aria: Zapłać %{name} (otwiera się w nowej karcie)
pick_entry:
diff --git a/config/locales/views/recurring_transactions/ru.yml b/config/locales/views/recurring_transactions/ru.yml
index 28597d7f88..7dbe483497 100644
--- a/config/locales/views/recurring_transactions/ru.yml
+++ b/config/locales/views/recurring_transactions/ru.yml
@@ -97,7 +97,6 @@ ru:
add_link_aria: Добавить ссылку на оплату для %{name}
autopay: Автоплатёж
autopay_aria: '%{name} оплачивается автоматически; открыть его сайт в новой вкладке'
- open_site: Открыть сайт для оплаты
new:
title: Добавить платёж
income_title: Добавить доход
diff --git a/config/locales/views/recurring_transactions/tr.yml b/config/locales/views/recurring_transactions/tr.yml
index 2f6cc7dce4..ed6d834be6 100644
--- a/config/locales/views/recurring_transactions/tr.yml
+++ b/config/locales/views/recurring_transactions/tr.yml
@@ -96,7 +96,6 @@ tr:
add_link_aria: '%{name} için bir ödeme bağlantısı ekle'
autopay: Otomatik ödeme
autopay_aria: '%{name} otomatik olarak ödeniyor, portalını yeni sekmede açın'
- open_site: Fatura sitesini aç
new:
title: Fatura ekle
income_title: Gelir ekle
diff --git a/config/locales/views/recurring_transactions/uk.yml b/config/locales/views/recurring_transactions/uk.yml
index b29ef4f9e0..4f71710c16 100644
--- a/config/locales/views/recurring_transactions/uk.yml
+++ b/config/locales/views/recurring_transactions/uk.yml
@@ -90,7 +90,6 @@ uk:
add_link_aria: Додати посилання для оплати %{name}
autopay: Автоплатіж
autopay_aria: '%{name} оплачується автоматично; відкрити його портал у новій вкладці'
- open_site: Відкрити сайт для оплати
new:
title: Додати платіж
income_title: Додати дохід
diff --git a/test/controllers/bills_controller_test.rb b/test/controllers/bills_controller_test.rb
index e196125f61..691036a9cc 100644
--- a/test/controllers/bills_controller_test.rb
+++ b/test/controllers/bills_controller_test.rb
@@ -1332,15 +1332,18 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
end
test "autopay reads on the bill's line rather than in the action slot" do
- create_bill(name: "Netflix", amount: 15.99, autopay: true,
- payment_url: "https://example.com/pay")
+ bill = create_bill(name: "Netflix", amount: 15.99, autopay: true,
+ payment_url: "https://example.com/pay")
get bills_url
assert_includes response.body, I18n.t("recurring_transactions.pay_action.autopay")
refute_includes response.body, "refresh-cw",
"autopay is a state; the row's one action position belongs to a verb"
- assert_includes response.body, "https://example.com/pay",
- "the portal stays reachable, just not as the row's headline action"
+ refute_includes response.body, "https://example.com/pay",
+ "an autopay bill on schedule needs nothing from you, so its row offers no portal"
+
+ get_bill_drawer(bill)
+ assert_includes response.body, "https://example.com/pay", "the portal stays one tap away"
end
# Opacity on the whole row took the secondary text to about 2.7:1 in light
diff --git a/test/helpers/bills_helper_test.rb b/test/helpers/bills_helper_test.rb
index dae5f9e975..d0f69e0941 100644
--- a/test/helpers/bills_helper_test.rb
+++ b/test/helpers/bills_helper_test.rb
@@ -312,6 +312,109 @@ class BillsHelperTest < ActionView::TestCase
assert_empty paycheck_plan_sections(nil)
end
+ # --- The row's one verb: present only when the bill needs you now. ---
+
+ test "a paused bill's leftover row offers no verb, even overdue" do
+ leftover = build_occurrence(due_on: Date.current - 10, status: "scheduled", series: { status: "inactive" })
+ assert_equal :overdue, leftover.derived_state, "precondition: past its grace"
+
+ assert_nil bills_row_verb(leftover)
+ assert_nil bills_row_verb(leftover, suggestion: RecurringAllocation.new)
+ end
+
+ test "a settled row offers no verb, even with a pending match" do
+ %w[paid skipped missed].each do |status|
+ assert_nil bills_row_verb(build_occurrence(due_on: Date.current - 10, status: status)),
+ "a #{status} row has nothing left to chase"
+ end
+ # Needs review still asks about the match; the row doesn't.
+ assert_nil bills_row_verb(build_occurrence(due_on: Date.current - 10, status: "paid"),
+ suggestion: RecurringAllocation.new)
+ end
+
+ test "a pending match is reviewed whatever the date" do
+ upcoming = build_occurrence(due_on: Date.current + 20, status: "scheduled")
+ assert_equal :upcoming, upcoming.derived_state, "precondition: outside its window"
+
+ assert_equal :review_match, bills_row_verb(upcoming, suggestion: RecurringAllocation.new)
+ end
+
+ test "a partial row inside its window offers Add payment" do
+ [ Date.current, Date.current - 10 ].each do |due_on|
+ assert_equal :add_payment, bills_row_verb(build_partial(due_on: due_on)), "due #{due_on}"
+ end
+ end
+
+ test "a partial row outside its window offers no verb" do
+ assert_nil bills_row_verb(build_partial(due_on: Date.current + 20))
+ end
+
+ test "an autopay bill on schedule offers no verb, portal or not" do
+ [ Date.current, Date.current + 20 ].each do |due_on|
+ [ nil, "https://pay.example.com" ].each do |payment_url|
+ occurrence = build_occurrence(due_on: due_on, status: "scheduled",
+ series: { autopay: true, payment_url: payment_url })
+ assert_nil bills_row_verb(occurrence), "due #{due_on}, portal #{payment_url.inspect}"
+ end
+ end
+ end
+
+ test "a pending match or a partial payment outranks autopay" do
+ autopay = { autopay: true, payment_url: "https://pay.example.com" }
+
+ assert_equal :review_match, bills_row_verb(build_occurrence(due_on: Date.current, status: "scheduled", series: autopay),
+ suggestion: RecurringAllocation.new)
+ assert_equal :add_payment, bills_row_verb(build_partial(due_on: Date.current, series: autopay))
+ end
+
+ # Overdue means the charge autopay promised never showed up.
+ test "an autopay bill past its grace is chased like any other" do
+ with_portal = build_occurrence(due_on: Date.current - 10, status: "scheduled",
+ series: { autopay: true, payment_url: "https://pay.example.com" })
+ without = build_occurrence(due_on: Date.current - 10, status: "scheduled", series: { autopay: true })
+
+ assert_equal :pay, bills_row_verb(with_portal)
+ assert_equal :find_payment, bills_row_verb(without)
+ end
+
+ test "a bill inside its window offers Pay with a portal and Find payment without one" do
+ [ Date.current, Date.current - 10 ].each do |due_on|
+ with_portal = build_occurrence(due_on: due_on, status: "scheduled",
+ series: { payment_url: "https://pay.example.com" })
+ without = build_occurrence(due_on: due_on, status: "scheduled")
+
+ assert_equal :pay, bills_row_verb(with_portal), "due #{due_on}"
+ assert_equal :find_payment, bills_row_verb(without), "due #{due_on}"
+ end
+ end
+
+ test "an upcoming bill offers no verb, Pay included" do
+ with_portal = build_occurrence(due_on: Date.current + 20, status: "scheduled",
+ series: { payment_url: "https://pay.example.com" })
+ without = build_occurrence(due_on: Date.current + 20, status: "scheduled")
+
+ assert_nil bills_row_verb(with_portal)
+ assert_nil bills_row_verb(without)
+ end
+
+ # The drawer is the only way into unlinking a payment, reopening a cycle or
+ # paying by hand, so it always offers a verb. Pay has its own button there.
+ test "the drawer always offers a verb" do
+ upcoming = build_occurrence(due_on: Date.current + 20, status: "scheduled")
+ autopay = build_occurrence(due_on: Date.current, status: "scheduled",
+ series: { autopay: true, payment_url: "https://pay.example.com" })
+ portal = build_occurrence(due_on: Date.current, status: "scheduled",
+ series: { payment_url: "https://pay.example.com" })
+ leftover = build_occurrence(due_on: Date.current - 10, status: "scheduled", series: { status: "inactive" })
+
+ assert_equal :manage_payments, bills_drawer_verb(build_occurrence(due_on: Date.current - 10, status: "paid"))
+ assert_equal :review_match, bills_drawer_verb(upcoming, suggestion: RecurringAllocation.new)
+ assert_equal :add_payment, bills_drawer_verb(build_partial(due_on: Date.current + 20))
+ { "upcoming" => upcoming, "autopay" => autopay, "portal" => portal, "paused" => leftover }.each do |label, occurrence|
+ assert_equal :find_payment, bills_drawer_verb(occurrence), label
+ end
+ end
+
private
def stub_occurrence(name, amount, id:, due_on: Date.current)
@@ -323,22 +426,30 @@ class BillsHelperTest < ActionView::TestCase
)
end
- def build_occurrence(due_on:, status:)
+ def build_occurrence(due_on:, status:, series: {})
family = users(:family_admin).family
- series = family.recurring_transactions.create!(
+ bill = family.recurring_transactions.create!({
name: "Twitch #{status} #{due_on}", account: accounts(:depository),
amount: 11.99, currency: "USD", expected_day_of_month: due_on.day,
status: "active", bill_type: "subscription", manual: true,
- dedup_scope: "twitch-#{status}-#{due_on}",
+ dedup_scope: "twitch-#{status}-#{due_on}-#{SecureRandom.hex(4)}",
last_occurrence_date: due_on, next_expected_date: due_on
- )
- series.recurring_occurrences.destroy_all
- series.recurring_occurrences.create!(
+ }.merge(series))
+ bill.recurring_occurrences.destroy_all
+ bill.recurring_occurrences.create!(
family: family, original_due_on: due_on, due_on: due_on,
currency: "USD", expected_amount: 11.99, status: status,
closed_at: (status == "scheduled" ? nil : Time.current)
)
end
+
+ def build_partial(due_on:, series: {})
+ occurrence = build_occurrence(due_on: due_on, status: "scheduled", series: series)
+ occurrence.allocations.create!(allocated_amount: 5, currency: "USD", source: "user_created")
+ assert occurrence.partially_paid?, "precondition: partly paid"
+ occurrence
+ end
+
def build_period(income:, due:, reserved:, sources: [ "Payroll" ], leading: false, cash_on_hand: nil, items: [])
obligations = BigDecimal(due.to_s) + BigDecimal(reserved.to_s)
diff --git a/test/system/bill_drawer_test.rb b/test/system/bill_drawer_test.rb
index d1ebc1e60c..75c5b01efe 100644
--- a/test/system/bill_drawer_test.rb
+++ b/test/system/bill_drawer_test.rb
@@ -70,6 +70,9 @@ class BillDrawerTest < ApplicationSystemTestCase
# The payment drawer's "View full bill" leaves the same way.
test "going back from the bill's page shows the list, not a leftover payment drawer" do
+ # Rows carry their verb only from @lg, and at 1400 both sidebars leave the
+ # list just short of it.
+ page.current_window.resize_to(1440, 1400)
visit bills_url
find(@find_payment_link).click
diff --git a/test/system/bills_mobile_test.rb b/test/system/bills_mobile_test.rb
index d670fb5a4d..804e704d8b 100644
--- a/test/system/bills_mobile_test.rb
+++ b/test/system/bills_mobile_test.rb
@@ -170,6 +170,27 @@ class BillsMobileTest < ApplicationSystemTestCase
assert_no_horizontal_scroll("the payment drawer")
end
+ # A row's verb needs @lg of list to sit beside the bill's name. Below it the
+ # subline says why the row matters, and the drawer spells the verb out.
+ test "a phone row carries no verb, and tapping it opens the drawer with one" do
+ [ [ "CITY WATER", nil ], [ "COMCAST", "https://pay.example.com" ] ].each do |name, payment_url|
+ @family.recurring_transactions.create!(
+ name: name, account: accounts(:depository), amount: 80, currency: "USD",
+ expected_day_of_month: Date.current.day, anchor_date: Date.current,
+ last_occurrence_date: Date.current, next_expected_date: Date.current,
+ status: "active", manual: true, payment_url: payment_url
+ )
+ end
+
+ visit bills_url
+ assert_text "COMCAST"
+ assert_no_link I18n.t("bills.find_payment")
+ assert_no_selector "a[href='https://pay.example.com']"
+
+ find("a[data-turbo-frame='drawer']", text: "CITY WATER", match: :first).click
+ within("dialog[open]") { assert_link I18n.t("bills.find_payment") }
+ end
+
private
# The document must never be wider than the viewport, and neither must the
# scroll container inside it. An open drawer sits outside #main, in a scroll
diff --git a/test/system/declare_and_pay_bill_test.rb b/test/system/declare_and_pay_bill_test.rb
index 254ff25caf..0becbd77a3 100644
--- a/test/system/declare_and_pay_bill_test.rb
+++ b/test/system/declare_and_pay_bill_test.rb
@@ -73,9 +73,12 @@ class DeclareAndPayBillTest < ApplicationSystemTestCase
# partly paid rather than settled: $537.50 against $2,150 is not rent.
assert_text I18n.t("bills.attention.partial", amount: "$1,612.50")
- # Journey C picks up exactly where that leaves off: the row's verb has
- # become Add payment, and the rest is settled from the drawer.
- click_on I18n.t("bills.add_payment"), match: :first
+ # Journey C picks up exactly where that leaves off. The bill is still ten
+ # days out, so its row stays quiet; the drawer's verb has become Add
+ # payment, and the rest is settled from there.
+ find("a[data-turbo-frame='drawer']", text: "Watson Property", match: :first).click
+ within("dialog[open]") { click_on I18n.t("bills.add_payment") }
+ within("dialog[open]") { assert_link I18n.t("recurring_occurrences.show.mark_paid") }
assert_text I18n.t("recurring_occurrences.show.remaining", amount: "$1,612.50")
click_on I18n.t("recurring_occurrences.show.mark_paid")