Files
sure/test/system/settings_test.rb
Juan José Mata 72e7d7736b Add onboarding state selector for self-hosted signup (#251)
* Add onboarding modes to self-hosted signup

* Style form consistently

* Configure ONBOARDING_STATE via ENV
2025-10-27 21:52:37 +01:00

73 lines
2.6 KiB
Ruby

require "application_system_test_case"
class SettingsTest < ApplicationSystemTestCase
setup do
sign_in @user = users(:family_admin)
@settings_links = [
[ "Accounts", accounts_path ],
[ "Bank Sync", settings_bank_sync_path ],
[ "Preferences", settings_preferences_path ],
[ "Profile Info", settings_profile_path ],
[ "Security", settings_security_path ],
[ "Categories", categories_path ],
[ "Tags", tags_path ],
[ "Rules", rules_path ],
[ "Merchants", family_merchants_path ],
[ "AI Prompts", settings_ai_prompts_path ],
[ "API Key", settings_api_key_path ],
[ "Guides", settings_guides_path ],
[ "What's new", changelog_path ],
[ "Feedback", feedback_path ]
]
end
test "can access settings from sidebar" do
VCR.use_cassette("git_repository_provider/fetch_latest_release_notes") do
open_settings_from_sidebar
assert_selector "h1", text: "Accounts"
assert_current_path accounts_path, ignore_query: true
@settings_links.each do |name, path|
click_link name
assert_selector "h1", text: name
assert_current_path path
end
end
end
test "can update self hosting settings" do
Rails.application.config.app_mode.stubs(:self_hosted?).returns(true)
Provider::Registry.stubs(:get_provider).with(:twelve_data).returns(nil)
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"
find("select#setting_onboarding_state").select("Invite-only")
within("select#setting_onboarding_state") do
assert_selector "option[selected]", text: "Invite-only"
end
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
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
private
def open_settings_from_sidebar
within "div[data-testid=user-menu]" do
find("button").click
end
click_link "Settings"
end
end