diff --git a/app/assets/javascripts/app/controllers/_ui_element/richtext.coffee b/app/assets/javascripts/app/controllers/_ui_element/richtext.coffee index 387a35a8f..262b742b2 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/richtext.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/richtext.coffee @@ -73,12 +73,19 @@ class App.UiElement.richtext @attachmentPlaceholder.addClass('hide') @attachmentUpload.removeClass('hide') @cancelContainer.removeClass('hide') + # Disable the create ticket button during uploading + $('.main .newTicket .page-content .js-submit') + .text(App.i18n.translateInline('Uploading')) + .addClass('is-disabled') App.Log.debug 'UiElement.richtext', 'upload start' onAborted: => @attachmentPlaceholder.removeClass('hide') @attachmentUpload.addClass('hide') item.find('input').val('') + $('.main .newTicket .page-content .js-submit') + .text(App.i18n.translateInline('Create')) + .removeClass('is-disabled') # Called after received response from the server onCompleted: (response) => @@ -93,6 +100,9 @@ class App.UiElement.richtext renderFile(response.data) item.find('input').val('') + $('.main .newTicket .page-content .js-submit') + .text(App.i18n.translateInline('Create')) + .removeClass('is-disabled') App.Log.debug 'UiElement.richtext', 'upload complete', response.data diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee index d02f7db5a..4f3416985 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee @@ -188,11 +188,18 @@ class App.TicketZoomArticleNew extends App.Controller @attachmentPlaceholder.addClass('hide') @attachmentUpload.removeClass('hide') @cancelContainer.removeClass('hide') + # Disable the update ticket button during uploading + $('.active .attributeBar .js-submit') + .text(App.i18n.translateInline('Uploading')) + .addClass('is-disabled') onAborted: => @attachmentPlaceholder.removeClass('hide') @attachmentUpload.addClass('hide') @$('.article-attachment input').val('') + $('.active .attributeBar .js-submit') + .text(App.i18n.translateInline('Update')) + .removeClass('is-disabled') # Called after received response from the server onCompleted: (response) => @@ -209,6 +216,9 @@ class App.TicketZoomArticleNew extends App.Controller @renderAttachment(response.data) @$('.article-attachment input').val('') + $('.active .attributeBar .js-submit') + .text(App.i18n.translateInline('Update')) + .removeClass('is-disabled') # Called during upload progress, first parameter # is decimal value from 0 to 100. diff --git a/test/browser/agent_ticket_attachment_test.rb b/test/browser/agent_ticket_attachment_test.rb index d199c0d64..be0feb36d 100644 --- a/test/browser/agent_ticket_attachment_test.rb +++ b/test/browser/agent_ticket_attachment_test.rb @@ -302,4 +302,76 @@ class AgentTicketAttachmentTest < TestCase # some form reset checks end + + def test_upload_blocks_ticket_updates + # since selenium webdriver with firefox is not able to upload files, skip here + # https://github.com/w3c/webdriver/issues/1230 + return if browser == 'firefox' + + @browser = browser_instance + login( + username: 'agent1@example.com', + password: 'test', + url: browser_url, + ) + tasks_close_all() + + ticket1 = ticket_create( + data: { + customer: 'Nico', + group: 'Users', + title: 'Ticket 1', + body: 'some body', + }, + do_not_submit: true, + ) + + # First test the attachment uploading for new tickets + file_upload( + css: '.content.active .attachmentPlaceholder-inputHolder input', + files: [Rails.root.join('test', 'data', 'upload', 'upload2.jpg')], + no_sleep: true, + ) + match( + css: '.js-submit.is-disabled', + value: 'Uploading', + ) + watch_for_disappear( + css: '.js-submit.is-disabled', + value: 'Uploading', + ) + match( + css: '.js-submit', + value: 'Create', + ) + click( + css: '.active .js-submit', + ) + sleep 2 + + # Next test the attachment uploading for new articles + ticket_update( + data: { + body: 'added attachment', + }, + do_not_submit: true, + ) + file_upload( + css: '.content.active .attachmentPlaceholder-inputHolder input', + files: [Rails.root.join('test', 'data', 'upload', 'upload2.jpg')], + no_sleep: true, + ) + match( + css: '.js-submit.is-disabled', + value: 'Uploading', + ) + watch_for_disappear( + css: '.js-submit.is-disabled', + value: 'Uploading', + ) + match( + css: '.js-submit', + value: 'Update', + ) + end end diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index af5e05d48..3556a0d20 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -1317,6 +1317,7 @@ set type of task (closeTab, closeNextInOverview, stayOnTab) params[:files].each do |file| instance.find_elements(css: params[:css])[0].send_keys(Rails.root.join(file)) end + return if params[:no_sleep] sleep 2 * params[:files].count end