1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-02 20:15:22 +02:00

New Settings Menu, Routes and Controllers Organization (#641)

* Add new settings routes and controllers

* Add new settings view, restructure controllers and routes

* Fix lint errors
This commit is contained in:
Zach Gollwitzer 2024-04-18 07:56:51 -04:00 committed by GitHub
parent 39d57a167e
commit 9bda7efc3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 771 additions and 203 deletions

View file

@ -12,9 +12,10 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
fill_in "Password", with: "password"
click_button "Log in"
end
assert_text "Dashboard", wait: 5
find('[data-controller="menu"]').click
end
def sign_out
find("#user-menu").click
click_button "Logout"
assert_text "Sign in to your account"
end
end

View file

@ -1,6 +1,6 @@
require "test_helper"
class Settings::SelfHostingControllerTest < ActionDispatch::IntegrationTest
class Settings::HostingsControllerTest < ActionDispatch::IntegrationTest
setup do
ENV["SELF_HOSTING_ENABLED"] = "true"
sign_in users(:family_admin)
@ -9,14 +9,14 @@ class Settings::SelfHostingControllerTest < ActionDispatch::IntegrationTest
test "cannot edit when self hosting is disabled" do
ENV["SELF_HOSTING_ENABLED"] = "false"
get edit_settings_self_hosting_url
get settings_hosting_url
assert :not_found
patch settings_self_hosting_url, params: { setting: { render_deploy_hook: "https://example.com" } }
patch settings_hosting_url, params: { setting: { render_deploy_hook: "https://example.com" } }
assert :not_found
end
test "should get edit when self hosting is enabled" do
get edit_settings_self_hosting_url
get settings_hosting_url
assert_response :success
end
@ -24,7 +24,7 @@ class Settings::SelfHostingControllerTest < ActionDispatch::IntegrationTest
NEW_RENDER_DEPLOY_HOOK = "https://api.render.com/deploy/srv-abc123"
assert_nil Setting.render_deploy_hook
patch settings_self_hosting_url, params: { setting: { render_deploy_hook: NEW_RENDER_DEPLOY_HOOK } }
patch settings_hosting_url, params: { setting: { render_deploy_hook: NEW_RENDER_DEPLOY_HOOK } }
assert_equal NEW_RENDER_DEPLOY_HOOK, Setting.render_deploy_hook
end

View file

@ -0,0 +1,11 @@
require "test_helper"
class Settings::NotificationsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in users(:family_admin)
end
test "get" do
get settings_notifications_url
assert_response :success
end
end

View file

@ -0,0 +1,11 @@
require "test_helper"
class Settings::PreferencesControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in users(:family_admin)
end
test "get" do
get settings_preferences_url
assert_response :success
end
end

View file

@ -0,0 +1,11 @@
require "test_helper"
class Settings::ProfilesControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in @user = users(:family_admin)
end
test "get" do
get settings_profile_url
assert_response :success
end
end

View file

@ -0,0 +1,11 @@
require "test_helper"
class Settings::SecuritiesControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in users(:family_admin)
end
test "get" do
get settings_security_url
assert_response :success
end
end

View file

@ -1,20 +0,0 @@
require "application_system_test_case"
class AccountsTest < ApplicationSystemTestCase
setup do
sign_in @user = users(:family_admin)
end
test "should create account" do
skip("Disabling this test for now, UI is changing to quickly to do systems testing")
click_on "New account"
click_on "Credit Card"
within "form" do
fill_in "Name", with: "VISA"
fill_in "Balance", with: "1000"
click_on "Submit"
end
assert_text "$1,000"
end
end

View file

@ -0,0 +1,66 @@
require "application_system_test_case"
class SettingsTest < ApplicationSystemTestCase
setup do
sign_in @user = users(:family_admin)
@settings_links = [
[ "Account", "Account", settings_profile_path ],
[ "Preferences", "Preferences", settings_preferences_path ],
[ "Notifications", "Notifications", settings_notifications_path ],
[ "Security", "Security", settings_security_path ],
[ "Billing", "Billing", settings_billing_path ],
[ "Accounts", "Accounts", accounts_path ],
[ "Categories", "Categories", transactions_categories_path ],
[ "Merchants", "Merchants", transactions_merchants_path ],
[ "Rules", "Rules", transactions_rules_path ],
[ "What's New", "What's New", changelog_path ],
[ "Feedback", "Feedback", feedback_path ],
[ "Invite friends", "Invite friends", invites_path ]
]
end
test "can access settings from sidebar" do
open_settings_from_sidebar
assert_selector "h1", text: "Account"
assert_current_path settings_profile_path
end
test "all settings views and links are accessible" do
open_settings_from_sidebar
@settings_links.each_with_index do |(link_text, header_text, path), index|
next_setting_path = @settings_links[index + 1][2] if index < @settings_links.size - 1
prev_setting_path = @settings_links[index - 1][2] if index > 0
find_link(link_text, exact: true).click
assert_selector "h1", text: header_text
assert_current_path path
assert_link "Next", href: next_setting_path if next_setting_path.present?
assert_link "Back", href: prev_setting_path if prev_setting_path.present?
end
# Conditional nav items don't show by default
assert_no_text "Self Hosting"
end
test "can see conditional nav items" do
ENV["SELF_HOSTING_ENABLED"] = "true"
open_settings_from_sidebar
click_link "Self Hosting"
assert_selector "h1", text: "Self Hosting"
end
test "clicking back or hitting escape key takes user back page they opened settings from" do
# TODO: Implement test for back navigation and escape key functionality.
end
private
def open_settings_from_sidebar
find("#user-menu").click
click_link "Settings"
end
end

View file

@ -1,3 +1,7 @@
# Require individual test files to enable these as needed
ENV["SELF_HOSTING_ENABLED"] = "false"
ENV["UPGRADES_ENABLED"] = "false"
ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rails/test_help"