Added more tests for object manager.
This commit is contained in:
parent
da754d5d25
commit
eede1267b0
6 changed files with 387 additions and 38 deletions
|
@ -4,5 +4,5 @@ class App.UiElement.integer
|
|||
attribute.type = 'number'
|
||||
attribute.step = '1'
|
||||
item = $( App.view('generic/input')(attribute: attribute) )
|
||||
item.find('select').data('field-type', 'integer')
|
||||
item.data('field-type', 'integer')
|
||||
item
|
|
@ -110,8 +110,22 @@ class ObjectManagerAttributesController < ApplicationController
|
|||
private
|
||||
|
||||
def check_params
|
||||
if params[:data_type] =~ /^(boolean)$/
|
||||
if params[:data_option][:options]
|
||||
if params[:data_option][:options][:false]
|
||||
params[:data_option][:options][false] = params[:data_option][:options][:false]
|
||||
params[:data_option][:options].delete(:false)
|
||||
end
|
||||
if params[:data_option][:options][:true]
|
||||
params[:data_option][:options][true] = params[:data_option][:options][:true]
|
||||
params[:data_option][:options].delete(:true)
|
||||
end
|
||||
end
|
||||
end
|
||||
if params[:data_option] && !params[:data_option].key?(:default)
|
||||
params[:data_option][:default] = ''
|
||||
params[:data_option][:default] = if params[:data_type] =~ /^(input|select)$/
|
||||
''
|
||||
end
|
||||
end
|
||||
return if !params[:data_option][:null].nil?
|
||||
params[:data_option][:null] = true
|
||||
|
|
|
@ -23,7 +23,7 @@ list of all attributes
|
|||
=end
|
||||
|
||||
def self.list_full
|
||||
result = ObjectManager::Attribute.all
|
||||
result = ObjectManager::Attribute.all.order('position ASC, name ASC')
|
||||
attributes = []
|
||||
assets = {}
|
||||
result.each {|item|
|
||||
|
@ -354,7 +354,7 @@ returns:
|
|||
active: true,
|
||||
to_create: false,
|
||||
to_delete: false,
|
||||
).order('position ASC')
|
||||
).order('position ASC, name ASC')
|
||||
attributes = []
|
||||
result.each {|item|
|
||||
data = {
|
||||
|
@ -534,7 +534,7 @@ to send no browser reload event, pass false
|
|||
attribute.name,
|
||||
data_type,
|
||||
default: attribute.data_option[:default],
|
||||
null: false
|
||||
null: true
|
||||
)
|
||||
else
|
||||
raise "Unknown attribute.data_type '#{attribute.data_type}', can't update attribute"
|
||||
|
@ -571,7 +571,7 @@ to send no browser reload event, pass false
|
|||
attribute.name,
|
||||
data_type,
|
||||
default: attribute.data_option[:default],
|
||||
null: false
|
||||
null: true
|
||||
)
|
||||
elsif attribute.data_type =~ /^datetime|date$/
|
||||
ActiveRecord::Migration.add_column(
|
||||
|
@ -623,7 +623,7 @@ to send no browser reload event, pass false
|
|||
raise 'Only letters from a-z, numbers from 0-9, and _ are allowed'
|
||||
elsif name !~ /[a-z]/
|
||||
raise 'At least one letters is needed'
|
||||
elsif name =~ /^(destroy|true|false|integer|select|drop|create|alter|index|table)$/
|
||||
elsif name =~ /^(destroy|true|false|integer|select|drop|create|alter|index|table|varchar|blob|date|datetime|timestamp)$/
|
||||
raise "#{name} is a reserved word, please choose a different one"
|
||||
end
|
||||
true
|
||||
|
@ -665,7 +665,7 @@ to send no browser reload event, pass false
|
|||
end
|
||||
|
||||
if data_type == 'select' || data_type == 'checkbox'
|
||||
raise 'Need data_option[:default] param' if data_option[:default].nil?
|
||||
raise 'Need data_option[:default] param' if !data_option.key?(:default)
|
||||
raise 'Invalid data_option[:options] or data_option[:relation] param' if data_option[:options].nil? && data_option[:relation].nil?
|
||||
if !data_option.key?(:nulloption)
|
||||
data_option[:nulloption] = true
|
||||
|
@ -673,7 +673,7 @@ to send no browser reload event, pass false
|
|||
end
|
||||
|
||||
if data_type == 'boolean'
|
||||
raise 'Need data_option[:default] param true|false' if data_option[:default].nil?
|
||||
raise 'Need data_option[:default] param true|false|undefined' if !data_option.key?(:default)
|
||||
raise 'Invalid data_option[:options] param' if data_option[:options].nil?
|
||||
end
|
||||
|
||||
|
|
|
@ -176,15 +176,213 @@ class AdminObjectManagerTest < TestCase
|
|||
},
|
||||
)
|
||||
|
||||
sleep 10
|
||||
|
||||
object_manager_attribute_discard_changes
|
||||
|
||||
#object_manager_attribute_delete(
|
||||
# data: {
|
||||
# name: 'browser_test2',
|
||||
sleep 4
|
||||
|
||||
object_manager_attribute_create(
|
||||
data: {
|
||||
name: 'browser_test2',
|
||||
display: 'Browser Test 2',
|
||||
data_type: 'Text',
|
||||
#data_option: {
|
||||
# default: 'xxx',
|
||||
#},
|
||||
#)
|
||||
},
|
||||
)
|
||||
object_manager_attribute_create(
|
||||
data: {
|
||||
name: 'browser_test3',
|
||||
display: 'Browser Test 3',
|
||||
data_type: 'Select',
|
||||
data_option: {
|
||||
options: {
|
||||
'aa' => 'AA',
|
||||
'bb' => 'BB',
|
||||
'cc' => 'CC',
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
object_manager_attribute_create(
|
||||
data: {
|
||||
name: 'browser_test4',
|
||||
display: 'Browser Test 4',
|
||||
data_type: 'Integer',
|
||||
#data_option: {
|
||||
# default: 'xxx',
|
||||
# min: 15,
|
||||
# max: 99,
|
||||
#},
|
||||
},
|
||||
)
|
||||
|
||||
object_manager_attribute_create(
|
||||
data: {
|
||||
name: 'browser_test5',
|
||||
display: 'Browser Test 5',
|
||||
data_type: 'Datetime',
|
||||
#data_option: {
|
||||
# future: true,
|
||||
# past: true,
|
||||
# diff: 24
|
||||
#},
|
||||
},
|
||||
)
|
||||
|
||||
object_manager_attribute_create(
|
||||
data: {
|
||||
name: 'browser_test6',
|
||||
display: 'Browser Test 6',
|
||||
data_type: 'Date',
|
||||
#data_option: {
|
||||
# future: true,
|
||||
# past: true,
|
||||
# diff: 24
|
||||
#},
|
||||
},
|
||||
)
|
||||
|
||||
object_manager_attribute_create(
|
||||
data: {
|
||||
name: 'browser_test7',
|
||||
display: 'Browser Test 7',
|
||||
data_type: 'Boolean',
|
||||
data_option: {
|
||||
options: {
|
||||
true: 'YES',
|
||||
false: 'NO',
|
||||
},
|
||||
# default: true,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
watch_for(
|
||||
css: '#content',
|
||||
value: 'Database Update required',
|
||||
)
|
||||
click(css: '#content .tab-pane.active div.js-execute')
|
||||
watch_for(
|
||||
css: '.modal',
|
||||
value: 'restart',
|
||||
)
|
||||
watch_for_disappear(
|
||||
css: '.modal',
|
||||
timeout: 120,
|
||||
)
|
||||
sleep 5
|
||||
watch_for(
|
||||
css: '#content',
|
||||
)
|
||||
|
||||
# create new ticket
|
||||
ticket = ticket_create(
|
||||
data: {
|
||||
customer: 'nico',
|
||||
group: 'Users',
|
||||
priority: '2 normal',
|
||||
state: 'open',
|
||||
title: 'ticket attribute test all #1',
|
||||
body: 'ticket attribute test all #1',
|
||||
},
|
||||
custom_data_select: {
|
||||
browser_test3: 'CC',
|
||||
browser_test7: 'NO',
|
||||
},
|
||||
custom_data_input: {
|
||||
browser_test2: 'some value öäüß',
|
||||
browser_test4: '25',
|
||||
},
|
||||
disable_group_check: true,
|
||||
)
|
||||
|
||||
ticket_verify(
|
||||
data: {
|
||||
title: 'ticket attribute test all #1',
|
||||
custom_data_select: {
|
||||
browser_test3: 'CC',
|
||||
browser_test7: 'NO',
|
||||
},
|
||||
custom_data_input: {
|
||||
browser_test2: 'some value öäüß',
|
||||
browser_test4: '25',
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
object_manager_attribute_delete(
|
||||
data: {
|
||||
name: 'browser_test2',
|
||||
},
|
||||
)
|
||||
object_manager_attribute_delete(
|
||||
data: {
|
||||
name: 'browser_test3',
|
||||
},
|
||||
)
|
||||
object_manager_attribute_delete(
|
||||
data: {
|
||||
name: 'browser_test4',
|
||||
},
|
||||
)
|
||||
object_manager_attribute_delete(
|
||||
data: {
|
||||
name: 'browser_test5',
|
||||
},
|
||||
)
|
||||
object_manager_attribute_delete(
|
||||
data: {
|
||||
name: 'browser_test6',
|
||||
},
|
||||
)
|
||||
object_manager_attribute_delete(
|
||||
data: {
|
||||
name: 'browser_test7',
|
||||
},
|
||||
)
|
||||
click(css: '#content .tab-pane.active div.js-execute')
|
||||
watch_for(
|
||||
css: '.modal',
|
||||
value: 'restart',
|
||||
)
|
||||
watch_for_disappear(
|
||||
css: '.modal',
|
||||
timeout: 120,
|
||||
)
|
||||
sleep 5
|
||||
watch_for(
|
||||
css: '#content',
|
||||
)
|
||||
match_not(
|
||||
css: '#content',
|
||||
value: 'Database Update required',
|
||||
)
|
||||
match_not(
|
||||
css: '#content table',
|
||||
value: 'browser_test2',
|
||||
)
|
||||
match_not(
|
||||
css: '#content table',
|
||||
value: 'browser_test3',
|
||||
)
|
||||
match_not(
|
||||
css: '#content table',
|
||||
value: 'browser_test4',
|
||||
)
|
||||
match_not(
|
||||
css: '#content table',
|
||||
value: 'browser_test5',
|
||||
)
|
||||
match_not(
|
||||
css: '#content table',
|
||||
value: 'browser_test6',
|
||||
)
|
||||
match_not(
|
||||
css: '#content table',
|
||||
value: 'browser_test7',
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -30,11 +30,11 @@ class SettingTest < TestCase
|
|||
|
||||
# set yes
|
||||
select(
|
||||
css: '#auth_facebook select[name="{boolean}auth_facebook"]',
|
||||
css: '#auth_facebook select[name="auth_facebook"]',
|
||||
value: 'yes',
|
||||
)
|
||||
match(
|
||||
css: '#auth_facebook select[name="{boolean}auth_facebook"]',
|
||||
css: '#auth_facebook select[name="auth_facebook"]',
|
||||
value: 'yes',
|
||||
)
|
||||
click( css: '#auth_facebook button[type=submit]' )
|
||||
|
@ -44,17 +44,17 @@ class SettingTest < TestCase
|
|||
)
|
||||
sleep 4
|
||||
match(
|
||||
css: '#auth_facebook select[name="{boolean}auth_facebook"]',
|
||||
css: '#auth_facebook select[name="auth_facebook"]',
|
||||
value: 'yes',
|
||||
)
|
||||
match_not(
|
||||
css: '#auth_facebook select[name="{boolean}auth_facebook"]',
|
||||
css: '#auth_facebook select[name="auth_facebook"]',
|
||||
value: 'no',
|
||||
)
|
||||
|
||||
# set no
|
||||
select(
|
||||
css: '#auth_facebook select[name="{boolean}auth_facebook"]',
|
||||
css: '#auth_facebook select[name="auth_facebook"]',
|
||||
value: 'no',
|
||||
)
|
||||
click( css: '#auth_facebook button[type=submit]' )
|
||||
|
@ -64,11 +64,11 @@ class SettingTest < TestCase
|
|||
)
|
||||
sleep 4
|
||||
match(
|
||||
css: '#auth_facebook select[name="{boolean}auth_facebook"]',
|
||||
css: '#auth_facebook select[name="auth_facebook"]',
|
||||
value: 'no',
|
||||
)
|
||||
match_not(
|
||||
css: '#auth_facebook select[name="{boolean}auth_facebook"]',
|
||||
css: '#auth_facebook select[name="auth_facebook"]',
|
||||
value: 'yes',
|
||||
)
|
||||
|
||||
|
|
|
@ -1779,7 +1779,7 @@ wait untill text in selector disabppears
|
|||
browser: instance,
|
||||
css: ".active .newTicket select[name=\"#{local_key}\"]",
|
||||
value: local_value,
|
||||
mute_log: true,
|
||||
#mute_log: true,
|
||||
)
|
||||
}
|
||||
end
|
||||
|
@ -1790,7 +1790,7 @@ wait untill text in selector disabppears
|
|||
css: ".active .newTicket input[name=\"#{local_key}\"]",
|
||||
value: local_value,
|
||||
clear: true,
|
||||
mute_log: true,
|
||||
#mute_log: true,
|
||||
)
|
||||
}
|
||||
end
|
||||
|
@ -2018,7 +2018,7 @@ wait untill text in selector disabppears
|
|||
browser: instance,
|
||||
css: ".active .sidebar select[name=\"#{local_key}\"]",
|
||||
value: local_value,
|
||||
mute_log: true,
|
||||
#mute_log: true,
|
||||
)
|
||||
}
|
||||
end
|
||||
|
@ -2029,7 +2029,7 @@ wait untill text in selector disabppears
|
|||
css: ".active .sidebar input[name=\"#{local_key}\"]",
|
||||
value: local_value,
|
||||
clear: true,
|
||||
mute_log: true,
|
||||
#mute_log: true,
|
||||
)
|
||||
}
|
||||
end
|
||||
|
@ -2095,6 +2095,12 @@ wait untill text in selector disabppears
|
|||
body: 'some body',
|
||||
## group: 'some group',
|
||||
## state: 'closed',
|
||||
custom_data_select: {
|
||||
key1: 'some value',
|
||||
},
|
||||
custom_data_input: {
|
||||
key1: 'some value',
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -2108,7 +2114,7 @@ wait untill text in selector disabppears
|
|||
data = params[:data]
|
||||
|
||||
if data[:title]
|
||||
title = instance.find_elements(css: '.content.active .ticketZoom-header .js-objectTitle')[0].text.strip
|
||||
title = instance.find_elements(css: '.content.active .ticketZoom-header .js-objectTitle').first.text.strip
|
||||
if title =~ /#{data[:title]}/i
|
||||
assert(true, "matching '#{data[:title]}' in title '#{title}'")
|
||||
else
|
||||
|
@ -2117,13 +2123,37 @@ wait untill text in selector disabppears
|
|||
end
|
||||
|
||||
if data[:body]
|
||||
body = instance.find_elements(css: '.content.active [data-name="body"]')[0].text.strip
|
||||
body = instance.find_elements(css: '.content.active [data-name="body"]').first.text.strip
|
||||
if body =~ /#{data[:body]}/i
|
||||
assert(true, "matching '#{data[:body]}' in body '#{body}'")
|
||||
else
|
||||
raise "not matching '#{data[:body]}' in body '#{body}'"
|
||||
end
|
||||
end
|
||||
|
||||
if params[:custom_data_select]
|
||||
params[:custom_data_select].each {|local_key, local_value|
|
||||
element = instance.find_elements(css: ".active .sidebar select[name=\"#{local_key}\"] option[selected]").first
|
||||
value = element.text.strip
|
||||
if value =~ /#{local_value}/i
|
||||
assert(true, "matching '#{value}' in #{local_key} '#{local_value}'")
|
||||
else
|
||||
raise "not matching '#{value}' in #{local_key} '#{local_value}'"
|
||||
end
|
||||
}
|
||||
end
|
||||
if params[:custom_data_input]
|
||||
params[:custom_data_input].each {|local_key, local_value|
|
||||
element = instance.find_elements(css: ".active .sidebar input[name=\"#{local_key}\"]").first
|
||||
value = element.text.strip
|
||||
if value =~ /#{local_value}/i
|
||||
assert(true, "matching '#{value}' in #{local_key} '#{local_value}'")
|
||||
else
|
||||
raise "not matching '#{value}' in #{local_key} '#{local_value}'"
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -2717,12 +2747,89 @@ wait untill text in selector disabppears
|
|||
data: {
|
||||
name: 'field_name' + random,
|
||||
display: 'Display Name of Field',
|
||||
data_type: 'Text', # Text|Select|...
|
||||
data_type: 'Select',
|
||||
data_option: {
|
||||
options: {
|
||||
'aa' => 'AA',
|
||||
'bb' => 'BB',
|
||||
},
|
||||
|
||||
default: 'abc',
|
||||
},
|
||||
},
|
||||
error: 'already exists'
|
||||
)
|
||||
|
||||
object_manager_attribute_create(
|
||||
browser: browser2,
|
||||
data: {
|
||||
name: 'field_name' + random,
|
||||
display: 'Display Name of Field',
|
||||
data_type: 'Text',
|
||||
data_option: {
|
||||
default: 'abc',
|
||||
},
|
||||
},
|
||||
error: 'already exists'
|
||||
)
|
||||
|
||||
object_manager_attribute_create(
|
||||
browser: browser2,
|
||||
data: {
|
||||
name: 'field_name' + random,
|
||||
display: 'Display Name of Field',
|
||||
data_type: 'Integer',
|
||||
data_option: {
|
||||
default: '15',
|
||||
min: 1,
|
||||
max: 999999,
|
||||
},
|
||||
},
|
||||
error: 'already exists'
|
||||
)
|
||||
|
||||
object_manager_attribute_create(
|
||||
browser: browser2,
|
||||
data: {
|
||||
name: 'field_name' + random,
|
||||
display: 'Display Name of Field',
|
||||
data_type: 'Datetime',
|
||||
data_option: {
|
||||
future: true,
|
||||
past: true,
|
||||
diff: 24,
|
||||
},
|
||||
},
|
||||
error: 'already exists'
|
||||
)
|
||||
|
||||
object_manager_attribute_create(
|
||||
browser: browser2,
|
||||
data: {
|
||||
name: 'field_name' + random,
|
||||
display: 'Display Name of Field',
|
||||
data_type: 'Date',
|
||||
data_option: {
|
||||
future: true,
|
||||
past: true,
|
||||
diff: 24,
|
||||
},
|
||||
},
|
||||
error: 'already exists'
|
||||
)
|
||||
|
||||
object_manager_attribute_create(
|
||||
browser: browser2,
|
||||
data: {
|
||||
name: 'field_name' + random,
|
||||
display: 'Display Name of Field',
|
||||
data_type: 'Boolean',
|
||||
data_option: {
|
||||
options: {
|
||||
true: 'YES',
|
||||
false: 'NO',
|
||||
}
|
||||
default: undefined,
|
||||
},
|
||||
},
|
||||
error: 'already exists'
|
||||
|
@ -2768,6 +2875,14 @@ wait untill text in selector disabppears
|
|||
)
|
||||
if data[:data_option]
|
||||
if data[:data_option][:options]
|
||||
if data[:data_type] == 'Boolean'
|
||||
element = instance.find_elements(css: '.modal .js-valueTrue').first
|
||||
element.clear
|
||||
element.send_keys(data[:data_option][:options][:true])
|
||||
element = instance.find_elements(css: '.modal .js-valueFalse').first
|
||||
element.clear
|
||||
element.send_keys(data[:data_option][:options][:false])
|
||||
else
|
||||
data[:data_option][:options].each {|key, value|
|
||||
element = instance.find_elements(css: '.modal .js-Table .js-key').last
|
||||
element.clear
|
||||
|
@ -2780,6 +2895,25 @@ wait untill text in selector disabppears
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
[:default, :min, :max, :diff].each {|key|
|
||||
next if !data[:data_option].key?(key)
|
||||
element = instance.find_elements(css: ".modal [name=\"data_option::#{key}\"]").first
|
||||
element.clear
|
||||
element.send_keys(data[:data_option][key])
|
||||
}
|
||||
|
||||
[:future, :past].each {|key|
|
||||
next if !data[:data_option].key?(key)
|
||||
select(
|
||||
browser: instance,
|
||||
css: ".modal select[name=\"data_option::#{key}\"]",
|
||||
value: data[:data_option][key],
|
||||
mute_log: true,
|
||||
)
|
||||
}
|
||||
|
||||
end
|
||||
instance.find_elements(css: '.modal button.js-submit')[0].click
|
||||
if params[:error]
|
||||
sleep 4
|
||||
|
@ -2824,6 +2958,9 @@ wait untill text in selector disabppears
|
|||
switch_window_focus(params)
|
||||
log('object_manager_attribute_delete', params)
|
||||
|
||||
instance = params[:browser] || @browser
|
||||
data = params[:data]
|
||||
|
||||
click(
|
||||
browser: instance,
|
||||
css: 'a[href="#manage"]',
|
||||
|
|
Loading…
Reference in a new issue