From 73e5638cd45b6bf2e2ac6eaf3e6345f7d72544c8 Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Thu, 31 Oct 2024 09:37:31 -0400 Subject: [PATCH] downcase auto modules so they are dynamic as well (#3905) --- .../attributes/auto_modules.rb | 2 +- .../test/system/batch_connect_widgets_test.rb | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/apps/dashboard/app/lib/smart_attributes/attributes/auto_modules.rb b/apps/dashboard/app/lib/smart_attributes/attributes/auto_modules.rb index 08a7987dba..1b31ade17f 100644 --- a/apps/dashboard/app/lib/smart_attributes/attributes/auto_modules.rb +++ b/apps/dashboard/app/lib/smart_attributes/attributes/auto_modules.rb @@ -53,7 +53,7 @@ def filter_versions? # normalize module names so they can be accessed through methods. # see https://github.com/OSC/ondemand/issues/2933 def normalize_module(module_name) - module_name.to_s.gsub('-', '_') + module_name.to_s.gsub('-', '_').downcase end private diff --git a/apps/dashboard/test/system/batch_connect_widgets_test.rb b/apps/dashboard/test/system/batch_connect_widgets_test.rb index 97e36a640f..ed854d0a1f 100644 --- a/apps/dashboard/test/system/batch_connect_widgets_test.rb +++ b/apps/dashboard/test/system/batch_connect_widgets_test.rb @@ -282,4 +282,38 @@ def make_bc_app(dir, form) assert_equal('Four', find("[for='#{bc_ele_id('vector_four')}']").text) end end + + test 'auto modules something' do + Dir.mktmpdir do |dir| + with_modified_env({ OOD_MODULE_FILE_DIR: 'test/fixtures/modules' }) do + form = <<~HEREDOC + cluster: owens + form: + - auto_modules_R + - module_hider + attributes: + module_hider: + widget: select + options: + - ['show', 'show'] + - ['hide', 'hide', data-hide-auto-modules-r: true] + HEREDOC + + make_bc_app(dir, form) + visit new_batch_connect_session_context_url('sys/app') + + # just to be sure auto_modules_r actually populates with module options + assert_equal(20, find_all_options('auto_modules_r', nil).size) + assert(find("##{bc_ele_id('auto_modules_r')}").visible?) + + # select hide and auto_modules_r isn't visible anymore. + select('hide', from: bc_ele_id('module_hider')) + refute(find("##{bc_ele_id('auto_modules_r')}", visible: :hidden).visible?) + + # select show and it's back. + select('show', from: bc_ele_id('module_hider')) + assert(find("##{bc_ele_id('auto_modules_r')}").visible?) + end + end + end end