From a9569326c1e51967f47b670f3163b307a5fab437 Mon Sep 17 00:00:00 2001 From: HazelGrant Date: Thu, 19 Dec 2024 13:20:47 -0500 Subject: [PATCH] Small refactor to match code style & additional assertions to test minor details of option-for-* directives --- apps/dashboard/app/javascript/dynamic_forms.js | 3 +-- .../test/system/batch_connect_widgets_test.rb | 14 +++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/dashboard/app/javascript/dynamic_forms.js b/apps/dashboard/app/javascript/dynamic_forms.js index 17ba700e5..f989a9c85 100644 --- a/apps/dashboard/app/javascript/dynamic_forms.js +++ b/apps/dashboard/app/javascript/dynamic_forms.js @@ -780,8 +780,7 @@ function sharedToggleOptionsFor(_event, elementId, contextStr) { if (contextStr == 'optionFor') { hide = option.dataset[`optionFor${optionFor}${optionForValue}`] === 'false'; } else if (contextStr == 'exclusiveOptionFor') { - const exclusiveForCluster = option.dataset[`exclusiveOptionFor${optionFor}${optionForValue}`]; - hide = !(exclusiveForCluster === 'true') + hide = !(option.dataset[`exclusiveOptionFor${optionFor}${optionForValue}`] === 'true') } if (hide) { diff --git a/apps/dashboard/test/system/batch_connect_widgets_test.rb b/apps/dashboard/test/system/batch_connect_widgets_test.rb index 191ce8ce8..e4ccd27e8 100644 --- a/apps/dashboard/test/system/batch_connect_widgets_test.rb +++ b/apps/dashboard/test/system/batch_connect_widgets_test.rb @@ -432,7 +432,7 @@ def make_bc_app(dir, form) end end - test 'data-options-for-*' do + test 'data-options-for-' do Dir.mktmpdir do |dir| "#{dir}/app".tap { |d| Dir.mkdir(d) } SysRouter.stubs(:base_path).returns(Pathname.new(dir)) @@ -470,6 +470,9 @@ def make_bc_app(dir, form) assert_equal "standard", options[0]["innerHTML"] assert_equal "gpu", options[1]["innerHTML"] + # select gpu, to test that it's deselected properly when pitzer is selected + select('gpu', from: 'batch_connect_session_context_node_type') + # pitzer is selected, gpu is not visible select('pitzer', from: 'batch_connect_session_context_cluster') options = find_all("#batch_connect_session_context_node_type option") @@ -478,6 +481,9 @@ def make_bc_app(dir, form) assert_equal "standard", options[0]["innerHTML"] assert_equal display_property, options[1].style('display') + + # value of node_type has gone back to standard + assert_equal 'standard', find('#batch_connect_session_context_node_type').value end end @@ -521,6 +527,9 @@ def make_bc_app(dir, form) assert_equal "standard", options[0]["innerHTML"] assert_equal display_property, options[1].style('display') + # select gpu, to test that it's deselected properly when pitzer is selected + select('gpu', from: 'batch_connect_session_context_node_type') + # pitzer is selected, gpu is not visible select('pitzer', from: 'batch_connect_session_context_cluster') options = find_all("#batch_connect_session_context_node_type option") @@ -529,6 +538,9 @@ def make_bc_app(dir, form) assert_equal "standard", options[0]["innerHTML"] assert_equal display_property, options[1].style('display') + + # value of node_type has gone back to standard + assert_equal 'standard', find('#batch_connect_session_context_node_type').value end end end