From e7c6ea63d025ab4dd9f4d382cc316cf39b821d44 Mon Sep 17 00:00:00 2001 From: Romit Choudhary Date: Thu, 28 Oct 2021 11:33:02 +0200 Subject: [PATCH] Fixes #2275 - Display name not used --- .../javascripts/app/lib/app_post/utils.coffee | 2 +- spec/system/ticket/update/email_reply_spec.rb | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee index cbc0585d2..04a7fbac4 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.coffee @@ -1327,7 +1327,7 @@ class App.Utils if type is 'email' && !e.attrs.value.match(/@/) || e.attrs.value.match(/\s/) e.preventDefault() return false - e.attrs.label = e.attrs.value + e.attrs.label ||= e.attrs.value true ) App.Delay.set(a, 500, undefined, 'tags') diff --git a/spec/system/ticket/update/email_reply_spec.rb b/spec/system/ticket/update/email_reply_spec.rb index c5133ee10..8d64e111f 100644 --- a/spec/system/ticket/update/email_reply_spec.rb +++ b/spec/system/ticket/update/email_reply_spec.rb @@ -17,7 +17,7 @@ RSpec.describe 'Ticket > Update > Email Reply', current_user_id: -> { current_us it 'shows error dialog when updated value is an invalid email' do within(:active_content) do - click_reply + click_email_reply find('.token').double_click find('.js-to', visible: false).sibling('.token-input').set('test') @@ -30,7 +30,7 @@ RSpec.describe 'Ticket > Update > Email Reply', current_user_id: -> { current_us it 'updates article when updated value is a valid email' do within(:active_content) do - click_reply + click_email_reply find('.token').double_click find('.js-to', visible: false).sibling('.token-input').set('user@test.com') @@ -43,7 +43,20 @@ RSpec.describe 'Ticket > Update > Email Reply', current_user_id: -> { current_us end - def click_reply + context 'when a new recipient is added in email reply' do + it 'shows both name and email in token' do + click_email_reply + + find('.js-to', visible: false).sibling('.token-input').set(customer.email) + find('ul.ui-autocomplete li:first-child', visible: false).click + + within all('.token-label')[1] do + expect(page).to have_text("#{customer.firstname} #{customer.lastname} <#{customer.email}>") + end + end + end + + def click_email_reply click '.js-ArticleAction[data-type=emailReply]' end