Skip to content

Commit

Permalink
Small refactor to match code style & additional assertions to test mi…
Browse files Browse the repository at this point in the history
…nor details of option-for-* directives
  • Loading branch information
HazelGrant committed Dec 19, 2024
1 parent 3079c85 commit a956932
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 1 addition & 2 deletions apps/dashboard/app/javascript/dynamic_forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 13 additions & 1 deletion apps/dashboard/test/system/batch_connect_widgets_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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")
Expand All @@ -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

Expand Down Expand Up @@ -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")
Expand All @@ -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

0 comments on commit a956932

Please sign in to comment.