Files
sure/test/models/account_simplefin_creation_test.rb
LPW cf5e7de65f UI Suggestions for Account Types in Setup Modal + Stats-Based Inactive Handling (#368)
* - Add tests for `Simplefin::AccountTypeMapper` and `AccountSimplefinCreation`
- Implement `Simplefin::AccountTypeMapper` for account type inference with fallback-only logic
- Enhance inactive state handling for `SimplefinItem::Importer`
- Improve subtype selection handling in views with confidence-based inference

* Remove unnecessary `.presence` check for `openai_uri_base` in hostings settings

* Refine zero balance detection logic in `SimplefinItem::Importer` and add regression test for missing balances scenario

* Enhance account type and subtype inference logic with explicit investment subtype mapping, improved regex handling, and institution-based credit card detection

* Refine retirement subtype mapping in `AccountTypeMapper` tests with explicit case-based assertions

* Expand `AccountTypeMapper` investment subtype mapping to include `403b` and `tsp` with updated regex definitions

* Remove unused `retirement_hint?` method in `AccountTypeMapper` to simplify codebase

---------

Co-authored-by: Josh Waldrep <joshua.waldrep5+github@gmail.com>
2025-11-24 14:07:14 +01:00

39 lines
1006 B
Ruby

require "test_helper"
class AccountSimplefinCreationTest < ActiveSupport::TestCase
setup do
@family = families(:dylan_family)
@item = SimplefinItem.create!(family: @family, name: "SF Conn", access_url: "https://example.com/access")
end
test "requires explicit account_type at creation" do
sfa = SimplefinAccount.create!(
simplefin_item: @item,
name: "Brokerage",
account_id: "acct_1",
currency: "USD",
account_type: "investment",
current_balance: 1000
)
assert_raises(ArgumentError) do
Account.create_from_simplefin_account(sfa, nil)
end
end
test "uses provided account_type without inference" do
sfa = SimplefinAccount.create!(
simplefin_item: @item,
name: "My Loan",
account_id: "acct_2",
currency: "USD",
account_type: "loan",
current_balance: -5000
)
account = Account.create_from_simplefin_account(sfa, "Loan")
assert_equal "Loan", account.accountable_type
end
end