1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00
Maybe/test/system/transfers_test.rb
Zach Gollwitzer c3314e62d1
Account::Entry Delegated Type (namespace updates part 7) (#923)
* Initial entryable models

* Update transfer and tests

* Update transaction controllers and tests

* Update sync process to use new entries model

* Get dashboard working again

* Update transfers, imports, and accounts to use Account::Entry

* Update system tests

* Consolidate transaction management into entries controller

* Add permitted partial key helper

* Move account transactions list to entries controller

* Delegate transaction entries search

* Move transfer relation to entry

* Update bulk transaction management flows to use entries

* Remove test code

* Test fix attempt

* Update demo data script

* Consolidate remaining transaction partials to entries

* Consolidate valuations controller to entries controller

* Lint fix

* Remove unused files, additional cleanup

* Add back valuation creation

* Make migrations fully reversible

* Stale routes cleanup

* Migrations reversible fix

* Move types to entryable concern

* Fix search when no entries found

* Remove more unused code
2024-07-01 10:49:43 -04:00

89 lines
2.2 KiB
Ruby

require "application_system_test_case"
class TransfersTest < ApplicationSystemTestCase
setup do
sign_in @user = users(:family_admin)
visit transactions_url
end
test "can create a transfer" do
checking_name = accounts(:checking).name
savings_name = accounts(:savings).name
transfer_date = Date.current
click_on "New transaction"
# Will navigate to different route in same modal
click_on "Transfer"
assert_text "New transfer"
fill_in "Description", with: "Transfer txn name"
select checking_name, from: "From"
select savings_name, from: "To"
fill_in "account_transfer[amount]", with: 500
fill_in "Date", with: transfer_date
click_button "Create transfer"
within "#entry-group-" + transfer_date.to_s do
assert_text "Transfer from"
end
end
test "can match 2 transactions and create a transfer" do
transfer_date = Date.current
outflow = accounts(:savings).entries.create! \
name: "Outflow from savings account",
date: transfer_date,
amount: 100,
currency: "USD",
entryable: Account::Transaction.new
inflow = accounts(:checking).entries.create! \
name: "Inflow to checking account",
date: transfer_date,
amount: -100,
currency: "USD",
entryable: Account::Transaction.new
visit transactions_url
transaction_entry_checkbox(inflow).check
transaction_entry_checkbox(outflow).check
bulk_transfer_action_button.click
click_on "Mark as transfers"
within "#entry-group-" + transfer_date.to_s do
assert_text "Transfer from"
end
end
test "can mark a single transaction as a transfer" do
txn = @user.family.entries.reverse_chronological.first
within "#" + dom_id(txn) do
assert_text "Uncategorized"
end
transaction_entry_checkbox(txn).check
bulk_transfer_action_button.click
click_on "Mark as transfers"
within "#" + dom_id(txn) do
assert_no_text "Uncategorized"
end
end
private
def transaction_entry_checkbox(transaction_entry)
find("#" + dom_id(transaction_entry, "selection"))
end
def bulk_transfer_action_button
find("#bulk-transfer-btn")
end
end