Skip to content

Commit

Permalink
Normalize bc keys (#3867)
Browse files Browse the repository at this point in the history
Downcase batch connect ids so dynamic directives can work with capitalized
directives.
  • Loading branch information
johrstrom authored Oct 15, 2024
1 parent f04f477 commit af498f3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/dashboard/app/lib/smart_attributes/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Attribute
# @param id [#to_s] id of attribute
# @param opts [#to_h] options for attribute
def initialize(id, opts = {})
@id = id.to_s
@id = id.to_s.downcase
@opts = opts.to_h.symbolize_keys
end

Expand Down
32 changes: 32 additions & 0 deletions apps/dashboard/test/system/batch_connect_widgets_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,36 @@ def make_bc_app(dir, form)
assert_equal('Global Queues', label.text)
end
end

test 'forms correctly deal with capitalized ids' do
Dir.mktmpdir do |dir|
form = <<~HEREDOC
---
form:
- switcher
- Eastern_City
- Western_City
attributes:
switcher:
widget: 'select'
options:
- ["east", data-hide-Western-City: true]
- ["west", data-hide-Eastern-City: true]
HEREDOC

make_bc_app(dir, form)

visit(new_batch_connect_session_context_url('sys/app'))

# select east, and west is no longer visible. Also note that the id is lowercase.
select('east', from: bc_ele_id('switcher'))
assert(find("##{bc_ele_id('eastern_city')}").visible?)
refute(find("##{bc_ele_id('western_city')}", visible: false).visible?)

# select west, and now ease is no longer visible
select('west', from: bc_ele_id('switcher'))
assert(find("##{bc_ele_id('western_city')}").visible?)
refute(find("##{bc_ele_id('eastern_city')}", visible: false).visible?)
end
end
end

0 comments on commit af498f3

Please sign in to comment.