From 5b2ef2708980f596b6c6ac3e860f1e0aea378505 Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Tue, 10 Mar 2026 13:46:21 -0400 Subject: [PATCH 1/4] use longest match instead of endsWith --- apps/dashboard/app/javascript/dynamic_forms.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/dashboard/app/javascript/dynamic_forms.js b/apps/dashboard/app/javascript/dynamic_forms.js index c9012f35d4..9a76c89303 100644 --- a/apps/dashboard/app/javascript/dynamic_forms.js +++ b/apps/dashboard/app/javascript/dynamic_forms.js @@ -771,12 +771,10 @@ function idFromToken(str) { // you matched multiple things. For example you're searching for // ClusterFilesystem and matched against both 'Cluster' and 'ClusterFilesystem'. - // The correrct element id ends with cluster_filesystem. + // The correrct element id is the longer one. } else if(elements.length > 1) { - const snake_case_str = snakeCaseWords(str); - return elements.filter((element) => { - return element.endsWith(snake_case_str); - })[0]; + let longest = elements.reduce((a, b) => a.length > b.length ? a : b); + return longest; } } From 61244c1319c91af6a674f835d4190ccbbcc45c9b Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Wed, 27 May 2026 11:25:01 -0400 Subject: [PATCH 2/4] add test case --- .../test/system/batch_connect_test.rb | 70 ++++++++++++++++++- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/apps/dashboard/test/system/batch_connect_test.rb b/apps/dashboard/test/system/batch_connect_test.rb index 9b8d5dd6c3..ae8ba9075d 100644 --- a/apps/dashboard/test/system/batch_connect_test.rb +++ b/apps/dashboard/test/system/batch_connect_test.rb @@ -488,7 +488,7 @@ def stub_good_launch(dir) cache_json.write({ cluster: 'old' }.to_json) end - new_cluster = OodCore::Cluster.new({ id: :new, job: { some: 'job config' } }) + new_cluster = OodCore::cluster.new({ id: :new, job: { some: 'job config' } }) # Only new cluster exists BatchConnect::App.any_instance.stubs(:cfg_to_clusters).returns(new_cluster) @@ -507,8 +507,8 @@ def stub_good_launch(dir) cache_json.write({ cluster: 'old' }.to_json) end - new_cluster = OodCore::Cluster.new({ id: :new, job: { some: 'job config' } }) - old_cluster = OodCore::Cluster.new({ id: :old, job: { some: 'job config ' } }) + new_cluster = OodCore::cluster.new({ id: :new, job: { some: 'job config' } }) + old_cluster = OodCore::cluster.new({ id: :old, job: { some: 'job config ' } }) # Both clusters exist, but only new one is valid BatchConnect::App.any_instance.stubs(:cfg_to_clusters).returns(new_cluster) @@ -918,6 +918,70 @@ def check_visibility(hidden_id, expect_hidden) data_hide_checkbox_test(form, 'checkbox_test', 'gpus', true) end + test 'hiding when form element names have a shared prefix' do + form = <<~HEREDOC + --- + cluster: + - owens + form: + - cluster + - cluster_file_system + - checkbox_hide_cluster + - checkbox_hide_cluster_file_system + attributes: + cluster: + widget: 'text_area' + cluster_file_system: + widget: 'text_area' + checkbox_hide_cluster: + widget: 'check_box' + html_options: + data: + hide-cluster-when-checked: true + checkbox_hide_cluster_file_system: + widget: 'check_box' + html_options: + data: + hide-cluster-file-system-when-checked: true + HEREDOC + Dir.mktmpdir do |dir| + "#{dir}/app".tap { |d| Dir.mkdir(d) } + SysRouter.stubs(:base_path).returns(Pathname.new(dir)) + stub_scontrol + stub_sacctmgr + stub_git("#{dir}/app") + + Pathname.new("#{dir}/app/").join('form.yml').write(form) + visit new_batch_connect_session_context_url('sys/app') + + # defaults + refute(find("##{bc_ele_id("checkbox_hide_cluster")}").checked?) + refute(find("##{bc_ele_id("checkbox_hide_cluster_file_system")}").checked?) + check_visibility("cluster", true) + check_visibility("cluster_file_system", true) + + # check the checkbox, and 'cluster' is hidden + check(bc_ele_id("checkbox_hide_cluster")) + check_visibility("cluster", false) + check_visibility("cluster_file_system", true) + + # un-check the checkbox, and 'cluster' is back to being visible + uncheck(bc_ele_id("checkbox_hide_cluster")) + check_visibility("cluster", true) + check_visibility("cluster_file_system", true) + + # check the checkbox, and 'cluster_file_system' is hidden + check(bc_ele_id("checkbox_hide_cluster_file_system")) + check_visibility("cluster", true) + check_visibility("cluster_file_system", false) + + # un-check the checkbox, and 'cluster_file_system' is back to being visible + uncheck(bc_ele_id("checkbox_hide_cluster_file_system")) + check_visibility("cluster", true) + check_visibility("cluster_file_system", true) + end + end + def basic_default_hide_check_hidden(invert = false) if invert assert_selector("##{bc_ele_id('gpus')}") From 1caae02409fa40af5aca622f819f7396340fa7d0 Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Wed, 27 May 2026 11:28:19 -0400 Subject: [PATCH 3/4] revert accidental find/replace --- apps/dashboard/test/system/batch_connect_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/dashboard/test/system/batch_connect_test.rb b/apps/dashboard/test/system/batch_connect_test.rb index ae8ba9075d..7f09a4d8ea 100644 --- a/apps/dashboard/test/system/batch_connect_test.rb +++ b/apps/dashboard/test/system/batch_connect_test.rb @@ -488,7 +488,7 @@ def stub_good_launch(dir) cache_json.write({ cluster: 'old' }.to_json) end - new_cluster = OodCore::cluster.new({ id: :new, job: { some: 'job config' } }) + new_cluster = OodCore::Cluster.new({ id: :new, job: { some: 'job config' } }) # Only new cluster exists BatchConnect::App.any_instance.stubs(:cfg_to_clusters).returns(new_cluster) @@ -507,8 +507,8 @@ def stub_good_launch(dir) cache_json.write({ cluster: 'old' }.to_json) end - new_cluster = OodCore::cluster.new({ id: :new, job: { some: 'job config' } }) - old_cluster = OodCore::cluster.new({ id: :old, job: { some: 'job config ' } }) + new_cluster = OodCore::Cluster.new({ id: :new, job: { some: 'job config' } }) + old_cluster = OodCore::Cluster.new({ id: :old, job: { some: 'job config ' } }) # Both clusters exist, but only new one is valid BatchConnect::App.any_instance.stubs(:cfg_to_clusters).returns(new_cluster) From 8350b7acd55674cd226a8112800d7ac2711f11ba Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Wed, 27 May 2026 11:51:46 -0400 Subject: [PATCH 4/4] flip conditionals --- .../test/system/batch_connect_test.rb | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/dashboard/test/system/batch_connect_test.rb b/apps/dashboard/test/system/batch_connect_test.rb index 7f09a4d8ea..1732efec0d 100644 --- a/apps/dashboard/test/system/batch_connect_test.rb +++ b/apps/dashboard/test/system/batch_connect_test.rb @@ -957,28 +957,28 @@ def check_visibility(hidden_id, expect_hidden) # defaults refute(find("##{bc_ele_id("checkbox_hide_cluster")}").checked?) refute(find("##{bc_ele_id("checkbox_hide_cluster_file_system")}").checked?) - check_visibility("cluster", true) - check_visibility("cluster_file_system", true) + check_visibility("cluster", false) + check_visibility("cluster_file_system", false) # check the checkbox, and 'cluster' is hidden check(bc_ele_id("checkbox_hide_cluster")) - check_visibility("cluster", false) - check_visibility("cluster_file_system", true) + check_visibility("cluster", true) + check_visibility("cluster_file_system", false) # un-check the checkbox, and 'cluster' is back to being visible uncheck(bc_ele_id("checkbox_hide_cluster")) - check_visibility("cluster", true) - check_visibility("cluster_file_system", true) + check_visibility("cluster", false) + check_visibility("cluster_file_system", false) # check the checkbox, and 'cluster_file_system' is hidden check(bc_ele_id("checkbox_hide_cluster_file_system")) - check_visibility("cluster", true) - check_visibility("cluster_file_system", false) + check_visibility("cluster", false) + check_visibility("cluster_file_system", true) # un-check the checkbox, and 'cluster_file_system' is back to being visible uncheck(bc_ele_id("checkbox_hide_cluster_file_system")) - check_visibility("cluster", true) - check_visibility("cluster_file_system", true) + check_visibility("cluster", false) + check_visibility("cluster_file_system", false) end end