2024-05-17 09:09:32 -04:00
|
|
|
require "application_system_test_case"
|
|
|
|
|
|
|
|
class ImportsTest < ApplicationSystemTestCase
|
2024-10-01 10:47:59 -04:00
|
|
|
include ActiveJob::TestHelper
|
2024-05-17 09:09:32 -04:00
|
|
|
|
|
|
|
setup do
|
|
|
|
sign_in @user = users(:family_admin)
|
2025-03-17 11:54:53 -04:00
|
|
|
|
|
|
|
# Trade securities will be imported as "offline" tickers
|
|
|
|
Security.stubs(:provider).returns(nil)
|
2024-05-17 09:09:32 -04:00
|
|
|
end
|
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
test "transaction import" do
|
|
|
|
visit new_import_path
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Import transactions"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2025-04-18 18:53:10 +05:30
|
|
|
find("button[data-id='csv-paste-tab']").click
|
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
fill_in "import[raw_file_str]", with: file_fixture("imports/transactions.csv").read
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
find('input[type="submit"][value="Upload CSV"]').click
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2025-04-18 10:48:10 -04:00
|
|
|
select "Date", from: "import[date_col_label]"
|
|
|
|
select "YYYY-MM-DD", from: "import[date_format]"
|
|
|
|
select "Amount", from: "import[amount_col_label]"
|
|
|
|
select "Account", from: "import[account_col_label]"
|
|
|
|
select "Name", from: "import[name_col_label]"
|
|
|
|
select "Category", from: "import[category_col_label]"
|
|
|
|
select "Tags", from: "import[tags_col_label]"
|
|
|
|
select "Notes", from: "import[notes_col_label]"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Apply configuration"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Next step"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
assert_selector "h1", text: "Assign your categories"
|
|
|
|
click_on "Next"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
assert_selector "h1", text: "Assign your tags"
|
|
|
|
click_on "Next"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
assert_selector "h1", text: "Assign your accounts"
|
|
|
|
click_on "Next"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Publish import"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
assert_text "Import in progress"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
perform_enqueued_jobs
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Check status"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
assert_text "Import successful"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Back to dashboard"
|
|
|
|
end
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
test "trade import" do
|
|
|
|
visit new_import_path
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Import investments"
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2025-04-18 18:53:10 +05:30
|
|
|
find("button[data-id='csv-paste-tab']").click
|
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
fill_in "import[raw_file_str]", with: file_fixture("imports/trades.csv").read
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
find('input[type="submit"][value="Upload CSV"]').click
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2025-04-18 10:48:10 -04:00
|
|
|
select "date", from: "import[date_col_label]"
|
|
|
|
select "YYYY-MM-DD", from: "import[date_format]"
|
|
|
|
select "qty", from: "import[qty_col_label]"
|
|
|
|
select "ticker", from: "import[ticker_col_label]"
|
|
|
|
select "price", from: "import[price_col_label]"
|
|
|
|
select "account", from: "import[account_col_label]"
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Apply configuration"
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Next step"
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
assert_selector "h1", text: "Assign your accounts"
|
|
|
|
click_on "Next"
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Publish import"
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
assert_text "Import in progress"
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
perform_enqueued_jobs
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Check status"
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
assert_text "Import successful"
|
|
|
|
|
|
|
|
click_on "Back to dashboard"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "account import" do
|
|
|
|
visit new_import_path
|
|
|
|
|
|
|
|
click_on "Import accounts"
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2025-04-18 18:53:10 +05:30
|
|
|
find("button[data-id='csv-paste-tab']").click
|
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
fill_in "import[raw_file_str]", with: file_fixture("imports/accounts.csv").read
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
find('input[type="submit"][value="Upload CSV"]').click
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2025-04-18 10:48:10 -04:00
|
|
|
select "type", from: "import[entity_type_col_label]"
|
|
|
|
select "name", from: "import[name_col_label]"
|
|
|
|
select "amount", from: "import[amount_col_label]"
|
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Apply configuration"
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Next step"
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
assert_selector "h1", text: "Assign your account types"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
all("form").each do |form|
|
|
|
|
within(form) do
|
|
|
|
select = form.find("select")
|
|
|
|
select "Depository", from: select["id"]
|
2024-10-21 11:13:55 -03:00
|
|
|
sleep 0.5
|
2024-10-01 10:47:59 -04:00
|
|
|
end
|
2024-05-17 09:09:32 -04:00
|
|
|
end
|
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Next"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Publish import"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
assert_text "Import in progress"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
perform_enqueued_jobs
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Check status"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
assert_text "Import successful"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Back to dashboard"
|
2024-05-17 09:09:32 -04:00
|
|
|
end
|
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
test "mint import" do
|
|
|
|
visit new_import_path
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
click_on "Import from Mint"
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2025-04-18 18:53:10 +05:30
|
|
|
find("button[data-id='csv-paste-tab']").click
|
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
fill_in "import[raw_file_str]", with: file_fixture("imports/mint.csv").read
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
find('input[type="submit"][value="Upload CSV"]').click
|
|
|
|
|
|
|
|
click_on "Apply configuration"
|
|
|
|
|
|
|
|
click_on "Next step"
|
|
|
|
|
|
|
|
assert_selector "h1", text: "Assign your categories"
|
|
|
|
click_on "Next"
|
|
|
|
|
|
|
|
assert_selector "h1", text: "Assign your tags"
|
|
|
|
click_on "Next"
|
|
|
|
|
|
|
|
assert_selector "h1", text: "Assign your accounts"
|
|
|
|
click_on "Next"
|
|
|
|
|
|
|
|
click_on "Publish import"
|
|
|
|
|
|
|
|
assert_text "Import in progress"
|
|
|
|
|
|
|
|
perform_enqueued_jobs
|
|
|
|
|
|
|
|
click_on "Check status"
|
|
|
|
|
|
|
|
assert_text "Import successful"
|
|
|
|
|
|
|
|
click_on "Back to dashboard"
|
|
|
|
end
|
2024-05-17 09:09:32 -04:00
|
|
|
end
|