From d554aec6d39564a182058c3f653198fea955e3e0 Mon Sep 17 00:00:00 2001 From: HazelGrant Date: Tue, 9 Apr 2024 09:47:35 -0400 Subject: [PATCH] Removes NavConfig & associated tests --- .../app/models/user_configuration.rb | 7 ++++-- .../integration/dashboard_controller_test.rb | 22 +++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/apps/dashboard/app/models/user_configuration.rb b/apps/dashboard/app/models/user_configuration.rb index be74c9c368..16abc7182a 100644 --- a/apps/dashboard/app/models/user_configuration.rb +++ b/apps/dashboard/app/models/user_configuration.rb @@ -122,14 +122,17 @@ def announcement_path end end + CATEGORIES = ["Apps", "Files", "Jobs", "Clusters", "Interactive Apps"].freeze + CATEGORIES_WHITELIST = false + # Filtering is controlled with NavConfig.categories_allowlist? unless the configuration property categories is defined. # If categories are defined, filter_nav_categories? will always be true. def filter_nav_categories? - fetch(:nav_categories, nil).nil? ? NavConfig.categories_whitelist? : true + fetch(:nav_categories, nil).nil? ? CATEGORIES_WHITELIST : true end def nav_categories - fetch(:nav_categories, nil) || NavConfig.categories + fetch(:nav_categories, nil) || CATEGORIES end # Create support ticket service class based on the configuration diff --git a/apps/dashboard/test/integration/dashboard_controller_test.rb b/apps/dashboard/test/integration/dashboard_controller_test.rb index e5289701cd..e6e3301c51 100644 --- a/apps/dashboard/test/integration/dashboard_controller_test.rb +++ b/apps/dashboard/test/integration/dashboard_controller_test.rb @@ -147,7 +147,7 @@ def teardown assert_response :success assert_select "nav a[href='#{batch_connect_sessions_path}']", 0 end - +=begin test 'should not create app menus if NavConfig.categories is empty and whitelist is enabled' do SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps')) OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d')) @@ -159,7 +159,8 @@ def teardown assert_select dropdown_links, 1 # +1 here is 'Help' assert_select dropdown_link(1), text: 'Help' # ensure is Help end - +=end +=begin test 'should exclude gateway apps if NavConfig.categories is set to default and whitelist is enabled' do SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps')) OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d')) @@ -175,7 +176,8 @@ def teardown assert_select dropdown_link(4), text: 'Interactive Apps' assert_select dropdown_link(5), text: 'Help' end - +=end +=begin test 'uses NavConfig.categories as sort order if whitelist is false' do SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps')) OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d')) @@ -191,12 +193,11 @@ def teardown assert_select dropdown_link(4), text: 'Clusters' assert_select dropdown_link(5), text: 'Gateway Apps' end +=end - test 'UserConfiguration.categories should filter and order the navigation and have precedence over NavConfig' do + test 'UserConfiguration.categories should filter and order the navigation' do SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps')) OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d')) - NavConfig.stubs(:categories_whitelist?).returns(false) - NavConfig.stubs(:categories).returns(['Jobs', 'Interactive Apps', 'Files', 'Clusters']) stub_user_configuration({ nav_categories: ['Files', 'Interactive Apps', 'Clusters'] @@ -213,8 +214,6 @@ def teardown test 'should not create app menus if UserConfiguration.categories is empty' do SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps')) OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d')) - NavConfig.stubs(:categories_whitelist?).returns(false) - NavConfig.stubs(:categories).returns(['Jobs', 'Interactive Apps', 'Files', 'Clusters']) stub_user_configuration({ nav_categories: [] @@ -225,12 +224,13 @@ def teardown assert_select dropdown_links, 1 # +1 here is 'Help' assert_select dropdown_link(1), text: 'Help' # ensure is Help end - +=begin test 'verify default values for NavConfig' do refute NavConfig.categories_whitelist? assert NavConfig end - +=end +=begin test 'display all app menus in alphabetical order if NavConfig.whitelist false & NavConfig.categories nil or []' do SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps')) OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d')) @@ -247,11 +247,11 @@ def teardown assert_select dropdown_link(4), text: 'Interactive Apps' assert_select dropdown_link(5), text: 'Jobs' end +=end test 'apps with no category should not appear in menu' do SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps')) OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d')) - NavConfig.stubs(:categories_whitelist?).returns(false) get root_path