From a7e0d460aa91e2481aa44481d2c1df80af23e159 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Thu, 7 Oct 2021 09:01:07 +0200 Subject: [PATCH] Fixes #3789 - Article box opening on tickets with no changes. --- .../ticket_zoom/article_new.coffee | 4 +-- spec/system/ticket/zoom_spec.rb | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) 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 82411fe48..e8802b8e3 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee @@ -98,7 +98,7 @@ class App.TicketZoomArticleNew extends App.Controller @controllerBind('ui:rerender', => @adjustedTextarea = false @defaults = @ui.taskGet('article') - @attachments = @defaults.attachments + @attachments = @defaults.attachments || [] @render() ) @@ -117,7 +117,7 @@ class App.TicketZoomArticleNew extends App.Controller @tokanice(@type) - if @defaults.body or @attachments or @isIE10() + if @defaults.body or @attachments.length > 0 or @isIE10() @openTextarea(null, true) tokanice: (type = 'email') -> diff --git a/spec/system/ticket/zoom_spec.rb b/spec/system/ticket/zoom_spec.rb index 8a63fba43..07b57b31d 100644 --- a/spec/system/ticket/zoom_spec.rb +++ b/spec/system/ticket/zoom_spec.rb @@ -2193,4 +2193,39 @@ RSpec.describe 'Ticket zoom', type: :system do end end end + + context 'Article box opening on tickets with no changes #3789' do + let(:ticket) { create(:ticket, group: Group.find_by(name: 'Users')) } + + before do + visit "#ticket/zoom/#{ticket.id}" + end + + it 'does not expand the article box without changes' do + refresh + sleep 3 + expect(page).to have_no_selector('form.article-add.is-open') + end + + it 'does open and close by usage' do + find('.js-textarea').send_keys(' ') + expect(page).to have_selector('form.article-add.is-open') + find('input#global-search').click + expect(page).to have_no_selector('form.article-add.is-open') + end + + it 'does open automatically when body is given from sidebar' do + find('.js-textarea').send_keys('test') + wait(5).until { Taskbar.find_by(key: "Ticket-#{ticket.id}").state.dig('article', 'body').present? } + refresh + expect(page).to have_selector('form.article-add.is-open') + end + + it 'does open automatically when attachment is given from sidebar' do + page.find('input#fileUpload_1', visible: :all).set(Rails.root.join('test/data/mail/mail001.box')) + wait(5).until { Taskbar.find_by(key: "Ticket-#{ticket.id}").attributes_with_association_ids['attachments'].present? } + refresh + expect(page).to have_selector('form.article-add.is-open') + end + end end