Fixes #2669 - Pressing "Cancel" in a new ticket dialog doesn't close it's tab

This commit is contained in:
Mantas Masalskis 2021-05-17 15:12:45 +00:00 committed by Thorsten Eckel
parent 17f457cb58
commit 2001ac6968
4 changed files with 44 additions and 3 deletions

View file

@ -442,7 +442,9 @@ class App.TicketCreate extends App.Controller
cancel: (e) ->
e.preventDefault()
@navigate '#'
worker = App.TaskManager.worker(@taskKey)
App.Event.trigger('taskClose', [worker.taskKey])
params: =>
params = @formParam(@$('.main form'))

View file

@ -59,6 +59,10 @@ class App.TaskbarWidget extends App.CollectionController
@controllerBind('taskCollectionOrderSet', (taskKeys) =>
@collectionOrderSet(taskKeys)
)
@controllerBind('taskClose', (tasks) =>
for task in tasks
@remove(null, task)
)
itemGet: (key) ->
App.TaskManager.get(key)
@ -74,8 +78,8 @@ class App.TaskbarWidget extends App.CollectionController
@locationVerify(e)
remove: (e, key = false, force = false) =>
e.preventDefault()
e.stopPropagation()
e?.preventDefault()
e?.stopPropagation()
if !key
key = $(e.target).parents('a').data('key')
if !key

View file

@ -43,3 +43,11 @@ end
Capybara.add_selector(:link_containing) do
xpath { |text| ".//a//*[text()[contains(.,\"#{text}\")]]" }
end
Capybara.add_selector(:task_active) do
css { '.tasks .task.is-active' }
end
Capybara.add_selector(:task_with) do
css { |task_key| ".tasks .task[data-key='#{task_key}']" }
end

View file

@ -449,4 +449,31 @@ RSpec.describe 'Ticket Create', type: :system do
end
end
end
# https://github.com/zammad/zammad/issues/2669
context 'when canceling new ticket creation' do
it 'closes the dialog' do
visit 'ticket/create'
task_key = find(:task_active)['data-key']
expect { click('.js-cancel') }.to change { has_selector?(:task_with, task_key, wait: 0) }.to(false)
end
it 'asks for confirmation if the dialog was modified' do
visit 'ticket/create'
task_key = find(:task_active)['data-key']
find('[name=title]').fill_in with: 'Title'
click '.js-cancel'
in_modal do
click '.js-submit'
end
expect(page).to have_no_selector(:task_with, task_key)
end
end
end