From aa7dd550726899075fe36782c348ee6e00a7614a Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Fri, 11 Oct 2024 17:04:08 -0400 Subject: [PATCH 1/2] downcase bc ids so dynamic directives work --- apps/dashboard/app/lib/smart_attributes/attribute.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dashboard/app/lib/smart_attributes/attribute.rb b/apps/dashboard/app/lib/smart_attributes/attribute.rb index 735bcf53d0..ec39b9a313 100644 --- a/apps/dashboard/app/lib/smart_attributes/attribute.rb +++ b/apps/dashboard/app/lib/smart_attributes/attribute.rb @@ -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 From 8a33b72565951133f80270b5a94729b8a89000b8 Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Fri, 11 Oct 2024 17:04:21 -0400 Subject: [PATCH 2/2] add a test case for this --- .../test/system/batch_connect_widgets_test.rb | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/apps/dashboard/test/system/batch_connect_widgets_test.rb b/apps/dashboard/test/system/batch_connect_widgets_test.rb index b7e3cf4bd4..d7f73e55e1 100644 --- a/apps/dashboard/test/system/batch_connect_widgets_test.rb +++ b/apps/dashboard/test/system/batch_connect_widgets_test.rb @@ -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