The personal finance app for everyone (by everyone)
Ruby
Move pending transaction pill beside the amount (#4745)
Sure Admin (bot)2d07fa66a008
diff --git a/app/views/transactions/_transaction.html.erb b/app/views/transactions/_transaction.html.erbindex 428bf0ef1e..8f449888e0 100644--- a/app/views/transactions/_transaction.html.erb+++ b/app/views/transactions/_transaction.html.erb@@ -97,17 +97,6 @@</span><% end %>- <%# Pending indicator %>- <% if transaction.pending? %>- <%= render DS::Pill.new(- label: t("transactions.transaction.pending"),- tone: :neutral,- marker: false,- icon: "clock",- title: t("transactions.transaction.pending_tooltip")- ) %>- <% end %>-<%# Potential duplicate indicator - different styling for low vs medium confidence %><% if transaction.has_potential_duplicate? %><% if transaction.low_confidence_duplicate? %>@@ -240,19 +229,32 @@</span><% end %>- <div class="shrink-0 ml-auto flex items-center justify-end gap-2 <%= "opacity-50" if entry.excluded %>">- <%# Protection indicator - shows on hover when entry is protected from sync %>- <% if entry.protected_from_sync? && !entry.excluded? %>- <%= link_to entry_path(entry),- data: { turbo_frame: "drawer", turbo_prefetch: false },- class: "invisible group-hover:visible transition-opacity",- title: t("entries.protection.tooltip") do %>- <%= icon "lock", size: "sm", class: "text-secondary" %>- <% end %>+ <div class="ml-auto flex min-w-0 max-w-full flex-col-reverse items-end justify-end gap-1 lg:flex-row lg:flex-wrap-reverse lg:items-center lg:gap-2 <%= "opacity-50" if entry.excluded %>">+ <%# Pending indicator %>+ <% if transaction.pending? %>+ <%= render DS::Pill.new(+ label: t("transactions.transaction.pending"),+ tone: :neutral,+ marker: false,+ icon: "clock",+ title: t("transactions.transaction.pending_tooltip")+ ) %><% end %>- <%= content_tag :p,- transaction.transfer? && view_ctx == "global" ? "+/- #{format_money(entry.amount_money.abs)}" : format_money(-entry.amount_money),- class: ["privacy-sensitive", "text-green-600": entry.amount.negative?] %>++ <div class="shrink-0 flex items-center justify-end gap-2">+ <%# Protection indicator - shows on hover when entry is protected from sync %>+ <% if entry.protected_from_sync? && !entry.excluded? %>+ <%= link_to entry_path(entry),+ data: { turbo_frame: "drawer", turbo_prefetch: false },+ class: "invisible group-hover:visible transition-opacity",+ title: t("entries.protection.tooltip") do %>+ <%= icon "lock", size: "sm", class: "text-secondary" %>+ <% end %>+ <% end %>+ <%= content_tag :p,+ transaction.transfer? && view_ctx == "global" ? "+/- #{format_money(entry.amount_money.abs)}" : format_money(-entry.amount_money),+ class: ["privacy-sensitive shrink-0", "text-green-600": entry.amount.negative?] %>+ </div></div></div></div>diff --git a/app/views/transactions/_transfer_match.html.erb b/app/views/transactions/_transfer_match.html.erbindex 749e21b6f9..3b24218606 100644--- a/app/views/transactions/_transfer_match.html.erb+++ b/app/views/transactions/_transfer_match.html.erb@@ -6,7 +6,7 @@<%= icon "link-2", size: "sm", class: "text-secondary" %></span><% elsif transaction.transfer.pending? %>- <span class="hidden lg:inline">+ <span class="hidden lg:flex items-center"><%= render DS::Pill.new(label: t("transactions.transfer_match.auto_matched"),tone: :neutral,@@ -14,7 +14,7 @@show_dot: false) %></span>- <span class="inline lg:hidden">+ <span class="flex items-center lg:hidden"><%= render DS::Pill.new(label: t("transactions.transfer_match.auto_matched_short"),tone: :neutral,diff --git a/config/locales/views/transactions/en.yml b/config/locales/views/transactions/en.ymlindex 0d1623f3b0..bf44a48de5 100644--- a/config/locales/views/transactions/en.yml+++ b/config/locales/views/transactions/en.yml@@ -168,8 +168,8 @@ en:split_parent_row:split_label: "Split"transfer_match:- auto_matched: Auto-matched- auto_matched_short: Auto+ auto_matched: Match?+ auto_matched_short: Match?confirm_match: Confirm matchpayment_confirmed: Payment is confirmedreject_match: Reject matchdiff --git a/test/system/transactions_test.rb b/test/system/transactions_test.rbindex 479c96cb58..9b16546904 100644--- a/test/system/transactions_test.rb+++ b/test/system/transactions_test.rb@@ -140,7 +140,68 @@ class TransactionsTest < ApplicationSystemTestCaseassert_text @transaction.nameend+ test "keeps pending status beside the amount without crowding the name" do+ @user.update!(show_ai_sidebar: false)+ entry = create_transaction("Streaming subscription with a long merchant name", Date.current, 12.99)+ entry.entryable.update!(extra: { "plaid" => { "pending" => true } })+ pending = "[title='#{I18n.t("transactions.transaction.pending_tooltip")}']"++ [ 390, 820, 1024, 1440 ].each do |width|+ page.current_window.resize_to(width, 900)+ visit transactions_url(per_page: @page_size)++ row = find("##{dom_id(entry)} [data-controller='clickable-row']")+ assert_no_selector "##{dom_id(entry)} [data-tag-fit-bounds='0.5'] #{pending}"+ pill = row.find(pending).evaluate_script("this.getBoundingClientRect().toJSON()")+ amount = row.find("p.privacy-sensitive").evaluate_script("this.getBoundingClientRect().toJSON()")+ bounds = row.evaluate_script("this.getBoundingClientRect().toJSON()")++ if page.evaluate_script("window.matchMedia('(min-width: 64rem)').matches")+ assert_operator pill["right"], :<=, amount["left"], "Pending must precede the amount at #{width}px"+ assert_in_delta pill["y"] + pill["height"] / 2, amount["y"] + amount["height"] / 2, 0.5+ else+ assert_operator pill["top"], :>=, amount["bottom"], "Pending must sit below the amount at #{width}px"+ assert_in_delta pill["right"], amount["right"], 1+ end+ assert_operator pill["left"], :>=, bounds["left"]+ columns = row.all(:xpath, "./div[contains(@class, 'col-span-5') or contains(@class, 'col-span-3')]", visible: true)+ columns.each do |column|+ right = column.evaluate_script("this.getBoundingClientRect().right")+ assert_operator pill["left"], :>=, right - 1, "Pending must clear the name and category at #{width}px"+ end+ assert_operator amount["right"], :<=, bounds["right"]+ assert_operator amount["height"], :<=, 24, "the amount should stay on one line at #{width}px"+ end++ entry.entryable.update!(extra: { "plaid" => { "pending" => false } })+ visit transactions_url(per_page: @page_size)+ assert_no_selector "##{dom_id(entry)} #{pending}"+ end++ test "keeps pending amounts contained with both sidebars open" do+ @user.update!(show_ai_sidebar: true)+ entry = create_transaction("Pending payment", Date.current, 4321.09)+ entry.entryable.update!(extra: { "plaid" => { "pending" => true } })++ [ 1100, 1280, 1440 ].each do |width|+ page.current_window.resize_to(width, 900)+ visit transactions_url(per_page: @page_size)+ assert_selector "[data-app-layout-target='rightSidebar']", visible: true+ row = find("##{dom_id(entry)} [data-controller='clickable-row']")+ column = row.find("[data-tag-fit-bounds='1']").find(:xpath, "..").evaluate_script("this.getBoundingClientRect().toJSON()")+ amount = row.find("p.privacy-sensitive").evaluate_script("this.getBoundingClientRect().toJSON()")+ pill = row.find("[title='#{I18n.t("transactions.transaction.pending_tooltip")}']").evaluate_script("this.getBoundingClientRect().toJSON()")+ [ pill, amount ].each do |bounds|+ assert_operator bounds["left"], :>=, column["left"] - 1+ assert_operator bounds["right"], :<=, column["right"] + 1+ end+ assert_operator amount["height"], :<=, 24+ end+ end+test "confirms an auto-matched transfer from beside the amount" do+ @user.update!(show_ai_sidebar: false)+ page.current_window.resize_to(1440, 900)outflow = create_transaction("Payment to credit card", Date.current, 100)inflow = create_transaction("Payment received", Date.current, -100, account: accounts(:credit_card))transfer = Transfer.create!(outflow_transaction: outflow.entryable, inflow_transaction: inflow.entryable)@@ -148,6 +209,10 @@ class TransactionsTest < ApplicationSystemTestCasevisit transactions_url(per_page: @page_size)assert_selector match+ pill_bounds = find("#{match} [title='#{I18n.t("transactions.transfer_match.auto_matched")}']", visible: true).evaluate_script("this.getBoundingClientRect().toJSON()")+ amount_bounds = find("##{dom_id(outflow)} p.privacy-sensitive").evaluate_script("this.getBoundingClientRect().toJSON()")+ assert_in_delta pill_bounds["y"] + pill_bounds["height"] / 2,+ amount_bounds["y"] + amount_bounds["height"] / 2, 0.5assert_no_selector "[data-tag-fit-bounds='0.5'] #{match}"within(match) { click_button I18n.t("transactions.transfer_match.confirm_match") }