Fixed issue 1882 - Clearing the entered value in a not required ticket field.
This commit is contained in:
parent
3b27a22364
commit
7c23e2a2d0
7 changed files with 138 additions and 21 deletions
|
@ -507,7 +507,7 @@ class App.ControllerForm extends App.Controller
|
|||
param[newKey] = "invalid #{param[key]}"
|
||||
console.log('ERR', err)
|
||||
else
|
||||
param[newKey] = undefined
|
||||
param[newKey] = null
|
||||
delete param[key]
|
||||
|
||||
# get {datetime}
|
||||
|
@ -525,7 +525,7 @@ class App.ControllerForm extends App.Controller
|
|||
param[newKey] = "invalid #{param[key]}"
|
||||
console.log('ERR', err)
|
||||
else
|
||||
param[newKey] = undefined
|
||||
param[newKey] = null
|
||||
delete param[key]
|
||||
|
||||
# split :: fields, build objects
|
||||
|
|
|
@ -124,13 +124,13 @@ class App.Model extends Spine.Model
|
|||
if parts[0] && !parts[1]
|
||||
|
||||
# key exists not in hash || value is '' || value is undefined
|
||||
if !( attributeName of data['params'] ) || data['params'][attributeName] is '' || data['params'][attributeName] is undefined
|
||||
if !( attributeName of data['params'] ) || data['params'][attributeName] is '' || data['params'][attributeName] is undefined || data['params'][attributeName] is null
|
||||
errors[attributeName] = 'is required'
|
||||
|
||||
else if parts[0] && parts[1] && !parts[2]
|
||||
|
||||
# key exists not in hash || value is '' || value is undefined
|
||||
if !data.params[parts[0]] || !( parts[1] of data.params[parts[0]] ) || data.params[parts[0]][parts[1]] is '' || data.params[parts[0]][parts[1]] is undefined
|
||||
if !data.params[parts[0]] || !( parts[1] of data.params[parts[0]] ) || data.params[parts[0]][parts[1]] is '' || data.params[parts[0]][parts[1]] is undefined || data.params[parts[0]][parts[1]] is null
|
||||
errors[attributeName] = 'is required'
|
||||
|
||||
else
|
||||
|
|
|
@ -281,13 +281,13 @@ test("form params check", function() {
|
|||
richtext7: '',
|
||||
richtext8: '<div>lalu <i>b</i> lalu</div>',
|
||||
datetime1: '2015-01-11T12:40:00.000Z',
|
||||
datetime2: undefined,
|
||||
datetime2: null,
|
||||
datetime3: '2015-01-11T12:40:00.000Z',
|
||||
datetime4: undefined,
|
||||
datetime4: null,
|
||||
date1: '2015-01-11',
|
||||
date2: undefined,
|
||||
date2: null,
|
||||
date3: '2015-01-11',
|
||||
date4: undefined,
|
||||
date4: null,
|
||||
active1: true,
|
||||
active2: false,
|
||||
checkbox1: [],
|
||||
|
@ -518,13 +518,13 @@ test("form dependend fields check", function() {
|
|||
selectmulti2: [ "true", "false" ],
|
||||
selectmultioption1: "false",
|
||||
datetime1: '2015-01-11T12:40:00.000Z',
|
||||
datetime2: undefined,
|
||||
datetime2: null,
|
||||
datetime3: '2015-01-11T12:40:00.000Z',
|
||||
datetime4: undefined,
|
||||
datetime4: null,
|
||||
date1: '2015-01-11',
|
||||
date2: undefined,
|
||||
date2: null,
|
||||
date3: '2015-01-11',
|
||||
date4: undefined,
|
||||
date4: null,
|
||||
}
|
||||
deepEqual(params, test_params, 'form param check')
|
||||
|
||||
|
@ -547,13 +547,13 @@ test("form dependend fields check", function() {
|
|||
selectmulti2: [ "true", "false" ],
|
||||
selectmultioption1: "false",
|
||||
datetime1: null,
|
||||
datetime2: undefined,
|
||||
datetime2: null,
|
||||
datetime3: '2015-01-11T12:40:00.000Z',
|
||||
datetime4: undefined,
|
||||
datetime4: null,
|
||||
date1: '2015-01-11',
|
||||
date2: undefined,
|
||||
date2: null,
|
||||
date3: '2015-01-11',
|
||||
date4: undefined,
|
||||
date4: null,
|
||||
}
|
||||
deepEqual(params, test_params, 'form param check')
|
||||
});
|
||||
|
|
|
@ -111,7 +111,7 @@ test('datetime validation check', function() {
|
|||
// check params
|
||||
params = App.ControllerForm.params(el)
|
||||
test_params = {
|
||||
datetime1: undefined,
|
||||
datetime1: null,
|
||||
}
|
||||
deepEqual(params, test_params, 'params check')
|
||||
|
||||
|
@ -191,7 +191,7 @@ test('date validation check', function() {
|
|||
// check params
|
||||
params = App.ControllerForm.params(el)
|
||||
test_params = {
|
||||
date2: undefined,
|
||||
date2: null,
|
||||
}
|
||||
deepEqual(params, test_params, 'params check')
|
||||
|
||||
|
@ -234,7 +234,7 @@ test('date validation check', function() {
|
|||
// check params
|
||||
params = App.ControllerForm.params(el)
|
||||
test_params = {
|
||||
date2: undefined,
|
||||
date2: null,
|
||||
}
|
||||
deepEqual(params, test_params, 'params check')
|
||||
|
||||
|
@ -269,7 +269,7 @@ test( "datetime selector check", function() {
|
|||
// check params
|
||||
params = App.ControllerForm.params(el)
|
||||
test_params = {
|
||||
datetime1: undefined,
|
||||
datetime1: null,
|
||||
}
|
||||
deepEqual(params, test_params, 'params check')
|
||||
|
||||
|
@ -330,7 +330,7 @@ test( "date selector check", function() {
|
|||
// check params
|
||||
params = App.ControllerForm.params(el)
|
||||
test_params = {
|
||||
date3: undefined,
|
||||
date3: null,
|
||||
}
|
||||
deepEqual(params, test_params, 'params check')
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ if [ "$LEVEL" == '1' ]; then
|
|||
rm test/browser/agent_ticket_update1_test.rb
|
||||
rm test/browser/agent_ticket_update2_test.rb
|
||||
rm test/browser/agent_ticket_update3_test.rb
|
||||
rm test/browser/agent_ticket_update4_test.rb
|
||||
rm test/browser/agent_ticket_update_and_reload_test.rb
|
||||
rm test/browser/agent_user_manage_test.rb
|
||||
rm test/browser/agent_user_profile_test.rb
|
||||
|
@ -100,6 +101,7 @@ elif [ "$LEVEL" == '2' ]; then
|
|||
# test/browser/agent_ticket_update1_test.rb
|
||||
# test/browser/agent_ticket_update2_test.rb
|
||||
# test/browser/agent_ticket_update3_test.rb
|
||||
# test/browser/agent_ticket_update4_test.rb
|
||||
# test/browser/agent_ticket_update_and_reload_test.rb
|
||||
rm test/browser/agent_user_manage_test.rb
|
||||
rm test/browser/agent_user_profile_test.rb
|
||||
|
@ -162,6 +164,7 @@ elif [ "$LEVEL" == '3' ]; then
|
|||
rm test/browser/agent_ticket_update1_test.rb
|
||||
rm test/browser/agent_ticket_update2_test.rb
|
||||
rm test/browser/agent_ticket_update3_test.rb
|
||||
rm test/browser/agent_ticket_update4_test.rb
|
||||
rm test/browser/agent_ticket_update_and_reload_test.rb
|
||||
rm test/browser/agent_user_manage_test.rb
|
||||
rm test/browser/agent_user_profile_test.rb
|
||||
|
@ -224,6 +227,7 @@ elif [ "$LEVEL" == '4' ]; then
|
|||
rm test/browser/agent_ticket_update1_test.rb
|
||||
rm test/browser/agent_ticket_update2_test.rb
|
||||
rm test/browser/agent_ticket_update3_test.rb
|
||||
rm test/browser/agent_ticket_update4_test.rb
|
||||
rm test/browser/agent_ticket_update_and_reload_test.rb
|
||||
rm test/browser/agent_user_manage_test.rb
|
||||
rm test/browser/agent_user_profile_test.rb
|
||||
|
@ -285,6 +289,7 @@ elif [ "$LEVEL" == '5' ]; then
|
|||
rm test/browser/agent_ticket_update1_test.rb
|
||||
rm test/browser/agent_ticket_update2_test.rb
|
||||
rm test/browser/agent_ticket_update3_test.rb
|
||||
rm test/browser/agent_ticket_update4_test.rb
|
||||
rm test/browser/agent_ticket_update_and_reload_test.rb
|
||||
# test/browser/agent_user_manage_test.rb
|
||||
# test/browser/agent_user_profile_test.rb
|
||||
|
@ -349,6 +354,7 @@ elif [ "$LEVEL" == '6' ]; then
|
|||
rm test/browser/agent_ticket_update1_test.rb
|
||||
rm test/browser/agent_ticket_update2_test.rb
|
||||
rm test/browser/agent_ticket_update3_test.rb
|
||||
rm test/browser/agent_ticket_update4_test.rb
|
||||
rm test/browser/agent_ticket_update_and_reload_test.rb
|
||||
rm test/browser/agent_user_manage_test.rb
|
||||
rm test/browser/agent_user_profile_test.rb
|
||||
|
|
77
test/browser/agent_ticket_update4_test.rb
Normal file
77
test/browser/agent_ticket_update4_test.rb
Normal file
|
@ -0,0 +1,77 @@
|
|||
require 'browser_test_helper'
|
||||
|
||||
class AgentTicketUpdate4Test < TestCase
|
||||
|
||||
def test_update_date_object_for_ticket
|
||||
|
||||
@browser = browser_instance
|
||||
login(
|
||||
username: 'master@example.com',
|
||||
password: 'test',
|
||||
url: browser_url,
|
||||
)
|
||||
tasks_close_all()
|
||||
|
||||
# date object
|
||||
object_manager_attribute_create(
|
||||
data: {
|
||||
name: 'date1',
|
||||
display: "Date-#{rand(999_999)}",
|
||||
data_type: 'Date',
|
||||
},
|
||||
)
|
||||
|
||||
watch_for(
|
||||
css: '.content.active',
|
||||
value: 'Database Update required',
|
||||
)
|
||||
|
||||
click(css: '.content.active .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.active',
|
||||
)
|
||||
|
||||
# create new ticket
|
||||
ticket = ticket_create(
|
||||
data: {
|
||||
customer: 'nico',
|
||||
group: 'Users',
|
||||
priority: '2 normal',
|
||||
state: 'open',
|
||||
title: 'ticket attribute test #1',
|
||||
body: 'ticket attribute test #1',
|
||||
},
|
||||
custom_data_date: {
|
||||
date1: '02/28/2018',
|
||||
},
|
||||
disable_group_check: true,
|
||||
)
|
||||
|
||||
ticket_open_by_search(
|
||||
browser: @browser,
|
||||
number: ticket[:number],
|
||||
)
|
||||
|
||||
ticket_update(
|
||||
data: {},
|
||||
custom_data_date: {
|
||||
date1: '',
|
||||
},
|
||||
)
|
||||
click(css: '.content.active .js-submit')
|
||||
|
||||
match_not(
|
||||
css: '.active .sidebar div[data-name="date1"] input[data-item="date"]',
|
||||
value: '02/28/2018',
|
||||
)
|
||||
end
|
||||
end
|
|
@ -1832,6 +1832,9 @@ wait untill text in selector disabppears
|
|||
custom_data_input: {
|
||||
key1: 'some value',
|
||||
},
|
||||
custom_data_date: {
|
||||
key!: '02/28/2018',
|
||||
}
|
||||
disable_group_check: true,
|
||||
)
|
||||
|
||||
|
@ -1984,6 +1987,14 @@ wait untill text in selector disabppears
|
|||
clear: true,
|
||||
)
|
||||
end
|
||||
params[:custom_data_date]&.each do |local_key, local_value|
|
||||
set(
|
||||
browser: instance,
|
||||
css: ".content.active .newTicket div[data-name=\"#{local_key}\"] input[data-item=\"date\"]",
|
||||
value: local_value,
|
||||
clear: true,
|
||||
)
|
||||
end
|
||||
|
||||
if data[:attachment]
|
||||
file_upload(
|
||||
|
@ -2064,6 +2075,9 @@ wait untill text in selector disabppears
|
|||
custom_data_input: {
|
||||
key1: 'some value',
|
||||
},
|
||||
custom_data_date: {
|
||||
key1: '02/21/2018',
|
||||
},
|
||||
do_not_submit: true,
|
||||
task_type: 'stayOnTab', # default: stayOnTab / possible: closeTab, closeNextInOverview, stayOnTab
|
||||
)
|
||||
|
@ -2214,6 +2228,26 @@ wait untill text in selector disabppears
|
|||
clear: true,
|
||||
)
|
||||
end
|
||||
params[:custom_data_date]&.each do |local_key, local_value|
|
||||
click(
|
||||
browser: instance,
|
||||
css: ".active .sidebar div[data-name=\"#{local_key}\"] input[data-item=\"date\"]",
|
||||
mute_log: true,
|
||||
)
|
||||
# weird bug where you cannot "clear" for date/time input
|
||||
# this is specific chrome problem, chrome bug report: https://bugs.chromium.org/p/chromedriver/issues/detail?id=1319#c2
|
||||
# indirect issue: https://github.com/angular/protractor/issues/562#issuecomment-47745263
|
||||
11.times do
|
||||
sendkey(
|
||||
value: :backspace,
|
||||
)
|
||||
end
|
||||
set(
|
||||
browser: instance,
|
||||
css: ".active .sidebar div[data-name=\"#{local_key}\"] input[data-item=\"date\"]",
|
||||
value: local_value,
|
||||
)
|
||||
end
|
||||
|
||||
if data[:state] || data[:group] || data[:body] || params[:custom_data_select].present? || params[:custom_data_input].present?
|
||||
found = nil
|
||||
|
|
Loading…
Reference in a new issue