Files
sure/test/system/settings_test.rb
Guillem Arias bf73e3a1e3 refactor(settings/providers): finish design-review cleanup pass
Picks up the remaining items from Claude Design's review of #1710
that the previous review-feedback commit didn't cover.

DS / casing
- Sentence-case the page title ("Bank Sync" -> "Bank sync") and
  align the nav label.
- Drop the card hover-lift (shadow-border-sm) in favour of
  bg-container-hover; per the DS, card hover is colour-only.
- Whole-tile click target on each provider card — the inner
  "Connect ->" link was a hit-target inversion.
- Set Sync all to whitespace-nowrap so the label stops wrapping at
  narrow viewport widths.

UX simplifications
- Drop the four health-summary tiles (per-row warn/err pills already
  surface the signal at the scale this app sees). Removes
  Settings::HealthSummary, the @health_counts controller block, and
  the now-unused health.* locale keys.
- Hide "Your connections" heading + empty-state line when no
  providers are connected — the lede already invites a connect.
- Drop the redundant "Free" tier from per-card meta lines (printed
  10x for one fact); "Paid" still surfaces on Plaid.

Tests updated to drop the obsolete tiles assertion and switch the
provider-card click selector to look up the (now whole-card) anchor
by provider name.
2026-05-09 11:26:55 +02:00

107 lines
3.9 KiB
Ruby

require "application_system_test_case"
class SettingsTest < ApplicationSystemTestCase
setup do
sign_in @user = users(:family_admin)
# Base settings available to all users
@settings_links = [
[ "Accounts", accounts_path ]
]
@settings_links << [ "Bank sync", settings_providers_path ] if @user.admin?
@settings_links += [
[ "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 ],
[ "Guides", settings_guides_path ],
[ "What's new", changelog_path ],
[ "Feedback", feedback_path ]
]
# Add admin settings if user is admin
if @user.admin?
@settings_links += [
[ "AI Prompts", settings_ai_prompts_path ],
[ "API Key", settings_api_key_path ]
]
end
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
sign_in users(:sure_support_staff)
Rails.application.config.app_mode.stubs(:self_hosted?).returns(true)
Provider::Registry.stubs(:get_provider).with(:twelve_data).returns(nil)
Provider::Registry.stubs(:get_provider).with(:yahoo_finance).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)
page.execute_script("Object.defineProperty(navigator, 'clipboard', { value: { writeText: () => Promise.resolve() }, writable: true, configurable: true })") # Mock clipboard API due to browser security restrictions in tests
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 payment 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.payment_label")
end
test "does not show admin settings to non-admin users" do
VCR.use_cassette("git_repository_provider/fetch_latest_release_notes") do
# Visit accounts path directly as non-admin user to avoid user menu issues
visit new_session_path
within %(form[action='#{sessions_path}']) do
fill_in "Email", with: users(:family_member).email
fill_in "Password", with: user_password_test
click_on "Log in"
end
# Go directly to accounts (settings) page
visit accounts_path
# Assert that admin-only settings are not present in the navigation
assert_no_selector "li", text: "AI Prompts"
assert_no_selector "li", text: "API Key"
assert_no_selector "li", text: "Bank sync"
end
end
private
def open_settings_from_sidebar
within "div[data-testid=user-menu]" do
find("button").click
end
click_link "Settings"
end
end