mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-23 23:29:39 +02:00
Rework account views and addition flow (#1324)
* Move accountable partials * Split accountables into separate view partials * Fix test * Add form to permitted partials * Fix failing system tests * Update new account modal views * New sync algorithm implementation * Update account system test assertions to match new behavior * Fix off by 1 date error * Revert new balance sync algorithm * Add missing account overviews
This commit is contained in:
parent
c7c281073f
commit
e8e100e1d8
88 changed files with 763 additions and 526 deletions
|
@ -11,12 +11,6 @@ class ApplicationHelperTest < ActionView::TestCase
|
|||
assert_equal "Test Header Title", content_for(:header_title)
|
||||
end
|
||||
|
||||
test "#permitted_accountable_partial(accountable_type)" do
|
||||
assert_equal "account", permitted_accountable_partial("Account")
|
||||
assert_equal "user", permitted_accountable_partial("User")
|
||||
assert_equal "admin_user", permitted_accountable_partial("AdminUser")
|
||||
end
|
||||
|
||||
def setup
|
||||
@account1 = Account.new(currency: "USD", balance: 1)
|
||||
@account2 = Account.new(currency: "USD", balance: 2)
|
||||
|
|
|
@ -35,15 +35,6 @@ class Account::Balance::SyncerTest < ActiveSupport::TestCase
|
|||
assert_equal [ 19600, 19500, 19500, 20000, 20000, 20000 ], @account.balances.chronological.map(&:balance)
|
||||
end
|
||||
|
||||
test "syncs account with trades only" do
|
||||
aapl = securities(:aapl)
|
||||
create_trade(aapl, account: @investment_account, date: 1.day.ago.to_date, qty: 10)
|
||||
|
||||
run_sync_for @investment_account
|
||||
|
||||
assert_equal [ 52140, 50000, 50000 ], @investment_account.balances.chronological.map(&:balance)
|
||||
end
|
||||
|
||||
test "syncs account with valuations and transactions" do
|
||||
create_valuation(account: @account, date: 5.days.ago.to_date, amount: 20000)
|
||||
create_transaction(account: @account, date: 3.days.ago.to_date, amount: -500)
|
||||
|
|
|
@ -80,19 +80,15 @@ class AccountsTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
def assert_account_created(accountable_type, &block)
|
||||
click_link humanized_accountable(accountable_type)
|
||||
click_link "Enter account balance manually"
|
||||
click_link "Enter account manually"
|
||||
|
||||
account_name = "[system test] #{accountable_type} Account"
|
||||
|
||||
select accountable_type.titleize, from: "Account type"
|
||||
fill_in "Account name", with: account_name
|
||||
fill_in "account[balance]", with: 100.99
|
||||
fill_in "Start date (optional)", with: 10.days.ago.to_date
|
||||
fill_in "account[start_balance]", with: 95.25
|
||||
|
||||
yield if block_given?
|
||||
|
||||
click_button "Add #{humanized_accountable(accountable_type).downcase}"
|
||||
click_button "Create Account"
|
||||
|
||||
find("details", text: humanized_accountable(accountable_type)).click
|
||||
assert_text account_name
|
||||
|
@ -107,8 +103,10 @@ class AccountsTest < ApplicationSystemTestCase
|
|||
click_on "Edit"
|
||||
end
|
||||
|
||||
yield if block_given?
|
||||
|
||||
fill_in "Account name", with: "Updated account name"
|
||||
click_button "Update #{humanized_accountable(accountable_type).downcase}"
|
||||
click_button "Update Account"
|
||||
assert_selector "h2", text: "Updated account name"
|
||||
end
|
||||
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
require "application_system_test_case"
|
||||
|
||||
class TooltipsTest < ApplicationSystemTestCase
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include ApplicationHelper
|
||||
|
||||
setup do
|
||||
sign_in @user = users(:family_admin)
|
||||
@account = accounts(:investment)
|
||||
end
|
||||
|
||||
test "can see account information tooltip" do
|
||||
visit account_path(@account)
|
||||
tooltip_element = find('[data-controller="tooltip"]')
|
||||
tooltip_element.hover
|
||||
tooltip_contents = find('[data-tooltip-target="tooltip"]')
|
||||
assert tooltip_contents.visible?
|
||||
within tooltip_contents do
|
||||
assert_text I18n.t("accounts.tooltip.total_value_tooltip")
|
||||
assert_text I18n.t("accounts.tooltip.holdings")
|
||||
assert_text format_money(@account.investment.holdings_value, precision: 0)
|
||||
assert_text I18n.t("accounts.tooltip.cash")
|
||||
assert_text format_money(@account.balance_money, precision: 0)
|
||||
end
|
||||
find("body").click
|
||||
assert find('[data-tooltip-target="tooltip"]', visible: false)
|
||||
end
|
||||
end
|
|
@ -62,6 +62,6 @@ class TradesTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
def visit_account_trades
|
||||
visit account_url(@account, tab: "trades")
|
||||
visit account_url(@account, tab: "transactions")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -156,6 +156,7 @@ class TransactionsTest < ApplicationSystemTestCase
|
|||
|
||||
test "can create deposit transaction for investment account" do
|
||||
investment_account = accounts(:investment)
|
||||
investment_account.entries.create!(name: "Investment account", date: Date.current, amount: 1000, currency: "USD", entryable: Account::Transaction.new)
|
||||
transfer_date = Date.current
|
||||
visit account_path(investment_account)
|
||||
click_on "New transaction"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue