From 2844b6d95da2468fb9c7f76145e1cbc0786eaf0e Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Mon, 4 Apr 2022 20:26:01 +0200 Subject: [PATCH] Maintenance: Track console js errors in chrome capybara tests. --- .../javascripts/app/controllers/search.coffee | 11 ++++++----- .../app/controllers/ticket_overview.coffee | 5 +++-- .../controllers/widget/ticket_bulk_form.coffee | 2 ++ .../app/views/agent_ticket_view/content.jst.eco | 4 +++- .../javascripts/app/views/search/index.jst.eco | 2 ++ app/models/ticket/assets.rb | 1 + spec/support/capybara/console_errors.rb | 17 +++++++++++++++++ 7 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 spec/support/capybara/console_errors.rb diff --git a/app/assets/javascripts/app/controllers/search.coffee b/app/assets/javascripts/app/controllers/search.coffee index 68056952a..1ec5781c4 100644 --- a/app/assets/javascripts/app/controllers/search.coffee +++ b/app/assets/javascripts/app/controllers/search.coffee @@ -150,7 +150,7 @@ class App.Search extends App.Controller tabModel = $(e.currentTarget).data('tab-content') tabs.find('.js-tab').removeClass('active') $(e.currentTarget).addClass('active') - @renderTab(tabModel, @result[tabModel] || []) + @renderTab(tabModel, @result?[tabModel] || []) renderTab: (model, localList) => @@ -231,15 +231,16 @@ class App.Search extends App.Controller @search(true) @delay(callback, 100) + @bulkForm.releaseController() if @bulkForm @bulkForm = new App.TicketBulkForm( - holder: localeEl - view: @view - callback: updateSearch + el: @el.find('.bulkAction') + holder: localeEl + view: @view + callback: updateSearch noSidebar: true ) # start bulk action observ - @el.append(@bulkForm.el) localElement = @$('.js-content') if localElement.find('input[name="bulk"]:checked').length isnt 0 @bulkForm.show() diff --git a/app/assets/javascripts/app/controllers/ticket_overview.coffee b/app/assets/javascripts/app/controllers/ticket_overview.coffee index 92098fe62..25ae2a04b 100644 --- a/app/assets/javascripts/app/controllers/ticket_overview.coffee +++ b/app/assets/javascripts/app/controllers/ticket_overview.coffee @@ -1212,13 +1212,14 @@ class Table extends App.Controller @renderPopovers() + @bulkForm.releaseController() if @bulkForm @bulkForm = new App.TicketBulkForm( + el: @el.find('.bulkAction') holder: @el - view: @view + view: @view ) # start bulk action observ - @el.append(@bulkForm.el) localElement = @$('.table-overview') if localElement.find('input[name="bulk"]:checked').length isnt 0 @bulkForm.show() diff --git a/app/assets/javascripts/app/controllers/widget/ticket_bulk_form.coffee b/app/assets/javascripts/app/controllers/widget/ticket_bulk_form.coffee index 04eba61f0..dd2c92734 100644 --- a/app/assets/javascripts/app/controllers/widget/ticket_bulk_form.coffee +++ b/app/assets/javascripts/app/controllers/widget/ticket_bulk_form.coffee @@ -14,6 +14,8 @@ class App.TicketBulkForm extends App.Controller constructor: -> super + return if !@permissionCheck('ticket.agent') + @configure_attributes_ticket = [] used_attributes = ['state_id', 'pending_time', 'priority_id', 'group_id', 'owner_id'] diff --git a/app/assets/javascripts/app/views/agent_ticket_view/content.jst.eco b/app/assets/javascripts/app/views/agent_ticket_view/content.jst.eco index 6fe1c1c7e..963809b6f 100644 --- a/app/assets/javascripts/app/views/agent_ticket_view/content.jst.eco +++ b/app/assets/javascripts/app/views/agent_ticket_view/content.jst.eco @@ -20,4 +20,6 @@
-
\ No newline at end of file + + +
diff --git a/app/assets/javascripts/app/views/search/index.jst.eco b/app/assets/javascripts/app/views/search/index.jst.eco index 6969b49ad..dee3f20a5 100644 --- a/app/assets/javascripts/app/views/search/index.jst.eco +++ b/app/assets/javascripts/app/views/search/index.jst.eco @@ -24,3 +24,5 @@ + +
diff --git a/app/models/ticket/assets.rb b/app/models/ticket/assets.rb index 66340b884..0d067e909 100644 --- a/app/models/ticket/assets.rb +++ b/app/models/ticket/assets.rb @@ -34,6 +34,7 @@ returns data[ app_model_ticket ][ id ] = attributes_with_association_ids app_model_user = User.to_app_model + group.assets(data) %w[created_by_id updated_by_id owner_id customer_id].each do |local_user_id| next if !self[ local_user_id ] diff --git a/spec/support/capybara/console_errors.rb b/spec/support/capybara/console_errors.rb new file mode 100644 index 000000000..9703c95da --- /dev/null +++ b/spec/support/capybara/console_errors.rb @@ -0,0 +1,17 @@ +# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ + +RSpec.configure do |config| + config.after(:each, type: :system) do + next if page.driver.browser.browser != :chrome + + errors = page.driver.browser.manage.logs.get(:browser).select { |m| m.level == 'SEVERE' && m.to_s =~ %r{EvalError|InternalError|RangeError|ReferenceError|SyntaxError|TypeError|URIError} } + if errors.present? + Rails.logger.error "JS ERRORS: #{errors.to_json}" + errors.each do |error| + puts "#{error.message}\n\n" + end + end + + expect(errors.length).to eq(0) + end +end