Fixed issue #2042 - incorrect notification when closing a tab after setting up an object (fixes #2042)

This commit is contained in:
Billy Zhou 2018-10-30 22:51:20 +01:00 committed by Martin Edenhofer
parent a2c52538be
commit a960cdf422
4 changed files with 88 additions and 3 deletions

View file

@ -753,6 +753,11 @@ class App.Utils
changes[dataNowkey] = diff changes[dataNowkey] = diff
else if _.isObject( dataNow[dataNowkey] ) && _.isObject( dataLast[dataNowkey] ) else if _.isObject( dataNow[dataNowkey] ) && _.isObject( dataLast[dataNowkey] )
changes = @_formDiffChanges( dataNow[dataNowkey], dataLast[dataNowkey], changes ) changes = @_formDiffChanges( dataNow[dataNowkey], dataLast[dataNowkey], changes )
# fix for issue #2042 - incorrect notification when closing a tab after setting up an object
# Ignore the diff if both conditions are true:
# 1. current value is the empty string (no user input yet)
# 2. no previous value (it's a newly added attribute)
else if dataNow[dataNowkey] == '' && !dataLast[dataNowkey]?
else else
changes[dataNowkey] = dataNow[dataNowkey] changes[dataNowkey] = dataNow[dataNowkey]
changes changes

View file

