2024-04-18 07:56:51 -04:00
|
|
|
require "application_system_test_case"
|
|
|
|
|
|
|
|
class SettingsTest < ApplicationSystemTestCase
|
|
|
|
setup do
|
|
|
|
sign_in @user = users(:family_admin)
|
|
|
|
|
|
|
|
@settings_links = [
|
2024-08-27 17:10:31 -04:00
|
|
|
[ "Account", settings_profile_path ],
|
|
|
|
[ "Preferences", settings_preferences_path ],
|
|
|
|
[ "Accounts", accounts_path ],
|
|
|
|
[ "Tags", tags_path ],
|
|
|
|
[ "Categories", categories_path ],
|
|
|
|
[ "Merchants", merchants_path ],
|
|
|
|
[ "Imports", imports_path ],
|
|
|
|
[ "What's new", changelog_path ],
|
|
|
|
[ "Feedback", feedback_path ]
|
2024-04-18 07:56:51 -04:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
test "can access settings from sidebar" do
|
2024-09-09 16:54:56 -04:00
|
|
|
VCR.use_cassette("git_repository_provider/fetch_latest_release_notes") do
|
|
|
|
open_settings_from_sidebar
|
|
|
|
assert_selector "h1", text: "Account"
|
2024-10-01 02:58:15 +05:30
|
|
|
assert_current_path settings_profile_path, ignore_query: true
|
2024-08-27 17:10:31 -04:00
|
|
|
|
2024-09-09 16:54:56 -04:00
|
|
|
@settings_links.each do |name, path|
|
|
|
|
click_link name
|
|
|
|
assert_selector "h1", text: name
|
|
|
|
assert_current_path path
|
|
|
|
end
|
2024-08-27 17:10:31 -04:00
|
|
|
end
|
2024-04-18 07:56:51 -04:00
|
|
|
end
|
|
|
|
|
2024-09-11 19:04:39 +02:00
|
|
|
test "can update self hosting settings" do
|
|
|
|
Rails.application.config.app_mode.stubs(:self_hosted?).returns(true)
|
2025-03-17 11:54:53 -04:00
|
|
|
Providers.stubs(:synth).returns(nil)
|
2024-09-11 19:04:39 +02:00
|
|
|
open_settings_from_sidebar
|
|
|
|
assert_selector "li", text: "Self hosting"
|
|
|
|
click_link "Self hosting"
|
|
|
|
assert_current_path settings_hosting_path
|
|
|
|
assert_selector "h1", text: "Self-Hosting"
|
|
|
|
check "setting_require_invite_for_signup", allow_label_click: true
|
|
|
|
click_button "Generate new code"
|
|
|
|
assert_selector 'span[data-clipboard-target="source"]', visible: true, count: 1 # invite code copy widget
|
|
|
|
copy_button = find('button[data-action="clipboard#copy"]', match: :first) # Find the first copy button (adjust if needed)
|
|
|
|
copy_button.click
|
|
|
|
assert_selector 'span[data-clipboard-target="iconSuccess"]', visible: true, count: 1 # text copied and icon changed to checkmark
|
|
|
|
end
|
|
|
|
|
2025-02-28 15:35:00 +01:00
|
|
|
test "does not show billing link if self hosting" do
|
|
|
|
Rails.application.config.app_mode.stubs(:self_hosted?).returns(true)
|
|
|
|
open_settings_from_sidebar
|
|
|
|
assert_no_selector "li", text: I18n.t("settings.settings_nav.billing_label")
|
|
|
|
end
|
|
|
|
|
2024-04-18 07:56:51 -04:00
|
|
|
private
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-04-18 07:56:51 -04:00
|
|
|
def open_settings_from_sidebar
|
|
|
|
find("#user-menu").click
|
|
|
|
click_link "Settings"
|
|
|
|
end
|
|
|
|
end
|