diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac5fe9514..1bdd0f0d7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -51,7 +51,7 @@ test:rspec:mysql: - rake db:create - rake db:migrate - rake db:seed - - rspec + - bundle exec rspec - rake db:drop test:rspec:postgresql: @@ -64,7 +64,7 @@ test:rspec:postgresql: - rake db:create - rake db:migrate - rake db:seed - - rspec + - bundle exec rspec - rake db:drop test:unit:mysql: @@ -410,7 +410,7 @@ test:browser:integration:api_client_ruby: - cd zammad-api-client-ruby - bundle install --jobs 8 - export TEST_URL=http://$IP:$BROWSER_PORT/ - - rspec || (cd .. && script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1) + - bundle exec rspec || (cd .. && script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 1 1) - cd .. && script/build/test_shutdown.sh $RAILS_ENV $BROWSER_PORT $WS_PORT 0 1 test:browser:integration:api_client_php: diff --git a/app/assets/javascripts/app/controllers/_application_controller.coffee b/app/assets/javascripts/app/controllers/_application_controller.coffee index 95d242233..65ca0e4ef 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.coffee @@ -676,6 +676,7 @@ class App.ControllerModal extends App.Controller closeOnAnyClick: false initalFormParams: {} initalFormParamsIgnore: false + showTrySupport: false showTryMax: 10 showTrydelay: 1000 @@ -722,7 +723,7 @@ class App.ControllerModal extends App.Controller content = @contentInline else content = @content() - modal = $(App.view('modal') + modal = $(App.view('modal')( head: @head headPrefix: @headPrefix message: @message @@ -734,7 +735,7 @@ class App.ControllerModal extends App.Controller buttonClass: @buttonClass centerButtons: @centerButtons leftButtons: @leftButtons - ) + )) modal.find('.modal-body').html(content) if !@initRenderingDone @initRenderingDone = true @@ -750,7 +751,7 @@ class App.ControllerModal extends App.Controller @el render: => - if @modalAlreadyExists() && @showTryCount <= @showTryMax + if @showTrySupport is true && @modalAlreadyExists() && @showTryCount <= @showTryMax @showDelayed() return @@ -827,7 +828,7 @@ class App.ControllerModal extends App.Controller localOnClosed: (e) => @onClosed(e) - $('.modal').remove() + @el.modal('remove') onClosed: (e) -> # do nothing @@ -851,6 +852,8 @@ class App.ControllerModal extends App.Controller @onSubmit(e) class App.SessionMessage extends App.ControllerModal + showTrySupport: true + onCancel: (e) => if @forceReload @windowReload(e) diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.coffee index b827f52c2..a378f00dd 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.coffee @@ -3,6 +3,7 @@ class App.ControllerGenericNew extends App.ControllerModal buttonCancel: true buttonSubmit: true headPrefix: 'New' + showTrySupport: true content: => @head = @pageData.head || @pageData.object @@ -236,6 +237,7 @@ class App.ControllerGenericDescription extends App.ControllerModal class App.ControllerModalLoading extends App.Controller className: 'modal fade' + showTrySupport: true constructor: -> super @@ -322,6 +324,7 @@ class App.ControllerErrorModal extends App.ControllerModal head: 'Error' #small: true #shown: true + showTrySupport: true content: -> @message diff --git a/app/assets/javascripts/app/lib/bootstrap/modal.js b/app/assets/javascripts/app/lib/bootstrap/modal.js index 08345d217..bacf76633 100644 --- a/app/assets/javascripts/app/lib/bootstrap/modal.js +++ b/app/assets/javascripts/app/lib/bootstrap/modal.js @@ -182,6 +182,13 @@ }) } + // me - 2018-05-24 + // cleanup element on hide - cleanup dom with old modal dialogs + Modal.prototype.remove = function () { + console.log('remove', this.$element) + this.$element.remove() + } + Modal.prototype.removeBackdrop = function () { this.$backdrop && this.$backdrop.remove() this.$backdrop = null diff --git a/test/browser/agent_user_manage_test.rb b/test/browser/agent_user_manage_test.rb index 347ccc18a..906427e0e 100644 --- a/test/browser/agent_user_manage_test.rb +++ b/test/browser/agent_user_manage_test.rb @@ -2,7 +2,7 @@ require 'browser_test_helper' class AgentUserManageTest < TestCase - def test_agent_user + def test_agent_customer_ticket_create customer_user_email = 'customer-test-' + rand(999_999).to_s + '@example.com' firstname = 'Customer Firstname' lastname = 'Customer Lastname' @@ -16,58 +16,66 @@ class AgentUserManageTest < TestCase ) tasks_close_all() - sleep 1 - # create customer click(css: 'a[href="#new"]', only_if_exists: true) click(css: 'a[href="#ticket/create"]') - click(css: '.active .newTicket [name="customer_id_completion"]') + + watch_for( + css: '.content.active .newTicket', + timeout: 1, + ) + + click(css: '.content.active .newTicket [name="customer_id_completion"]') # check if pulldown is open, it's not working stable via selenium - @browser.execute_script( "$('.active .newTicket .js-recipientDropdown').addClass('open')" ) + @browser.execute_script("$('.active .newTicket .js-recipientDropdown').addClass('open')") sleep 1 sendkey(value: :arrow_down) sleep 0.5 - click(css: '.active .newTicket .recipientList-entry.js-objectNew') - sleep 1 + click(css: '.content.active .newTicket .recipientList-entry.js-objectNew') + + watch_for( + css: '.content.active .modal', + timeout: 1, + ) set( - css: '.modal input[name="firstname"]', + css: '.content.active .modal input[name="firstname"]', value: firstname, ) set( - css: '.modal input[name="lastname"]', + css: '.content.active .modal input[name="lastname"]', value: lastname, ) set( - css: '.modal input[name="email"]', + css: '.content.active .modal input[name="email"]', value: customer_user_email, ) - click(css: '.modal button.js-submit') + click(css: '.content.active .modal button.js-submit') sleep 4 # check is used to check selected match( - css: '.active input[name="customer_id"]', + css: '.content.active .newTicket input[name="customer_id"]', value: '^\d+$', no_quote: true, ) match( - css: '.active input[name="customer_id_completion"]', + css: '.content.active .newTicket input[name="customer_id_completion"]', value: firstname, ) match( - css: '.active input[name="customer_id_completion"]', + css: '.content.active .newTicket input[name="customer_id_completion"]', value: lastname, ) match( - css: '.active input[name="customer_id_completion"]', + css: '.content.active .newTicket input[name="customer_id_completion"]', value: customer_user_email, ) match( - css: '.active input[name="customer_id_completion"]', + css: '.content.active .newTicket input[name="customer_id_completion"]', value: fullname, ) sleep 4 @@ -77,47 +85,162 @@ class AgentUserManageTest < TestCase click(css: 'a[href="#new"]', only_if_exists: true) click(css: 'a[href="#ticket/create"]') - sleep 2 + + watch_for( + css: '.content.active .newTicket', + timeout: 1, + ) match( - css: '.active input[name="customer_id"]', + css: '.content.active .newTicket input[name="customer_id"]', value: '', ) match( - css: '.active input[name="customer_id_completion"]', + css: '.content.active .newTicket input[name="customer_id_completion"]', value: '', ) set( - css: '.active .newTicket input[name="customer_id_completion"]', + css: '.content.active .newTicket input[name="customer_id_completion"]', value: customer_user_email, ) sleep 3 - click(css: '.active .newTicket .recipientList-entry.js-object.is-active') + click(css: '.content.active .newTicket .recipientList-entry.js-object.is-active') sleep 1 # check is used to check selected match( - css: '.active input[name="customer_id"]', + css: '.content.active .newTicket input[name="customer_id"]', value: '^\d+$', no_quote: true, ) match( - css: '.active input[name="customer_id_completion"]', + css: '.content.active .newTicket input[name="customer_id_completion"]', value: firstname, ) match( - css: '.active input[name="customer_id_completion"]', + css: '.content.active .newTicket input[name="customer_id_completion"]', value: lastname, ) match( - css: '.active input[name="customer_id_completion"]', + css: '.content.active .newTicket input[name="customer_id_completion"]', value: customer_user_email, ) match( - css: '.active input[name="customer_id_completion"]', + css: '.content.active .newTicket input[name="customer_id_completion"]', value: fullname, ) end + def test_agent_customer_ticket_zoom + customer_user_email = 'customer-test-' + rand(999_999).to_s + '@example.com' + firstname = 'Customer Firstname' + lastname = 'Customer Lastname' + fullname = "#{firstname} #{lastname} <#{customer_user_email}>" + + @browser = browser_instance + login( + username: 'agent1@example.com', + password: 'test', + url: browser_url, + ) + tasks_close_all() + + ticket_create( + data: { + customer: 'nico', + group: 'Users', + title: 'some changes', + body: 'some body', + }, + ) + + watch_for( + css: '.content.active .ticketZoom-header .ticket-number', + value: '\d', + ) + + click(css: '.content.active .tabsSidebar-tabs .tabsSidebar-tab[data-tab="customer"]') + + match( + css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]', + value: 'Nicole Braun', + ) + + click(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"] .js-actions') + click(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"] .js-actions li[data-type="customer-change"]') + + watch_for( + css: '.content.active .modal', + ) + + click(css: '.content.active .modal [name="customer_id_completion"]') + + # check if pulldown is open, it's not working stable via selenium + @browser.execute_script("$('.active .modal .js-recipientDropdown').addClass('open')") + + sleep 1 + sendkey(value: :arrow_down) + sleep 0.5 + click(css: '.content.active .modal .recipientList-entry.js-objectNew') + + watch_for( + css: '.content.active .modal input[name="firstname"]', + timeout: 1, + ) + + set( + css: '.content.active .modal input[name="firstname"]', + value: firstname, + ) + set( + css: '.content.active .modal input[name="lastname"]', + value: lastname, + ) + set( + css: '.content.active .modal input[name="email"]', + value: customer_user_email, + ) + + # there are 2 models, take the correct one + #click(css: '.content.active .modal button.js-submit') + @browser.execute_script("$('.content.active .modal input[name=\"firstname\"]').closest('form').find('button.js-submit').click()") + + # check is used to check selected + watch_for( + css: '.content.active .modal input[name="customer_id"]', + value: '^\d+$', + no_quote: true, + ) + match( + css: '.content.active .modal input[name="customer_id_completion"]', + value: firstname, + ) + match( + css: '.content.active .modal input[name="customer_id_completion"]', + value: lastname, + ) + match( + css: '.content.active .modal input[name="customer_id_completion"]', + value: customer_user_email, + ) + match( + css: '.content.active .modal input[name="customer_id_completion"]', + value: fullname, + ) + + click(css: '.content.active .modal button.js-submit') + + watch_for_disappear( + css: '.content.active .modal', + ) + + watch_for( + css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]', + value: customer_user_email, + timeout: 4, + ) + + end + end