@ -1508,7 +1508,6 @@ test("check form diff", function() {
pending_date: '2015-01-28T09:39:00Z', pending_date: '2015-01-28T09:39:00Z',
} }
diff = { diff = {
owner_id: '',
} }
result = App.Utils.formDiff(dataNow, dataLast) result = App.Utils.formDiff(dataNow, dataLast)
deepEqual(result, diff, 'check form diff') deepEqual(result, diff, 'check form diff')
@ -1520,7 +1519,6 @@ test("check form diff", function() {
} }
dataLast = {} dataLast = {}
diff = { diff = {
owner_id: '',
state_ids: ['1','5','6','7'], state_ids: ['1','5','6','7'],
} }
result = App.Utils.formDiff(dataNow, dataLast) result = App.Utils.formDiff(dataNow, dataLast)
@ -1548,7 +1546,6 @@ test("check form diff", function() {
state_ids: ['1','5','7'], state_ids: ['1','5','7'],
} }
diff = { diff = {
owner_id: '',
state_ids: ['6'], state_ids: ['6'],
} }
result = App.Utils.formDiff(dataNow, dataLast) result = App.Utils.formDiff(dataNow, dataLast)
@ -1714,6 +1711,30 @@ test("check form diff", function() {
deepEqual(result, diff, 'check form diff') deepEqual(result, diff, 'check form diff')
// regression test for issue #2042 - incorrect notification when closing a tab after setting up an object
// A newly created attribute will have the empty string as its value, this should be ignored for formDiff comparison
dataNow = {
test: '',
}
dataLast = {}
diff = {}
result = App.Utils.formDiff(dataNow, dataLast)
deepEqual(result, diff, 'check form diff for a newly created attribute that is blank')
dataNow = {
test: '',
}
dataLast = {
test: '123',
}
diff = {
test: '',
}
result = App.Utils.formDiff(dataNow, dataLast)
deepEqual(result, diff, 'check form diff for setting a previously valid value to blank')
dataNow = { dataNow = {
test: '123', test: '123',
ticket: { ticket: {

View file

@ -43,6 +43,7 @@ if [ "$LEVEL" == '1' ]; then
rm test/browser/agent_ticket_overview_level1_test.rb rm test/browser/agent_ticket_overview_level1_test.rb
rm test/browser/agent_ticket_overview_tab_test.rb rm test/browser/agent_ticket_overview_tab_test.rb
rm test/browser/agent_ticket_tag_test.rb rm test/browser/agent_ticket_tag_test.rb
rm test/browser/agent_ticket_task_changed_test.rb
rm test/browser/agent_ticket_text_module_test.rb rm test/browser/agent_ticket_text_module_test.rb
rm test/browser/agent_ticket_time_accounting_test.rb rm test/browser/agent_ticket_time_accounting_test.rb
rm test/browser/agent_ticket_update1_test.rb rm test/browser/agent_ticket_update1_test.rb
@ -122,6 +123,7 @@ elif [ "$LEVEL" == '2' ]; then
rm test/browser/agent_ticket_overview_level1_test.rb rm test/browser/agent_ticket_overview_level1_test.rb
rm test/browser/agent_ticket_overview_tab_test.rb rm test/browser/agent_ticket_overview_tab_test.rb
rm test/browser/agent_ticket_tag_test.rb rm test/browser/agent_ticket_tag_test.rb
rm test/browser/agent_ticket_task_changed_test.rb
# test/browser/agent_ticket_text_module_test.rb # test/browser/agent_ticket_text_module_test.rb
# test/browser/agent_ticket_time_accounting_test.rb # test/browser/agent_ticket_time_accounting_test.rb
# test/browser/agent_ticket_update1_test.rb # test/browser/agent_ticket_update1_test.rb
@ -201,6 +203,7 @@ elif [ "$LEVEL" == '3' ]; then
rm test/browser/agent_ticket_overview_level1_test.rb rm test/browser/agent_ticket_overview_level1_test.rb
rm test/browser/agent_ticket_overview_tab_test.rb rm test/browser/agent_ticket_overview_tab_test.rb
# test/browser/agent_ticket_tag_test.rb # test/browser/agent_ticket_tag_test.rb
# test/browser/agent_ticket_task_changed_test.rb
rm test/browser/agent_ticket_text_module_test.rb rm test/browser/agent_ticket_text_module_test.rb
rm test/browser/agent_ticket_time_accounting_test.rb rm test/browser/agent_ticket_time_accounting_test.rb
rm test/browser/agent_ticket_update1_test.rb rm test/browser/agent_ticket_update1_test.rb
@ -280,6 +283,7 @@ elif [ "$LEVEL" == '4' ]; then
# test/browser/agent_ticket_overview_level1_test.rb # test/browser/agent_ticket_overview_level1_test.rb
# test/browser/agent_ticket_overview_tab_test.rb # test/browser/agent_ticket_overview_tab_test.rb
rm test/browser/agent_ticket_tag_test.rb rm test/browser/agent_ticket_tag_test.rb
rm test/browser/agent_ticket_task_changed_test.rb
rm test/browser/agent_ticket_text_module_test.rb rm test/browser/agent_ticket_text_module_test.rb
rm test/browser/agent_ticket_time_accounting_test.rb rm test/browser/agent_ticket_time_accounting_test.rb
rm test/browser/agent_ticket_update1_test.rb rm test/browser/agent_ticket_update1_test.rb
@ -358,6 +362,7 @@ elif [ "$LEVEL" == '5' ]; then
rm test/browser/agent_ticket_overview_level1_test.rb rm test/browser/agent_ticket_overview_level1_test.rb
rm test/browser/agent_ticket_overview_tab_test.rb rm test/browser/agent_ticket_overview_tab_test.rb
rm test/browser/agent_ticket_tag_test.rb rm test/browser/agent_ticket_tag_test.rb
rm test/browser/agent_ticket_task_changed_test.rb
rm test/browser/agent_ticket_text_module_test.rb rm test/browser/agent_ticket_text_module_test.rb
rm test/browser/agent_ticket_time_accounting_test.rb rm test/browser/agent_ticket_time_accounting_test.rb
rm test/browser/agent_ticket_update1_test.rb rm test/browser/agent_ticket_update1_test.rb
@ -439,6 +444,7 @@ elif [ "$LEVEL" == '6' ]; then
rm test/browser/agent_ticket_overview_level1_test.rb rm test/browser/agent_ticket_overview_level1_test.rb
rm test/browser/agent_ticket_overview_tab_test.rb rm test/browser/agent_ticket_overview_tab_test.rb
rm test/browser/agent_ticket_tag_test.rb rm test/browser/agent_ticket_tag_test.rb
rm test/browser/agent_ticket_task_changed_test.rb
rm test/browser/agent_ticket_text_module_test.rb rm test/browser/agent_ticket_text_module_test.rb
rm test/browser/agent_ticket_time_accounting_test.rb rm test/browser/agent_ticket_time_accounting_test.rb
rm test/browser/agent_ticket_update1_test.rb rm test/browser/agent_ticket_update1_test.rb

View file

@ -0,0 +1,53 @@
require 'browser_test_helper'
class AgentTicketTaskChangedTest < TestCase
# regression test for issue #2042 - incorrect notification when closing a tab after setting up an object
def test_detection_of_ticket_update_after_new_attribute
@browser = instance = browser_instance
login(
username: 'master@example.com',
password: 'test',
url: browser_url,
)
tasks_close_all()
ticket = ticket_create(
data: {
customer: 'nico',
group: 'Users',
title: 'test ticket',
body: 'some body 123äöü',
},
)
object_manager_attribute_create(
data: {
name: 'text_test',
display: 'text_test',
data_type: 'Text',
},
)
object_manager_attribute_migrate
ticket_open_by_title(title: 'test ticket')
# verify the 'Discard your changes' message does not appear (since there are no changes)
assert_nil execute(js: "return $('.content.active .js-attributeBar .js-reset:not(\".hide\")').get(0)")
# try and close the existing open ticket window
instance.action.move_to(instance.find_elements(css: '#navigation .tasks .task:first-child')[0]).release.perform
instance.find_elements(css: '#navigation .tasks .task:first-child .js-close')[0].click
sleep 0.5
exists_not( css: '.modal')
object_manager_attribute_delete(
data: {
name: 'text_test',
},
)
object_manager_attribute_migrate
end
end