mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 07:39:39 +02:00
Sync notifications and troubleshooting guides (#998)
* Add help articles * Broadcast sync messages as notifications * Lint fixes * more lint fixes * Remove redundant code
This commit is contained in:
parent
b200b71284
commit
fa08f027c7
33 changed files with 256 additions and 97 deletions
|
@ -69,7 +69,7 @@ class Account::EntriesControllerTest < ActionDispatch::IntegrationTest
|
|||
}
|
||||
end
|
||||
|
||||
assert_equal "Date has already been taken", flash[:error]
|
||||
assert_equal "Date has already been taken", flash[:alert]
|
||||
assert_redirected_to account_path(@valuation.account)
|
||||
end
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
|
|||
|
||||
test "can sync an account" do
|
||||
post sync_account_path(@account)
|
||||
assert_redirected_to account_url(@account)
|
||||
assert_response :no_content
|
||||
end
|
||||
|
||||
test "can sync all accounts" do
|
||||
|
|
18
test/controllers/help/articles_controller_test.rb
Normal file
18
test/controllers/help/articles_controller_test.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require "test_helper"
|
||||
|
||||
class Help::ArticlesControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in @user = users(:family_admin)
|
||||
|
||||
@article = Help::Article.new(frontmatter: { title: "Test Article", slug: "test-article" }, content: "")
|
||||
|
||||
Help::Article.stubs(:find).returns(@article)
|
||||
end
|
||||
|
||||
test "can view help article" do
|
||||
get help_article_path(@article)
|
||||
|
||||
assert_response :success
|
||||
assert_dom "h1", text: @article.title, count: 1
|
||||
end
|
||||
end
|
|
@ -81,7 +81,7 @@ class ImportsControllerTest < ActionDispatch::IntegrationTest
|
|||
patch load_import_url(@empty_import), params: { import: { raw_csv_str: malformed_csv_str } }
|
||||
|
||||
assert_response :unprocessable_entity
|
||||
assert_equal "Raw csv str is not a valid CSV format", flash[:error]
|
||||
assert_equal "Raw csv str is not a valid CSV format", flash[:alert]
|
||||
end
|
||||
|
||||
test "should flash error message if invalid CSV file upload" do
|
||||
|
@ -91,14 +91,14 @@ class ImportsControllerTest < ActionDispatch::IntegrationTest
|
|||
|
||||
patch upload_import_url(@empty_import), params: { import: { raw_csv_str: Rack::Test::UploadedFile.new(temp, ".csv") } }
|
||||
assert_response :unprocessable_entity
|
||||
assert_equal "Raw csv str is not a valid CSV format", flash[:error]
|
||||
assert_equal "Raw csv str is not a valid CSV format", flash[:alert]
|
||||
end
|
||||
end
|
||||
|
||||
test "should flash error message if no fileprovided for upload" do
|
||||
patch upload_import_url(@empty_import), params: { import: { raw_csv_str: nil } }
|
||||
assert_response :unprocessable_entity
|
||||
assert_equal "Please select a file to upload", flash[:error]
|
||||
assert_equal "Please select a file to upload", flash[:alert]
|
||||
end
|
||||
|
||||
test "should get configure" do
|
||||
|
|
|
@ -76,7 +76,7 @@ class Settings::HostingsControllerTest < ActionDispatch::IntegrationTest
|
|||
|
||||
post send_test_email_settings_hosting_path
|
||||
assert_response :unprocessable_entity
|
||||
assert controller.flash[:error].present?
|
||||
assert controller.flash[:alert].present?
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -87,7 +87,7 @@ class Settings::HostingsControllerTest < ActionDispatch::IntegrationTest
|
|||
|
||||
post send_test_email_settings_hosting_path
|
||||
assert_response :unprocessable_entity
|
||||
assert controller.flash[:error].present?
|
||||
assert controller.flash[:alert].present?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
6
test/fixtures/files/help_article.md
vendored
Normal file
6
test/fixtures/files/help_article.md
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
title: Placeholder
|
||||
slug: placeholder
|
||||
---
|
||||
|
||||
Test help article
|
|
@ -26,9 +26,15 @@ class Account::SyncTest < ActiveSupport::TestCase
|
|||
|
||||
@sync.run
|
||||
|
||||
streams = capture_turbo_stream_broadcasts [ @account.family, :notifications ]
|
||||
|
||||
assert_equal "completed", @sync.status
|
||||
assert_equal [ "test balance sync warning", "test holding sync warning" ], @sync.warnings
|
||||
assert @sync.last_ran_at
|
||||
|
||||
assert_equal "append", streams.first["action"]
|
||||
assert_equal "remove", streams.second["action"]
|
||||
assert_equal "append", streams.third["action"]
|
||||
end
|
||||
|
||||
test "handles sync errors" do
|
||||
|
|
21
test/models/help/article_test.rb
Normal file
21
test/models/help/article_test.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require "test_helper"
|
||||
|
||||
class Help::ArticleTest < ActiveSupport::TestCase
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
setup do
|
||||
Help::Article.stubs(:root_path).returns(Rails.root.join("test", "fixtures", "files"))
|
||||
end
|
||||
|
||||
test "returns nil if article not found" do
|
||||
assert_nil Help::Article.find("missing")
|
||||
end
|
||||
|
||||
test "find and renders markdown article" do
|
||||
article = Help::Article.find("placeholder")
|
||||
|
||||
assert_equal "Placeholder", article.title
|
||||
assert_equal "Test help article", article.content
|
||||
assert_equal "<p>Test help article</p>\n", article.html
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue