Fixed issue #2206 and #2207 by limiting historical_options to only select attributes

This commit is contained in:
Billy Zhou 2018-08-23 15:44:32 +08:00
parent fddc165d86
commit 9be7269646
3 changed files with 104 additions and 12 deletions

View file

@ -621,7 +621,7 @@ to send no browser reload event, pass false
# config changes # config changes
if attribute.to_config if attribute.to_config
execute_config_count += 1 execute_config_count += 1
if attribute.data_option[:options] if attribute.data_type == 'select' && attribute.data_option[:options]
historical_options = attribute.data_option[:historical_options] || {} historical_options = attribute.data_option[:historical_options] || {}
historical_options.update(attribute.data_option[:options]) historical_options.update(attribute.data_option[:options])
historical_options.update(attribute.data_option_new[:options]) historical_options.update(attribute.data_option_new[:options])
@ -634,7 +634,7 @@ to send no browser reload event, pass false
next if !attribute.to_create && !attribute.to_migrate && !attribute.to_delete next if !attribute.to_create && !attribute.to_migrate && !attribute.to_delete
end end
if attribute.data_option[:options] if attribute.data_type == 'select' && attribute.data_option[:options]
attribute.data_option[:historical_options] = attribute.data_option[:options] attribute.data_option[:historical_options] = attribute.data_option[:options]
end end

View file

@ -116,4 +116,94 @@ class AdminObjectManagerTreeSelectTest < TestCase
) )
end end
# verify the fix for issue #2206 - Unable to modify tree_select attributes with fresh 2.6
def test_modify_tree_select_attributes
@browser = instance = browser_instance
login(
username: 'master@example.com',
password: 'test',
url: browser_url,
)
tasks_close_all()
object_manager_attribute_create(
data: {
name: 'browser_test_tree_select2',
display: 'Browser Test TreeSelect2',
data_type: 'Tree Select',
data_option: {
options: {
'Incident' => {
'Hardware' => {
'Monitor' => {},
'Mouse' => {},
},
},
'Service request' => {
'New software requirement' => {},
'New hardware' => {},
},
'Change request' => {},
},
},
},
)
object_manager_attribute_migrate
# open the newly created tree_select and add some new options
object_manager_attribute_update(
data: {
name: 'browser_test_tree_select2',
},
do_not_submit: true,
)
# add two new first level entries
2.times do |i|
instance.find_elements(css: '.modal .js-treeTable .js-key').last.click
element = instance.find_elements(css: '.modal .js-treeTable .js-key').last
element.clear
element.send_keys("new tree option #{i}")
end
click(
css: '.modal button.js-submit'
)
modal_disappear
object_manager_attribute_migrate
# open the tree select again and check that the newly added options are there
watch_for(
css: '.content.active table',
value: 'browser_test_tree_select2',
)
object_manager_attribute_update(
data: {
name: 'browser_test_tree_select2',
},
do_not_submit: true,
)
2.times do |i|
exists(
css: '.modal .js-treeTable',
value: "new tree option #{i}",
)
end
modal_close
# clean up and confirm the deletion of newly created attributes
object_manager_attribute_delete(
data: {
name: 'browser_test_tree_select2',
},
)
object_manager_attribute_migrate
match_not(
css: '.content.active table',
value: 'browser_test_tree_select2',
)
end
end end

View file

@ -4196,17 +4196,19 @@ wait untill text in selector disabppears
options: data[:data_option][:options], options: data[:data_option][:options],
) )
else else
# first clear all existing entries if action == 'update'
loop do # first clear all existing entries
target = { loop do
browser: instance, target = {
css: '.modal .js-Table .js-remove', browser: instance,
mute_log: true, css: '.modal .js-Table .js-remove',
} mute_log: true,
break if !instance.find_elements(css: target[:css])[0] }
click(target) break if !instance.find_elements(css: target[:css])[0]
click(target)
end
sleep 1
end end
sleep 1
# then populate the table with the new values # then populate the table with the new values
data[:data_option][:options].each do |key, value| data[:data_option][:options].each do |key, value|