Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Open bills in the drawer instead of expanding the row (#3885)

Guillem Arias Fausteec4282e0eba8
diff --git a/app/components/DS/dialog_controller.js b/app/components/DS/dialog_controller.js
index f668693a27..918e707a5b 100644
--- a/app/components/DS/dialog_controller.js
+++ b/app/components/DS/dialog_controller.js
@@ -9,6 +9,10 @@ const FOCUSABLE_SELECTOR = [
"[tabindex]:not([tabindex='-1'])",
].join(", ");
+// Where focus goes back to, left by a dialog replaced while still open for the
+// one that takes its place in the same frame.
+const returnFocusByFrame = new WeakMap();
+
// Connects to data-controller="dialog"
export default class extends Controller {
static targets = ["content"]
@@ -21,6 +25,7 @@ export default class extends Controller {
connect() {
this._priorFocus = null;
+ this._frame = this.element.closest("turbo-frame");
this._onKeydown = this.#onKeydown.bind(this);
this._onClose = this.#onClose.bind(this);
@@ -29,7 +34,7 @@ export default class extends Controller {
if (this.element.open) return;
if (this.autoOpenValue) {
- this._priorFocus = document.activeElement;
+ this._priorFocus = this.#returnFocusTarget();
this.element.showModal();
this.#focusInitial();
}
@@ -38,6 +43,16 @@ export default class extends Controller {
disconnect() {
this.element.removeEventListener("keydown", this._onKeydown);
this.element.removeEventListener("close", this._onClose);
+
+ // Replaced while still open: one drawer linking to the next inside the
+ // same frame. The link that did it left with this dialog, so focus would
+ // fall to <body> on close. The dialog connecting in its place, in this
+ // same mutation batch, inherits the way back instead.
+ if (this._priorFocus && this._frame) {
+ const frame = this._frame;
+ returnFocusByFrame.set(frame, this._priorFocus);
+ queueMicrotask(() => returnFocusByFrame.delete(frame));
+ }
}
// If the user clicks anywhere outside of the visible content, close the dialog
@@ -57,6 +72,14 @@ export default class extends Controller {
}
}
+ // Whatever had focus as this opened, unless that went with the dialog this
+ // one replaced.
+ #returnFocusTarget() {
+ const active = document.activeElement;
+ if (active && active !== document.body) return active;
+ return returnFocusByFrame.get(this._frame) ?? active;
+ }
+
// Move focus to the first focusable child unless the dialog already
// declared one via the autofocus attribute. Native `<dialog>.showModal()`
// is supposed to do this but the behavior varies across engines.
diff --git a/app/controllers/bills_controller.rb b/app/controllers/bills_controller.rb
index b04df218c8..3fa97f8566 100644
--- a/app/controllers/bills_controller.rb
+++ b/app/controllers/bills_controller.rb
@@ -143,7 +143,7 @@ class BillsController < ApplicationController
.includes(:merchant)
.find(params[:id])
- # A row expansion names the cycle it was opened from; the bill's own page
+ # The drawer names the cycle its row was opened from; the bill's own page
# has no cycle in mind and asks the series. Looked up through the series, so
# an id from another bill resolves to nothing rather than to someone else's
# occurrence.
@@ -179,25 +179,15 @@ class BillsController < ApplicationController
}
end
- if params[:display] == "pane"
- # The expansion renders into whichever row frame asked for it; the id
- # is reflected back sanitized. close returns the empty frame, which
- # collapses the row.
- @pane_frame_id = params[:frame].to_s.gsub(/[^a-zA-Z0-9_-]/, "").presence || "bill_detail"
- if params[:close].present?
- render :pane_close, layout: false
- return
- end
- end
-
load_summary_extras
- if params[:display] == "pane"
- # A pending suggestion is the one thing that changes what the expansion
+ # Outside a frame (a new tab, a pasted link) there is nothing to open the
+ # dialog into, so the same URL is the bill's page.
+ if params[:display] == "drawer" && turbo_frame_request?
+ # A pending suggestion is the one thing that changes what the drawer
# should offer, so it is worth the one query.
- @pane_suggestion = @current_occurrence && RecurringAllocation.suggested
- .where(recurring_occurrence_id: @current_occurrence.id).first
- render :pane, layout: false
+ @drawer_suggestion = @current_occurrence&.allocations&.suggested&.first
+ render :drawer, layout: false
return
end
@@ -243,7 +233,7 @@ class BillsController < ApplicationController
end
helper_method :paycheck_income_plans?
- # What the expansion needs: the handful of payments that actually settled
+ # What the drawer needs: the handful of payments that actually settled
# this bill lately. Cheap enough to run on every row someone opens.
def load_summary_extras
@recent_allocations = confirmed_allocations.includes(:entry).order(paid_on: :desc, created_at: :desc).limit(6)
@@ -251,7 +241,7 @@ class BillsController < ApplicationController
# The bill's financial story: a year of payments by month, per-year totals,
# and where the money last came from. Three grouped aggregates, which is
- # why they no longer run every time a row is expanded.
+ # why they no longer run every time a row is opened.
def load_deep_extras
confirmed = confirmed_allocations
diff --git a/app/controllers/recurring_transactions_controller.rb b/app/controllers/recurring_transactions_controller.rb
index fb218a93fd..acf21d47f0 100644
--- a/app/controllers/recurring_transactions_controller.rb
+++ b/app/controllers/recurring_transactions_controller.rb
@@ -221,7 +221,7 @@ class RecurringTransactionsController < ApplicationController
respond_to do |format|
format.html do
flash[:notice] = message
- redirect_to recurring_transactions_path
+ redirect_back_or_to recurring_transactions_path
end
end
end
diff --git a/app/helpers/bills_helper.rb b/app/helpers/bills_helper.rb
index 82bcd5ccdf..675a04ccce 100644
--- a/app/helpers/bills_helper.rb
+++ b/app/helpers/bills_helper.rb
@@ -222,7 +222,7 @@ module BillsHelper
# Which account the charge lands on. Worth showing only when it tells the rows
# apart: on a single-account family it repeated the same name down every line,
# which is nineteen copies of a fact carrying no information. The bill's
- # expansion names the account regardless, so nothing is lost when it is quiet
+ # drawer names the account regardless, so nothing is lost when it is quiet
# here.
def bills_paid_from_label(bill)
return "" if bill.account.blank?
diff --git a/app/views/bills/_month_pulse.html.erb b/app/views/bills/_month_pulse.html.erb
index 0b7b5b87ad..fe3d9d35fc 100644
--- a/app/views/bills/_month_pulse.html.erb
+++ b/app/views/bills/_month_pulse.html.erb
@@ -71,9 +71,8 @@
<% end %>
<%# What happens next, which is what makes this header operational rather
- than statistical. Items open the bill's page: the row expansion belongs
- to a row, and expanding one further down the page while you are reading
- the top of it would be a jump with no explanation. %>
+ than statistical. Items open the same drawer their row does, over the
+ page, so reading the top of it never jumps you down to the row. %>
<% if @next_up.any? %>
<div class="pt-3 border-t border-subdued space-y-2">
<div class="flex items-center justify-between gap-3">
@@ -88,7 +87,8 @@
<% @next_up.each do |occurrence| %>
<% series = occurrence.recurring_transaction %>
<%# Inset ring: on phones the scroll strip clips an outline drawn outside the item. %>
- <%= link_to bill_path(series),
+ <%= link_to bill_path(series, display: "drawer", occurrence: occurrence.id),
+ data: { turbo_frame: "drawer", turbo_prefetch: false },
class: "shrink-0 w-36 sm:w-auto rounded-lg px-2 py-1.5 hover:bg-surface-hover focus-ring -outline-offset-2" do %>
<p class="text-xs text-secondary truncate">
<%= bills_next_up_date(occurrence) %>
diff --git a/app/views/bills/_occurrence.html.erb b/app/views/bills/_occurrence.html.erb
index 5b2524d736..9a6561bfef 100644
--- a/app/views/bills/_occurrence.html.erb
+++ b/app/views/bills/_occurrence.html.erb
@@ -2,30 +2,22 @@
<% series = occurrence.recurring_transaction %>
<% expected = occurrence.resolved_expected_amount_money %>
<% paid = occurrence.confirmed_allocated_money %>
-<% pane_frame = dom_id(occurrence, :pane) %>
<%# SCAN. What is this, and does it need me?
- Everything past that question lives one tap deeper, in the expansion.
+ Everything past that question lives one tap deeper, in the drawer.
An autopaying bill is still worth seeing and still counts toward the total,
but it recedes so the rows that want something from you carry the weight. %>
-<div>
<%# The row reads as interactive without dressing up as a button: a hover tint
- and the name underlining, the same cues the transaction list uses.
-
- The tint hangs off this element rather than a group on the wrapper. The
- wrapper also holds the expansion, so a group hover kept the row lit while
- the pointer was down in the expanded pane, and the lit band clipped against
- the pane's own fill. Hover still propagates from every child of the row, so
- the trailing action tints it exactly as before. %>
+ and the name underlining, the same cues the transaction list uses. %>
<div class="flex items-center gap-3 lg:gap-4 p-3 lg:p-4 transition-colors hover:bg-surface-hover <%= "opacity-70" if series.autopay? %>">
<%# The bulk of the row is the inspect control. Only the trailing verb sits
outside it, so there are no anchors inside anchors. %>
- <%# Names the cycle it was opened from. Without it the expansion falls back to
- the series' current occurrence, so expanding a settled row described the
+ <%# Names the cycle it was opened from. Without it the drawer falls back to
+ the series' current occurrence, so opening a settled row described the
NEXT one and reported it unpaid. %>
- <%= link_to bill_path(series, display: "pane", frame: pane_frame, occurrence: occurrence.id),
- data: { turbo_frame: pane_frame, turbo_prefetch: false },
+ <%= link_to bill_path(series, display: "drawer", occurrence: occurrence.id),
+ data: { turbo_frame: "drawer", turbo_prefetch: false },
class: "flex items-center gap-3 lg:gap-4 min-w-0 flex-1 group" do %>
<%# A date rail, and only a date. It used to print "Overdue" beside a
subline already reading "14 days overdue", which spent the row's one
@@ -131,8 +123,3 @@
<%= render "bills/row_action", occurrence: occurrence, suggestion: suggestion %>
</div>
</div>
-
-<%# The row's expansion: empty until the row is clicked, then the bill's
- current state slides in under the line item. %>
-<%= turbo_frame_tag pane_frame %>
-</div>
diff --git a/app/views/bills/_row_action.html.erb b/app/views/bills/_row_action.html.erb
index b434e00be1..a28fa4d0a4 100644
--- a/app/views/bills/_row_action.html.erb
+++ b/app/views/bills/_row_action.html.erb
@@ -9,10 +9,10 @@
that needs nothing from you now shows nothing.
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 row
- expansion, which is one tap away and has room for words.
+ touch target via pointer-coarse. The labelled version lives in the bill's
+ drawer, which is one tap away and has room for words.
- `labelled: true` is what the expansion passes to get the full-width,
+ `labelled: true` is what the drawer passes to get the full-width,
spelled-out version of the same decision. %>
<%
@@ -32,7 +32,7 @@
RecurringTransaction.valid_payment_url?(series.payment_url) ? nil : { key: "find_payment", icon: "search" }
end
- # A row that needs nothing stays silent; the expansion never does, or
+ # 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?
%>
diff --git a/app/views/bills/_summary.html.erb b/app/views/bills/_summary.html.erb
index d7ed94c1c7..fff19ece90 100644
--- a/app/views/bills/_summary.html.erb
+++ b/app/views/bills/_summary.html.erb
@@ -54,7 +54,7 @@
<% if recent_allocations.any? %>
<div class="space-y-1">
<p class="text-xs font-medium text-secondary uppercase"><%= t("bills.detail.recent_payments") %></p>
- <div class="bg-container rounded-lg divide-y divide-subdued">
+ <div class="bg-container-inset rounded-lg divide-y divide-subdued">
<% recent_allocations.first(3).each do |allocation| %>
<div class="flex items-center justify-between gap-3 px-3 py-2">
<div class="min-w-0">
@@ -101,7 +101,8 @@
) %>
<%# Edit, pause and remove stayed two clicks from the Overview rather
- than moving to the page and becoming four. %>
+ than moving to the page and becoming four. Pause and remove answer
+ with the whole page, so they leave the drawer's frame. %>
<%= render DS::Menu.new do |menu| %>
<% menu.with_item(
variant: "link",
@@ -122,7 +123,8 @@
text: series.active? ? t("recurring_transactions.actions.pause") : t("recurring_transactions.actions.resume"),
icon: series.active? ? "pause" : "play",
href: toggle_status_recurring_transaction_path(series),
- method: :post) %>
+ method: :post,
+ frame: "_top") %>
<% menu.with_item(
variant: "button",
text: t("recurring_transactions.actions.delete"),
@@ -130,6 +132,7 @@
href: recurring_transaction_path(series),
method: :delete,
destructive: true,
+ frame: "_top",
confirm: t(series.typed_income? ? "recurring_transactions.confirm_delete_income" : "recurring_transactions.confirm_delete", name: series.display_name)) %>
<% end %>
</div>
diff --git a/app/views/bills/drawer.html.erb b/app/views/bills/drawer.html.erb
new file mode 100644
index 0000000000..0dcabdfd12
--- /dev/null
+++ b/app/views/bills/drawer.html.erb
@@ -0,0 +1,26 @@
+<%# Opened from a row, over the list, the way a transaction or a budget
+ category opens. The list stays where it was, so closing this lands back
+ on the same row.
+
+ Temporary, so Turbo leaves it out of the cached page: "View full bill"
+ navigates away with the drawer still open, and Back would otherwise bring
+ it back as a stray non-modal dialog. %>
+<%= render DS::Dialog.new(variant: :drawer, data: { turbo_temporary: true }) do |dialog| %>
+ <% dialog.with_header(title: @series.display_name) do %>
+ <% if @series.category %>
+ <%= render "categories/badge", category: @series.category %>
+ <% end %>
+ <% end %>
+
+ <% dialog.with_body do %>
+ <%# What is going on with this bill, and what to do about it. Everything
+ deeper -- the chart, the per-year totals, the price history, the
+ upcoming dates, the settled cycles -- lives on the bill's page. %>
+ <%= render "bills/summary",
+ series: @series,
+ current_occurrence: @current_occurrence,
+ analytics: @analytics,
+ recent_allocations: @recent_allocations,
+ suggestion: @drawer_suggestion %>
+ <% end %>
+<% end %>
diff --git a/app/views/bills/pane.html.erb b/app/views/bills/pane.html.erb
deleted file mode 100644
index 725b3b307d..0000000000
--- a/app/views/bills/pane.html.erb
+++ /dev/null
@@ -1,30 +0,0 @@
-<%= turbo_frame_tag @pane_frame_id do %>
- <div class="bg-container-inset rounded-lg mx-3 mb-3 overflow-hidden">
- <div class="p-4 space-y-4">
- <div class="flex items-start justify-between gap-3">
- <div class="min-w-0 space-y-1.5">
- <% if @series.category %>
- <%= render "categories/badge", category: @series.category %>
- <% end %>
- <h3 class="text-lg font-medium text-primary truncate"><%= @series.display_name %></h3>
- </div>
- <%= link_to bill_path(@series, display: "pane", frame: @pane_frame_id, close: 1),
- data: { turbo_frame: @pane_frame_id },
- class: "text-secondary hover:text-primary shrink-0",
- "aria-label": t(".close") do %>
- <%= icon "x", size: "sm" %>
- <% end %>
- </div>
-
- <%# What is going on with this bill, and what to do about it. Everything
- deeper -- the chart, the per-year totals, the price history, the
- upcoming dates, the settled cycles -- lives on the bill's page. %>
- <%= render "bills/summary",
- series: @series,
- current_occurrence: @current_occurrence,
- analytics: @analytics,
- recent_allocations: @recent_allocations,
- suggestion: @pane_suggestion %>
- </div>
- </div>
-<% end %>
diff --git a/app/views/bills/pane_close.html.erb b/app/views/bills/pane_close.html.erb
deleted file mode 100644
index 506ebff01b..0000000000
--- a/app/views/bills/pane_close.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= turbo_frame_tag @pane_frame_id %>
diff --git a/app/views/bills/show.html.erb b/app/views/bills/show.html.erb
index ef2885f8e5..920a88defd 100644
--- a/app/views/bills/show.html.erb
+++ b/app/views/bills/show.html.erb
@@ -5,7 +5,7 @@
This used to be a drawer dialog floating over an empty settings layout,
which meant the app had three renderings of a bill's detail and no page.
It is a page now, so the chart, the history and the configuration have
- somewhere to live that is not the row expansion. %>
+ somewhere to live that is not the drawer. %>
<div class="space-y-4 pb-6 lg:pb-12">
<header class="flex items-start justify-between gap-3">
diff --git a/app/views/recurring_occurrences/show.html.erb b/app/views/recurring_occurrences/show.html.erb
index 67409556e0..5e160461cd 100644
--- a/app/views/recurring_occurrences/show.html.erb
+++ b/app/views/recurring_occurrences/show.html.erb
@@ -13,9 +13,15 @@
app -- a centred card on a phone, a right-hand drawer from lg up. The close
button is ours rather than dialog.close_button, because that one carries
`hidden lg:flex` under `responsive`, which leaves a phone with no visible
- way out. %>
+ way out.
-<%= render DS::Dialog.new(frame: "drawer", responsive: true) do |dialog| %>
+ Temporary in the drawer, so Turbo leaves it out of the cached page: "View
+ full bill" navigates away with it open, and Back would otherwise restore
+ it as a stray non-modal dialog. Not on a direct visit, where the dialog is
+ the page and Back has to bring it back. nil there, not false: Turbo drops
+ any element carrying the attribute, "false" included. %>
+
+<%= render DS::Dialog.new(frame: "drawer", responsive: true, data: { turbo_temporary: (true if turbo_frame_request?) }) do |dialog| %>
<% dialog.with_header(custom_header: true) do %>
<div class="flex items-start justify-between gap-3">
<div class="min-w-0">
@@ -291,7 +297,8 @@
<% menu.with_item(variant: "button",
text: series.active? ? t("recurring_transactions.actions.pause") : t("recurring_transactions.actions.resume"),
icon: series.active? ? "pause" : "play",
- href: toggle_status_recurring_transaction_path(series), method: :post) %>
+ href: toggle_status_recurring_transaction_path(series), method: :post,
+ frame: "_top") %>
<% end %>
</div>
<% else %>
diff --git a/config/locales/views/bills/ca.yml b/config/locales/views/bills/ca.yml
index a63eb48c91..7f70b19a04 100644
--- a/config/locales/views/bills/ca.yml
+++ b/config/locales/views/bills/ca.yml
@@ -86,8 +86,6 @@ ca:
remaining: '%{amount} pendents'
paid_headline: '%{amount} pagats'
cost_line: Una mitjana de %{average} per pagament, uns %{annualized} l'any
- pane:
- close: Amaga els detalls
add_bill: Afegeix una factura
manage: Gestiona
find_payment: Cerca el pagament
diff --git a/config/locales/views/bills/en.yml b/config/locales/views/bills/en.yml
index e86861d699..faeca3b8d3 100644
--- a/config/locales/views/bills/en.yml
+++ b/config/locales/views/bills/en.yml
@@ -88,8 +88,6 @@ en:
remaining: "%{amount} remaining"
paid_headline: "%{amount} paid"
cost_line: "Averages %{average} a payment, about %{annualized} a year"
- pane:
- close: Collapse details
add_bill: Add bill
manage: Manage
find_payment: Find payment
diff --git a/config/locales/views/bills/fr.yml b/config/locales/views/bills/fr.yml
index d05d05da0b..ca9919402f 100644
--- a/config/locales/views/bills/fr.yml
+++ b/config/locales/views/bills/fr.yml
@@ -212,8 +212,6 @@ fr:
paid_label: Payé
paid_over: Payé %{paid}, plus que prévu
paid_over_short: Payé, dépassement
- pane:
- close: Réduire les détails
partial_progress: "%{paid} sur %{expected} payés"
pay_period:
before_next_paycheck: Avant votre prochaine paie
diff --git a/config/locales/views/bills/pl.yml b/config/locales/views/bills/pl.yml
index a1dd6f0060..700be4ecfe 100644
--- a/config/locales/views/bills/pl.yml
+++ b/config/locales/views/bills/pl.yml
@@ -258,8 +258,6 @@ pl:
paid_label: Opłacone
paid_over: Zapłacono %{paid}, więcej niż oczekiwano
paid_over_short: Opłacone, więcej
- pane:
- close: Zwiń szczegóły
partial_progress: Zapłacono %{paid} z %{expected}
pay_period:
before_next_paycheck: Przed następną wypłatą
diff --git a/config/locales/views/bills/ru.yml b/config/locales/views/bills/ru.yml
index 39e4c1a74c..1437e7fdf3 100644
--- a/config/locales/views/bills/ru.yml
+++ b/config/locales/views/bills/ru.yml
@@ -94,8 +94,6 @@ ru:
remaining: Осталось %{amount}
paid_headline: Оплачено %{amount}
cost_line: В среднем %{average} за платёж, около %{annualized} в год
- pane:
- close: Свернуть подробности
add_bill: Добавить платёж
manage: Управлять
find_payment: Найти оплату
diff --git a/config/locales/views/bills/tr.yml b/config/locales/views/bills/tr.yml
index 09f80831d9..2f6f947d42 100644
--- a/config/locales/views/bills/tr.yml
+++ b/config/locales/views/bills/tr.yml
@@ -86,8 +86,6 @@ tr:
remaining: '%{amount} kaldı'
paid_headline: '%{amount} ödendi'
cost_line: Ödeme başına ortalama %{average}, yılda yaklaşık %{annualized}
- pane:
- close: Ayrıntıları daralt
add_bill: Fatura ekle
manage: Yönet
find_payment: Ödeme bul
diff --git a/config/locales/views/bills/uk.yml b/config/locales/views/bills/uk.yml
index 5497ec1e0f..749abb64cb 100644
--- a/config/locales/views/bills/uk.yml
+++ b/config/locales/views/bills/uk.yml
@@ -94,8 +94,6 @@ uk:
remaining: Залишилося %{amount}
paid_headline: Сплачено %{amount}
cost_line: У середньому %{average} за оплату, приблизно %{annualized} на рік
- pane:
- close: Згорнути деталі
add_bill: Додати платіж
manage: Керувати
find_payment: Знайти оплату
diff --git a/test/controllers/bills_controller_test.rb b/test/controllers/bills_controller_test.rb
index 09f8741e3c..20030908ac 100644
--- a/test/controllers/bills_controller_test.rb
+++ b/test/controllers/bills_controller_test.rb
@@ -430,10 +430,10 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
assert_no_match I18n.t("bills.partial_progress", paid: "$750.00", expected: "$2,000.00"), response.body
end
- # The row expansion described the SERIES definition while the drawer described
- # the current occurrence, so an overdue bill greeted you with "Next payment"
- # in one surface and "Overdue" in the other, at the same moment.
- test "the row expansion and the drawer tell the same story about an overdue bill" do
+ # The row's detail once described the SERIES definition while the bill's
+ # detail described the current occurrence, so an overdue bill greeted you
+ # with "Next payment" in one surface and "Overdue" in the other.
+ test "the drawer and the bill's page tell the same story about an overdue bill" do
overdue_day = 6.days.ago.to_date
bill = create_bill(name: "Late Co", amount: 5.99,
expected_day_of_month: overdue_day.day,
@@ -446,13 +446,13 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
overdue_phrase = I18n.t("bills.due_label.overdue", count: days,
date: I18n.l(occurrence.effective_due_on, format: :short))
- get bill_url(bill), headers: { "Turbo-Frame" => "drawer" }
+ get bill_url(bill)
assert_response :success
- assert_match overdue_phrase, response.body, "the drawer states the status"
+ assert_match overdue_phrase, response.body, "the page states the status"
- get bill_url(bill, display: "pane", frame: "x"), headers: { "Turbo-Frame" => "x" }
+ get_bill_drawer(bill)
assert_response :success
- assert_match overdue_phrase, response.body, "and the expansion must state the same one"
+ assert_match overdue_phrase, response.body, "and the drawer must state the same one"
assert_no_match I18n.t("bills.detail.next_payment"), response.body,
"an overdue bill is not a next payment"
end
@@ -508,7 +508,7 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
assert occurrence.reload.paid?, "each charge is inside tolerance and should settle the cycle"
end
- get bill_url(bill), headers: { "Turbo-Frame" => "drawer" }
+ get_bill_drawer(bill)
assert_response :success
assert_match "$77.00", response.body
@@ -648,11 +648,11 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
assert_match I18n.t("recurring_transactions.new.income_title"), response.body
end
- # The expansion is opened from one row, so it has to describe that row's
+ # The drawer is opened from one row, so it has to describe that row's
# cycle. It used to ask the series for its current occurrence, which is the
- # earliest still-open one, so expanding a settled row reported the NEXT cycle
- # as unpaid directly underneath a row marked Paid.
- test "expanding a row describes that row's cycle, not the series' next one" do
+ # earliest still-open one, so opening a settled row reported the NEXT cycle
+ # as unpaid beside a row marked Paid.
+ test "opening a row describes that row's cycle, not the series' next one" do
bill = create_bill(name: "Streaming Plus", amount: 15.99)
settled = bill.recurring_occurrences.order(:due_on).first
entry = accounts(:depository).entries.create!(
@@ -666,7 +666,7 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
assert_not_nil later, "the series has a later, unpaid cycle to be confused with"
assert_not_equal settled.id, later.id
- get bill_url(bill, display: "pane", frame: "pane_x", occurrence: settled.id)
+ get_bill_drawer(bill, occurrence: settled.id)
assert_response :success
assert_match I18n.t("bills.summary.paid_headline", amount: "$15.99"), response.body
@@ -675,10 +675,10 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
end
# Without an occurrence the page has no cycle in mind, so the series answers.
- test "the bill page with no occurrence falls back to the series" do
+ test "a bill opened with no occurrence falls back to the series" do
bill = create_bill(name: "Streaming Plus", amount: 15.99)
- get bill_url(bill, display: "pane", frame: "pane_x")
+ get_bill_drawer(bill)
assert_response :success
assert_match I18n.t("bills.summary.remaining", amount: "$15.99"), response.body
@@ -691,7 +691,7 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
other = create_bill(name: "Gym", amount: 40)
stranger = other.recurring_occurrences.order(:due_on).first
- get bill_url(mine, display: "pane", frame: "pane_x", occurrence: stranger.id)
+ get_bill_drawer(mine, occurrence: stranger.id)
assert_response :success
assert_match I18n.t("bills.summary.remaining", amount: "$15.99"), response.body
@@ -878,30 +878,37 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
assert_no_match I18n.t("bills.paycheck.reserved_ahead"), response.body
end
- test "every overview row carries its own empty expansion frame" do
- create_bill(name: "Rent", amount: 2150)
+ test "an overview row opens its bill in the drawer, for that row's cycle" do
+ # Overdue, because Next up lists nothing past due: the row is the only
+ # link to this cycle.
+ overdue_day = 6.days.ago.to_date
+ bill = create_bill(name: "Late Co", amount: 5.99, expected_day_of_month: overdue_day.day,
+ last_occurrence_date: 2.months.ago.to_date, next_expected_date: overdue_day)
+ occurrence = bill.recurring_occurrences.detect(&:overdue?)
get bills_url
assert_response :success
- assert_match(/<turbo-frame[^>]*id="pane_recurring_occurrence_/, response.body)
- assert_match(/data-turbo-frame="pane_recurring_occurrence_/, response.body)
+ assert_select "a[data-turbo-frame=drawer][href=?]", bill_path(bill, display: "drawer", occurrence: occurrence.id), count: 1
end
- test "the expansion renders into the requesting row frame and can collapse" do
+ # Next up used to go to the bill's page, because opening the expansion of a
+ # row further down would have jumped the page. The drawer opens over the
+ # page, so Next up opens the same one the row does.
+ test "a Next up item opens the same drawer as its row" do
bill = create_bill(name: "Rent", amount: 2150)
+ occurrence = bill.recurring_occurrences.find_by!(due_on: Date.current)
- get bill_url(bill, display: "pane", frame: "pane_recurring_occurrence_abc123")
- assert_response :success
- assert_match(/<turbo-frame[^>]*id="pane_recurring_occurrence_abc123"/, response.body)
+ get bills_url
- get bill_url(bill, display: "pane", frame: "pane_recurring_occurrence_abc123", close: 1)
assert_response :success
- assert_match(/<turbo-frame[^>]*id="pane_recurring_occurrence_abc123"><\/turbo-frame>/, response.body)
- assert_no_match I18n.t("bills.detail.rules"), response.body
+ assert_select "a[data-turbo-frame=drawer][href=?]", bill_path(bill, display: "drawer", occurrence: occurrence.id),
+ { count: 2 }, "the row and its Next up item"
end
- test "the detail pane tells the bill's story inside its frame" do
+ # A bill opens over the list, the way a transaction or a budget category
+ # does, rather than expanding inline under its row.
+ test "a bill opens in the drawer and tells its story there" do
bill = create_bill(name: "Rent", amount: 2150)
occurrence = bill.recurring_occurrences.order(:due_on).first
entry = accounts(:depository).entries.create!(
@@ -910,20 +917,63 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
)
RecurringTransaction::Allocator.new(occurrence).allocate!(amount: "2150", entry: entry)
- get bill_url(bill, display: "pane")
+ get_bill_drawer(bill)
assert_response :success
- assert_match(/<turbo-frame[^>]*id="bill_detail"/, response.body, "no frame param falls back to a stable id")
+ assert_select "turbo-frame#drawer dialog h2", text: "Rent"
assert_match I18n.t("bills.detail.recent_payments"), response.body
assert_match "WATSON PROPERTY", response.body
- # The expansion answers "what is going on with this bill" and stops there.
+ # The drawer answers "what is going on with this bill" and stops there.
# The matching rules and the per-year table are configuration and
# reference material, and they belong to the bill's page.
assert_no_match I18n.t("bills.detail.rules"), response.body,
- "the expansion is not a second detail view"
+ "the drawer is not a second detail view"
assert_no_match I18n.t("bills.detail.key_metrics"), response.body
- assert_no_match(/<html/, response.body, "the pane renders frame-only, no layout")
+ assert_no_match(/<html/, response.body, "the drawer renders frame-only, no layout")
+ end
+
+ # A match waiting on a decision is the one thing that changes what the
+ # drawer asks of you: review it, rather than go looking for the payment.
+ test "a pending match makes the drawer's verb Review" do
+ bill = declare_bill(name: "CITY WATER", amount: 80, due: Date.current - 3)
+ charge = create_transaction_entry(name: "CITY WATER", amount: 85.50, date: Date.current - 3)
+ occurrence = bill.recurring_occurrences.order(:due_on).first
+ RecurringTransaction::Allocator.new(occurrence).allocate_matched!(
+ entry: charge, state: "suggested", confidence: 0.7, signals: { name: 0.35 }
+ )
+
+ get_bill_drawer(bill, occurrence: occurrence.id)
+
+ assert_response :success
+ assert_match I18n.t("bills.review_match"), response.body
+ assert_no_match I18n.t("bills.find_payment"), response.body
+ end
+
+ # A form inside a frame answers into that frame. Pause and Delete redirect to
+ # a whole page, so inside the drawer they would only empty it and leave the
+ # list behind them stale.
+ test "the drawer's pause and delete submit to the whole page" do
+ bill = create_bill(name: "Rent", amount: 2150)
+
+ get_bill_drawer(bill)
+
+ assert_response :success
+ [ toggle_status_recurring_transaction_path(bill), recurring_transaction_path(bill) ].each do |action|
+ assert_select "form[action=?] button[data-turbo-frame=_top]", action
+ end
+ end
+
+ # The row is a real link, so a cmd-click or a pasted URL arrives with no frame
+ # to render into. A bare dialog with no page around it never opens, which
+ # would leave a blank tab.
+ test "a drawer link opened outside the drawer lands on the bill's page" do
+ bill = create_bill(name: "Power Co", amount: 80)
+
+ get bill_url(bill, display: "drawer")
+
+ assert_response :success
+ assert_select "main h1", text: "Power Co"
end
test "the paycheck view lists declared income with an edit affordance" do
@@ -990,9 +1040,8 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
# Trial and renewal are STATE: they change what you might do about the bill
# today, so both routes to it must say so. Price history is the record of
# how it got here, which is the page's job.
- { "page" => bill_url(sub),
- "expansion" => bill_url(sub, display: "pane", frame: "x") }.each do |label, url|
- get url
+ { "page" => -> { get bill_url(sub) }, "drawer" => -> { get_bill_drawer(sub) } }.each do |label, request|
+ request.call
assert_response :success
assert_match I18n.t("bills.detail.trial_chip", date: I18n.l(Date.current + 5, format: :short)),
response.body, "the #{label} lost the trial chip"
@@ -1160,15 +1209,16 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
assert_equal "Dismissed", I18n.t("recurring_transactions.status.ended")
end
- # The expansion and the drawer used to be two templates over one action, so
- # they drifted, and the fix made them render the SAME partial -- which traded
- # a disagreement for a duplication: two surfaces answering one question.
+ # The row expansion and the old drawer used to be two templates over one
+ # action, so they drifted, and the fix made them render the SAME partial --
+ # which traded a disagreement for a duplication: two surfaces answering one
+ # question.
#
# They now answer different ones. What has to stay true is that nothing was
# lost on the way, and that the shallower surface never quietly grows into
- # the deeper one again. So: the expansion is a strict subset of the page, and
+ # the deeper one again. So: the drawer is a strict subset of the page, and
# every section the old shared partial rendered still exists somewhere.
- test "the expansion is a subset of the bill's page, and nothing was dropped" do
+ test "the drawer is a subset of the bill's page, and nothing was dropped" do
bill = create_bill(name: "Power Co", amount: 80, notes: "Account 4821")
past = bill.recurring_occurrences.create!(
family: @family, original_due_on: 2.months.ago.to_date,
@@ -1188,9 +1238,9 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
assert_response :success
page = response.body
- get bill_url(bill, display: "pane", frame: "x"), headers: { "Turbo-Frame" => "x" }
+ get_bill_drawer(bill)
assert_response :success
- pane = response.body
+ drawer = response.body
# Every section the shared partial used to render still has a home.
everything = %w[rules history_title average annualized ytd upcoming
@@ -1199,14 +1249,14 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
homeless = everything.reject { |key| page.include?(I18n.t("bills.detail.#{key}")) }
assert_empty homeless, "relocating the detail must not delete any of it"
- # And the expansion adds nothing of its own that the page lacks.
- shown_in_pane = everything.select { |key| pane.include?(I18n.t("bills.detail.#{key}")) }
- assert_equal shown_in_pane, shown_in_pane & everything.select { |key| page.include?(I18n.t("bills.detail.#{key}")) },
- "the expansion must stay a subset, never a second detail view"
+ # And the drawer adds nothing of its own that the page lacks.
+ shown_in_drawer = everything.select { |key| drawer.include?(I18n.t("bills.detail.#{key}")) }
+ assert_equal shown_in_drawer, shown_in_drawer & everything.select { |key| page.include?(I18n.t("bills.detail.#{key}")) },
+ "the drawer must stay a subset, never a second detail view"
[ "POWER CO AUTOPAY", "$78.50" ].each do |fact|
assert_includes page, fact, "the page is missing #{fact}"
- assert_includes pane, fact, "the expansion is missing #{fact}"
+ assert_includes drawer, fact, "the drawer is missing #{fact}"
end
assert_includes page, "Account 4821", "notes belong to the page"
end
@@ -1652,6 +1702,11 @@ class BillsControllerTest < ActionDispatch::IntegrationTest
)
end
+ # What a row asks for: the drawer variant, fetched into the drawer frame.
+ def get_bill_drawer(bill, **params)
+ get bill_url(bill, display: "drawer", **params), headers: { "Turbo-Frame" => "drawer" }
+ end
+
def create_bill(name:, amount:, **overrides)
@family.recurring_transactions.create!({
account: accounts(:depository),
diff --git a/test/controllers/recurring_occurrences_controller_test.rb b/test/controllers/recurring_occurrences_controller_test.rb
index a170563fe4..a1fd857bb8 100644
--- a/test/controllers/recurring_occurrences_controller_test.rb
+++ b/test/controllers/recurring_occurrences_controller_test.rb
@@ -25,6 +25,29 @@ class RecurringOccurrencesControllerTest < ActionDispatch::IntegrationTest
assert_equal 1, response.body.scan(/<turbo-frame[^>]*id="drawer"/).size
end
+ # Turbo caches the page as it was left, so a drawer still open when "View
+ # full bill" navigated away would come back from Back as a stray dialog.
+ # Visited directly, the dialog is the page, and Back has to restore it.
+ test "the dialog is left out of Turbo's page cache in the drawer, not on a direct visit" do
+ get recurring_occurrence_url(@occurrence), headers: { "Turbo-Frame" => "drawer" }
+ assert_select "turbo-frame#drawer > dialog[data-turbo-temporary]", count: 1
+
+ # Scoped to the frame: the layout's own confirm dialog is a <dialog> too.
+ get recurring_occurrence_url(@occurrence)
+ assert_select "turbo-frame#drawer > dialog", count: 1
+ assert_select "turbo-frame#drawer > dialog[data-turbo-temporary]", count: 0
+ end
+
+ # Pause redirects back to the page it was pressed on. Fetched for the drawer
+ # frame, that page has no drawer frame in it, so the drawer would read
+ # "Content missing" instead of the list updating behind it.
+ test "the dialog's pause submits to the whole page" do
+ get recurring_occurrence_url(@occurrence), headers: { "Turbo-Frame" => "drawer" }
+
+ assert_response :success
+ assert_select "form[action=?] button[data-turbo-frame=_top]", toggle_status_recurring_transaction_path(@series)
+ end
+
test "recurring occurrence feedback is localized in German" do
@user.update!(locale: "de")
diff --git a/test/controllers/recurring_transactions_controller_test.rb b/test/controllers/recurring_transactions_controller_test.rb
index bf7f13128f..55101b5bb8 100644
--- a/test/controllers/recurring_transactions_controller_test.rb
+++ b/test/controllers/recurring_transactions_controller_test.rb
@@ -84,6 +84,14 @@ class RecurringTransactionsControllerTest < ActionDispatch::IntegrationTest
assert @recurring_transaction.reload.active?
end
+ # Pause is offered from the Bills drawer and the bill's page as well as from
+ # this settings page, and it used to send all of them here.
+ test "toggle_status returns to the page it was pressed on" do
+ post toggle_status_recurring_transaction_url(@recurring_transaction), headers: { "Referer" => bills_url }
+
+ assert_redirected_to bills_url
+ end
+
# The dialog is delivered into the shared <turbo-frame id="modal"> that every page
# layout already renders empty. If this action responds with a full page layout,
# the response carries two frames with that id, Turbo matches the empty one first,
diff --git a/test/system/bill_drawer_test.rb b/test/system/bill_drawer_test.rb
new file mode 100644
index 0000000000..d1ebc1e60c
--- /dev/null
+++ b/test/system/bill_drawer_test.rb
@@ -0,0 +1,99 @@
+require "application_system_test_case"
+
+# A bill opens the way a transaction or a budget category does: in the drawer,
+# over the list. Closing it has to put keyboard focus back on the row, or every
+# bill someone checks sends them back to the top of the page.
+class BillDrawerTest < ApplicationSystemTestCase
+ setup do
+ sign_in @user = users(:family_admin)
+ @user.update!(preferences: (@user.preferences || {}).merge("preview_features_enabled" => true))
+
+ # Overdue, so its row and its drawer offer Find payment, and so its row is
+ # the only link to this cycle: Next up lists nothing already past due.
+ due = 6.days.ago.to_date
+ bill = @user.family.recurring_transactions.create!(
+ name: "City Water", account: accounts(:depository), amount: 80, currency: "USD",
+ expected_day_of_month: due.day, last_occurrence_date: 2.months.ago.to_date,
+ next_expected_date: due, status: "active"
+ )
+ overdue = bill.recurring_occurrences.detect(&:overdue?)
+ @row_link = "a[data-turbo-frame='drawer'][href='#{bill_path(bill, display: "drawer", occurrence: overdue.id)}']"
+ @find_payment_link = "a[data-turbo-frame='drawer'][href='#{recurring_occurrence_path(overdue)}']"
+ end
+
+ # The inline expansion used to push everything below it down the page. The
+ # drawer opens over the list, so closing it leaves the row where it was.
+ test "on a phone, a row opens its drawer, and closing it puts focus back on the row where it was" do
+ # Enough rows below it that the list scrolls, or "where it was" is a
+ # position nothing could have moved.
+ 8.times do |i|
+ due = Date.current + 10 + i
+ @user.family.recurring_transactions.create!(
+ name: "Later bill #{i}", account: accounts(:depository), amount: 20 + i, currency: "USD",
+ expected_day_of_month: due.day, last_occurrence_date: due - 1.month,
+ next_expected_date: due, status: "active"
+ )
+ end
+ page.driver.browser.manage.window.resize_to(375, 812)
+ visit bills_url
+ row = find(@row_link)
+ scroll_to row, align: :center
+ assert_operator page.evaluate_script("document.querySelector('#main').scrollTop"), :>, 0
+ top = row.evaluate_script("this.getBoundingClientRect().top")
+
+ row.click
+ within("dialog[open]") do
+ assert_selector "h2", text: "City Water"
+ click_on I18n.t("ds.dialog.close")
+ end
+
+ assert_no_selector "dialog[open]"
+ assert_selector @row_link, focused: true
+ assert_equal top, row.evaluate_script("this.getBoundingClientRect().top"), "the list moved"
+ ensure
+ page.driver.browser.manage.window.resize_to(1400, 1400)
+ end
+
+ # Turbo caches the page as it was left. A drawer still open when "View full
+ # bill" navigated away came back from Back as a stray, non-modal dialog.
+ test "going back from the bill's page shows the list, not a leftover drawer" do
+ visit bills_url
+
+ find(@row_link).click
+ within("dialog[open]") { click_on I18n.t("bills.view_full_bill") }
+ assert_selector "main h1", text: "City Water"
+
+ page.go_back
+ assert_selector @row_link
+ assert_no_selector "dialog[open]"
+ end
+
+ # 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
+ visit bills_url
+
+ find(@find_payment_link).click
+ within("dialog[open]") { click_on I18n.t("recurring_occurrences.show.view_bill") }
+ assert_selector "main h1", text: "City Water"
+
+ page.go_back
+ assert_selector @row_link
+ assert_no_selector "dialog[open]"
+ end
+
+ # Find payment swaps the bill's drawer for the payment drawer inside the same
+ # frame, and the link that did it goes with the first one.
+ test "closing the payment drawer opened from a bill's drawer returns focus to the row" do
+ visit bills_url
+
+ find(@row_link).click
+ within("dialog[open]") { click_on I18n.t("bills.find_payment") }
+ # Waits on a control only the payment drawer has: its "remaining" line
+ # reads exactly like the bill drawer's.
+ within("dialog[open]") { assert_link I18n.t("recurring_occurrences.show.mark_paid") }
+
+ page.send_keys(:escape)
+ assert_no_selector "dialog[open]"
+ assert_selector @row_link, focused: true
+ end
+end
diff --git a/test/system/bills_mobile_test.rb b/test/system/bills_mobile_test.rb
index 432221a449..d670fb5a4d 100644
--- a/test/system/bills_mobile_test.rb
+++ b/test/system/bills_mobile_test.rb
@@ -99,11 +99,16 @@ class BillsMobileTest < ApplicationSystemTestCase
all("summary", text: I18n.t("bills.paycheck.reserved_ahead")).each(&:click)
assert_no_horizontal_scroll("the paycheck view with reserved amounts open")
- # And with a row expanded, which is the widest the page ever gets.
+ # And a bill opened in its drawer, back at phone width.
+ page.driver.browser.manage.window.resize_to(*PHONE)
visit bills_url
- find("a[data-turbo-frame^='pane_recurring_occurrence_']", match: :first).click
- assert_text bill.display_name
- assert_no_horizontal_scroll("the overview with a row expanded")
+ find("a[data-turbo-frame='drawer']", text: bill.display_name, match: :first).click
+ within("dialog[open]") do
+ assert_selector "h2", text: bill.display_name
+ # A phone has no Esc key, so the way out has to be on screen.
+ assert_selector "button[aria-label='#{I18n.t("ds.dialog.close")}']", visible: true
+ end
+ assert_no_horizontal_scroll("the bill drawer")
end
# A green overflow assertion proves nothing unless it can go red, and this
@@ -123,6 +128,28 @@ class BillsMobileTest < ApplicationSystemTestCase
assert_raises(Minitest::Assertion) { assert_no_horizontal_scroll("a deliberately wide element") }
end
+ # The same proof for a drawer, which sits outside #main where the document
+ # measurement cannot see it.
+ test "the overflow check sees inside an open drawer" do
+ bill = @family.recurring_transactions.create!(
+ name: "CITY WATER", 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
+ )
+ visit recurring_occurrence_url(bill.recurring_occurrences.order(:due_on).first)
+ assert_no_horizontal_scroll("the payment drawer")
+
+ page.execute_script(<<~JS)
+ const wide = document.createElement("div");
+ wide.style.width = "3000px";
+ wide.style.height = "1px";
+ document.querySelector("dialog[open] [data-DS--dialog-target='content'] > .overflow-auto").appendChild(wide);
+ JS
+
+ assert_raises(Minitest::Assertion) { assert_no_horizontal_scroll("a deliberately wide drawer") }
+ end
+
test "the payment drawer is escapable on a phone" do
bill = @family.recurring_transactions.create!(
name: "CITY WATER", account: accounts(:depository), amount: 80, currency: "USD",
@@ -145,19 +172,23 @@ class BillsMobileTest < ApplicationSystemTestCase
private
# The document must never be wider than the viewport, and neither must the
- # scroll container inside it.
+ # scroll container inside it. An open drawer sits outside #main, in a scroll
+ # container of its own.
def assert_no_horizontal_scroll(label)
overflow = page.evaluate_script(<<~JS)
(() => {
const main = document.querySelector("#main");
+ const drawer = document.querySelector("dialog[open] [data-DS--dialog-target='content'] > .overflow-auto");
return {
doc: document.documentElement.scrollWidth - document.documentElement.clientWidth,
- main: main ? main.scrollWidth - main.clientWidth : 0
+ main: main ? main.scrollWidth - main.clientWidth : 0,
+ drawer: drawer ? drawer.scrollWidth - drawer.clientWidth : 0
};
})()
JS
assert_operator overflow["doc"], :<=, 1, "#{label} scrolls the document sideways"
assert_operator overflow["main"], :<=, 1, "#{label} scrolls its main content sideways"
+ assert_operator overflow["drawer"], :<=, 1, "#{label} scrolls its drawer sideways"
end
end
diff --git a/test/system/declare_and_pay_bill_test.rb b/test/system/declare_and_pay_bill_test.rb
index 009751a79b..254ff25caf 100644
--- a/test/system/declare_and_pay_bill_test.rb
+++ b/test/system/declare_and_pay_bill_test.rb
@@ -29,27 +29,30 @@ class DeclareAndPayBillTest < ApplicationSystemTestCase
click_on I18n.t("bills.index.add_bill"), match: :first
fill_in I18n.t("recurring_transactions.form.name_label"), with: "Watson Property"
fill_in I18n.t("recurring_transactions.form.amount_label"), with: "2150"
- fill_in I18n.t("recurring_transactions.form.first_due_on_label"), with: due.strftime("%m/%d/%Y")
+ # A Date, not a typed string: Capybara sets it as ISO, where typed digits
+ # land in whatever day/month order the browser's locale uses.
+ fill_in I18n.t("recurring_transactions.form.first_due_on_label"), with: due
# Account is optional (DS::Select is a custom combobox; the family
# fallback covers candidates), so the bill is declared without one.
click_button I18n.t("recurring_transactions.form.submit")
assert_text "Watson Property"
- # Scan, then inspect: the row itself opens the expansion. It is due in ten
- # days, so the row carries no call to action -- there is nothing to chase
- # yet -- and the verb lives in the expansion, spelled out.
+ # Scan, then inspect: the row itself opens the bill's drawer. It is due in
+ # ten days, so the row carries no call to action -- there is nothing to
+ # chase yet -- and the verb lives in the drawer, spelled out.
#
- # Targeted by the frame it loads rather than by bare name: the bill also
- # appears in the summary's Next up strip, which goes to its page instead.
- # And by name within that: the index materializes the fixture family's
- # series on first visit now, so "first row" is no longer this bill.
- find("a[data-turbo-frame^='pane_recurring_occurrence_']", text: "Watson Property", match: :first).click
- within(find("turbo-frame[id^='pane_recurring_occurrence_']", match: :first)) do
+ # Targeted by name: the index materializes the fixture family's series on
+ # first visit now, so "first row" is no longer this bill. Its Next up item
+ # may come first, and opens the same drawer.
+ find("a[data-turbo-frame='drawer']", text: "Watson Property", match: :first).click
+ within("dialog[open]") do
click_on I18n.t("bills.find_payment")
end
- # Act: the drawer leads with what is owed.
+ # Act: the payment drawer leads with what is owed. Its "remaining" line
+ # reads exactly like the bill drawer's, so wait on its own control first.
+ within("dialog[open]") { assert_link I18n.t("recurring_occurrences.show.mark_paid") }
assert_text I18n.t("recurring_occurrences.show.remaining", amount: "$2,150.00")
# This bill was declared a moment ago, so the matcher knows it only by the