Fixes #2629 - Full quote shows "<agent> wrote:" instead of "<customer> wrote" when agent toggled article visibility

This commit is contained in:
Mantas Masalskis 2021-04-07 08:30:07 +00:00 committed by Thorsten Eckel
parent 9085ef3465
commit e73a45a30a
3 changed files with 37 additions and 4 deletions

View file

@ -344,7 +344,7 @@ class EmailReply extends App.Controller
return ''
date = @date_format(article.created_at)
name = article.updated_by.displayName()
name = (article.origin_by || article.created_by).displayName()
App.i18n.translateInline('On %s, %s wrote:', date, name) + '<br><br>'

View file

@ -16,6 +16,7 @@ class App.TicketArticle extends App.Model
{ name: 'created_at', display: 'Created', tag: 'datetime', readonly: 1, searchable: false },
{ name: 'updated_by_id', display: 'Updated by', relation: 'User', readonly: 1, searchable: false },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1, searchable: false },
{ name: 'origin_by_id', display: 'Origin By', relation: 'User', readonly: 1 },
]
uiUrl: ->

View file

@ -1,17 +1,17 @@
require 'rails_helper'
RSpec.describe 'Ticket > Update > Full Quote Header', type: :system, time_zone: 'Europe/London' do
RSpec.describe 'Ticket > Update > Full Quote Header', current_user_id: -> { current_user.id }, type: :system, time_zone: 'Europe/London' do
let(:group) { Group.find_by(name: 'Users') }
let(:ticket) { create(:ticket, group: group) }
let(:ticket_article) { create(:ticket_article, ticket: ticket, from: 'Example Name <asdf1@example.com>') }
let(:customer) { create(:customer) }
let(:current_user) { customer }
prepend_before do
Setting.set 'ui_ticket_zoom_article_email_full_quote_header', full_quote_header_setting
end
before do
UserInfo.current_user_id = customer.id
visit "ticket/zoom/#{ticket_article.ticket.id}"
end
@ -38,6 +38,17 @@ RSpec.describe 'Ticket > Update > Full Quote Header', type: :system, time_zone:
end
end
it 'includes OP when article visibility toggled' do
within(:active_content) do
set_internal
highlight_and_click_reply
within(:richtext) do
expect(page).to contain_full_quote(ticket_article).formatted_for(:reply)
end
end
end
context 'when customer is agent' do
let(:customer) { create(:agent) }
@ -51,6 +62,23 @@ RSpec.describe 'Ticket > Update > Full Quote Header', type: :system, time_zone:
end
end
end
context 'ticket is created by agent on behalf of customer' do
let(:agent) { create(:agent) }
let(:current_user) { agent }
let(:ticket) { create(:ticket, group: group, title: 'Created by agent on behalf of a customer', customer: customer) }
let(:ticket_article) { create(:ticket_article, ticket: ticket, from: 'Created by agent on behalf of a customer', origin_by_id: customer.id) }
it 'includes OP without email when replying' do
within(:active_content) do
highlight_and_click_reply
within(:richtext) do
expect(page).to contain_full_quote(ticket_article).formatted_for(:reply)
end
end
end
end
end
context 'when "ui_ticket_zoom_article_email_full_quote_header" is disabled' do
@ -81,6 +109,10 @@ RSpec.describe 'Ticket > Update > Full Quote Header', type: :system, time_zone:
click '.js-ArticleAction[data-type=emailForward]'
end
def set_internal
click '.js-ArticleAction[data-type=internal]'
end
def highlight_and_click_reply
find('.ticket-article-item .textBubble')
.execute_script <<~JAVASCRIPT
@ -162,7 +194,7 @@ RSpec.describe 'Ticket > Update > Full Quote Header', type: :system, time_zone:
end
def name
expected.created_by.fullname
(expected.origin_by || expected.created_by).fullname
end
def email